browser/components/tabview/test/browser_tabview_bug629195.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 let win;
michael@0 5 let contentWindow;
michael@0 6 let originalTab;
michael@0 7
michael@0 8 function test() {
michael@0 9 waitForExplicitFinish();
michael@0 10
michael@0 11 newWindowWithTabView(
michael@0 12 function() {
michael@0 13 ok(win.TabView.isVisible(), "Tab View is visible");
michael@0 14
michael@0 15 contentWindow = win.document.getElementById("tab-view").contentWindow;
michael@0 16 is(contentWindow.GroupItems.groupItems.length, 1, "There is one group");
michael@0 17 is(contentWindow.GroupItems.groupItems[0].getChildren().length, 1,
michael@0 18 "The group has only one tab item");
michael@0 19
michael@0 20 // show the undo close group button
michael@0 21 let group = contentWindow.GroupItems.groupItems[0];
michael@0 22 hideGroupItem(group, function () restore(group.id));
michael@0 23 },
michael@0 24 function(newWin) {
michael@0 25 win = newWin;
michael@0 26 originalTab = win.gBrowser.visibleTabs[0];
michael@0 27 win.gBrowser.addTab();
michael@0 28 win.gBrowser.pinTab(originalTab);
michael@0 29 }
michael@0 30 );
michael@0 31 }
michael@0 32
michael@0 33 function restore(groupId) {
michael@0 34 // window state ready
michael@0 35 let handleSSWindowStateReady = function() {
michael@0 36 win.removeEventListener("SSWindowStateReady", handleSSWindowStateReady, false);
michael@0 37
michael@0 38 executeSoon(function() {
michael@0 39 is(contentWindow.GroupItems.groupItems.length, 1, "There is one group");
michael@0 40
michael@0 41 let group = contentWindow.GroupItems.groupItems[0];
michael@0 42 ok(!group.hidden, "The group is visible");
michael@0 43 is(group.getChildren().length, 2, "This group has two tab items");
michael@0 44
michael@0 45 // check the position of the group item and the tab items.
michael@0 46 let tabItemOne = group.getChildren()[0];
michael@0 47 let tabItemTwo = group.getChildren()[1];
michael@0 48
michael@0 49 let groupBounds = group.getBounds();
michael@0 50 let tabItemOneBounds = tabItemOne.getBounds();
michael@0 51 let tabItemTwoBounds = tabItemTwo.getBounds();
michael@0 52
michael@0 53 ok(groupBounds.left < tabItemOneBounds.left &&
michael@0 54 (groupBounds.right) > (tabItemOneBounds.right) &&
michael@0 55 groupBounds.top < tabItemOneBounds.top &&
michael@0 56 (groupBounds.bottom) > (tabItemOneBounds.bottom),
michael@0 57 "Tab item one is within the group");
michael@0 58
michael@0 59 ok(groupBounds.left < tabItemOneBounds.left &&
michael@0 60 (groupBounds.right) > (tabItemTwoBounds.right) &&
michael@0 61 groupBounds.top < tabItemOneBounds.top &&
michael@0 62 (groupBounds.bottom) > (tabItemTwoBounds.bottom),
michael@0 63 "Tab item two is within the group");
michael@0 64
michael@0 65 win.close();
michael@0 66 finish();
michael@0 67 });
michael@0 68 }
michael@0 69 win.addEventListener("SSWindowStateReady", handleSSWindowStateReady, false);
michael@0 70
michael@0 71 // simulate restoring previous session (one group and two tab items)
michael@0 72 const DUMMY_PAGE_URL = "http://example.com/";
michael@0 73 let newState = {
michael@0 74 windows: [{
michael@0 75 tabs: [{
michael@0 76 entries: [{ url: DUMMY_PAGE_URL }],
michael@0 77 index: 2,
michael@0 78 hidden: false,
michael@0 79 attributes: {},
michael@0 80 extData: {
michael@0 81 "tabview-tab":
michael@0 82 '{"bounds":{"left":208,"top":54,"width":205,"height":169},' +
michael@0 83 '"userSize":null,"url":"' + DUMMY_PAGE_URL + '","groupID":' +
michael@0 84 groupId + ',"imageData":null,"title":null}'
michael@0 85 }}, {
michael@0 86 entries: [{ url: DUMMY_PAGE_URL }],
michael@0 87 index: 1,
michael@0 88 hidden: false,
michael@0 89 attributes: {},
michael@0 90 extData: {
michael@0 91 "tabview-tab":
michael@0 92 '{"bounds":{"left":429,"top":54,"width":205,"height":169},' +
michael@0 93 '"userSize":null,"url":"' + DUMMY_PAGE_URL + '","groupID":' +
michael@0 94 groupId + ',"imageData":null,"title":null}'
michael@0 95 }
michael@0 96 }],
michael@0 97 extData: {
michael@0 98 "tabview-groups": '{"nextID":' + (groupId + 1) + ',"activeGroupId":' + groupId + '}',
michael@0 99 "tabview-group":
michael@0 100 '{"' + groupId + '":{"bounds":{"left":202,"top":30,"width":455,"height":249},' +
michael@0 101 '"userSize":null,"locked":{},"title":"","id":' + groupId +'}}',
michael@0 102 "tabview-ui": '{"pageBounds":{"left":0,"top":0,"width":788,"height":548}}'
michael@0 103 }, sizemode:"normal"
michael@0 104 }]
michael@0 105 };
michael@0 106 let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
michael@0 107 ss.setWindowState(win, JSON.stringify(newState), true);
michael@0 108 }
michael@0 109

mercurial