browser/components/tabview/test/browser_tabview_bug589324.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 const DUMMY_PAGE_URL = "http://mochi.test:8888/browser/browser/components/tabview/test/dummy_page.html";
michael@0 5 const DUMMY_PAGE_URL_2 = "http://mochi.test:8888/";
michael@0 6
michael@0 7 let state = {
michael@0 8 windows: [{
michael@0 9 tabs: [{
michael@0 10 entries: [{ url: DUMMY_PAGE_URL }],
michael@0 11 hidden: true,
michael@0 12 attributes: {},
michael@0 13 extData: {
michael@0 14 "tabview-tab":
michael@0 15 '{"bounds":{"left":21,"top":29,"width":204,"height":153},' +
michael@0 16 '"userSize":null,"url":"' + DUMMY_PAGE_URL + '","groupID":1,' +
michael@0 17 '"imageData":null,"title":null}'
michael@0 18 }
michael@0 19 },{
michael@0 20 entries: [{ url: DUMMY_PAGE_URL_2 }],
michael@0 21 hidden: false,
michael@0 22 attributes: {},
michael@0 23 extData: {
michael@0 24 "tabview-tab":
michael@0 25 '{"bounds":{"left":315,"top":29,"width":111,"height":84},' +
michael@0 26 '"userSize":null,"url":"' + DUMMY_PAGE_URL_2 + '","groupID":2,' +
michael@0 27 '"imageData":null,"title":null}'
michael@0 28 },
michael@0 29 }],
michael@0 30 selected:2,
michael@0 31 _closedTabs: [],
michael@0 32 extData: {
michael@0 33 "tabview-groups": '{"nextID":3,"activeGroupId":2}',
michael@0 34 "tabview-group":
michael@0 35 '{"1":{"bounds":{"left":15,"top":5,"width":280,"height":232},' +
michael@0 36 '"userSize":null,"title":"","id":1},' +
michael@0 37 '"2":{"bounds":{"left":309,"top":5,"width":267,"height":226},' +
michael@0 38 '"userSize":null,"title":"","id":2}}',
michael@0 39 "tabview-ui": '{"pageBounds":{"left":0,"top":0,"width":788,"height":548}}'
michael@0 40 }, sizemode:"normal"
michael@0 41 }]
michael@0 42 };
michael@0 43
michael@0 44 function test() {
michael@0 45 waitForExplicitFinish();
michael@0 46
michael@0 47 registerCleanupFunction(function () {
michael@0 48 Services.prefs.clearUserPref("browser.sessionstore.restore_hidden_tabs");
michael@0 49 });
michael@0 50
michael@0 51 Services.prefs.setBoolPref("browser.sessionstore.restore_hidden_tabs", false);
michael@0 52
michael@0 53 testTabSwitchAfterRestore(function () {
michael@0 54 Services.prefs.setBoolPref("browser.sessionstore.restore_hidden_tabs", true);
michael@0 55 testTabSwitchAfterRestore(finish);
michael@0 56 });
michael@0 57 }
michael@0 58
michael@0 59 function testTabSwitchAfterRestore(callback) {
michael@0 60 newWindowWithState(state, function (win) {
michael@0 61 registerCleanupFunction(function () win.close());
michael@0 62
michael@0 63 let [firstTab, secondTab] = win.gBrowser.tabs;
michael@0 64 is(firstTab.linkedBrowser.currentURI.spec, DUMMY_PAGE_URL,
michael@0 65 "The url of first tab url is dummy_page.html");
michael@0 66
michael@0 67 // check the hidden state of both tabs.
michael@0 68 ok(firstTab.hidden, "The first tab is hidden");
michael@0 69 ok(!secondTab.hidden, "The second tab is not hidden");
michael@0 70 is(secondTab, win.gBrowser.selectedTab, "The second tab is selected");
michael@0 71
michael@0 72 // when the second tab is hidden, Panorama should be initialized and
michael@0 73 // the first tab should be visible.
michael@0 74 let container = win.gBrowser.tabContainer;
michael@0 75 container.addEventListener("TabHide", function onTabHide() {
michael@0 76 container.removeEventListener("TabHide", onTabHide, false);
michael@0 77
michael@0 78 ok(win.TabView.getContentWindow(), "Panorama is loaded");
michael@0 79 ok(!firstTab.hidden, "The first tab is not hidden");
michael@0 80 is(firstTab, win.gBrowser.selectedTab, "The first tab is selected");
michael@0 81 ok(secondTab.hidden, "The second tab is hidden");
michael@0 82
michael@0 83 callback();
michael@0 84 }, false);
michael@0 85
michael@0 86 // switch to another tab
michael@0 87 win.switchToTabHavingURI(DUMMY_PAGE_URL);
michael@0 88 });
michael@0 89 }

mercurial