browser/components/tabview/test/browser_tabview_bug597980.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 function test() {
michael@0 5 waitForExplicitFinish();
michael@0 6
michael@0 7 newWindowWithTabView(part1);
michael@0 8 }
michael@0 9
michael@0 10 function part1(win) {
michael@0 11 registerCleanupFunction(function() win.close());
michael@0 12
michael@0 13 let contentWindow = win.TabView.getContentWindow();
michael@0 14 is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group");
michael@0 15
michael@0 16 let originalTab = win.gBrowser.selectedTab;
michael@0 17 let originalGroup = contentWindow.GroupItems.groupItems[0];
michael@0 18 let newTab = win.gBrowser.loadOneTab("about:blank", {inBackground: true});
michael@0 19
michael@0 20 is(originalGroup.getChildren().length, 2, "The original group now has two tabs");
michael@0 21
michael@0 22 // create group two with the new tab
michael@0 23 let box = new contentWindow.Rect(300,300,150,150);
michael@0 24 let newGroup = new contentWindow.GroupItem([], {bounds: box, immediately: true});
michael@0 25 newGroup.add(newTab._tabViewTabItem, {immediately: true});
michael@0 26
michael@0 27 // ensure active group item and tab
michael@0 28 contentWindow.UI.setActive(originalGroup);
michael@0 29 is(contentWindow.GroupItems.getActiveGroupItem(), originalGroup,
michael@0 30 "The original group is active");
michael@0 31 is(contentWindow.UI.getActiveTab(), originalTab._tabViewTabItem,
michael@0 32 "The original tab is active");
michael@0 33
michael@0 34 function checkActive(callback, time) {
michael@0 35 is(contentWindow.GroupItems.getActiveGroupItem(), newGroup,
michael@0 36 "The new group is active");
michael@0 37 is(contentWindow.UI.getActiveTab(), newTab._tabViewTabItem,
michael@0 38 "The new tab is active");
michael@0 39 if (time)
michael@0 40 setTimeout(callback, time);
michael@0 41 else
michael@0 42 callback();
michael@0 43 }
michael@0 44
michael@0 45 // click on the new tab, and check that the new tab and group are active
michael@0 46 // at two times: 10 ms after (still during the animation) and
michael@0 47 // 500 ms after (after the animation, hopefully). Either way, the new
michael@0 48 // tab and group should be active.
michael@0 49 EventUtils.sendMouseEvent({ type: "mousedown" },
michael@0 50 newTab._tabViewTabItem.container, contentWindow);
michael@0 51 EventUtils.sendMouseEvent({ type: "mouseup" },
michael@0 52 newTab._tabViewTabItem.container, contentWindow);
michael@0 53 setTimeout(function() {
michael@0 54 checkActive(function() {
michael@0 55 checkActive(function() {
michael@0 56 win.close();
michael@0 57 newWindowWithTabView(part2);
michael@0 58 });
michael@0 59 }, 490);
michael@0 60 }, 10)
michael@0 61 }
michael@0 62
michael@0 63 function part2(win) {
michael@0 64 registerCleanupFunction(function() win.close());
michael@0 65
michael@0 66 let newTab = win.gBrowser.loadOneTab("about:blank", {inBackground: true});
michael@0 67 hideTabView(function() {
michael@0 68 let selectedTab = win.gBrowser.selectedTab;
michael@0 69 isnot(selectedTab, newTab, "They are different tabs");
michael@0 70
michael@0 71 // switch the selected tab to new tab
michael@0 72 win.gBrowser.selectedTab = newTab;
michael@0 73
michael@0 74 showTabView(function () {
michael@0 75 hideTabView(function () {
michael@0 76 is(win.gBrowser.selectedTab, newTab,
michael@0 77 "The selected tab should be the same as before (new tab)");
michael@0 78 waitForFocus(finish);
michael@0 79 }, win);
michael@0 80 }, win);
michael@0 81 }, win);
michael@0 82 }

mercurial