Wed, 31 Dec 2014 06:09:35 +0100
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(onTabViewWindowLoaded); |
michael@0 | 8 | } |
michael@0 | 9 | |
michael@0 | 10 | function onTabViewWindowLoaded(win) { |
michael@0 | 11 | win.removeEventListener("tabviewshown", onTabViewWindowLoaded, false); |
michael@0 | 12 | |
michael@0 | 13 | ok(win.TabView.isVisible(), "Tab View is visible"); |
michael@0 | 14 | |
michael@0 | 15 | let contentWindow = win.document.getElementById("tab-view").contentWindow; |
michael@0 | 16 | let [originalTab] = win.gBrowser.visibleTabs; |
michael@0 | 17 | |
michael@0 | 18 | let currentGroup = contentWindow.GroupItems.getActiveGroupItem(); |
michael@0 | 19 | |
michael@0 | 20 | // Create a group and make it active |
michael@0 | 21 | let box = new contentWindow.Rect(100, 100, 370, 370); |
michael@0 | 22 | let group = new contentWindow.GroupItem([], { bounds: box }); |
michael@0 | 23 | ok(group.isEmpty(), "This group is empty"); |
michael@0 | 24 | contentWindow.UI.setActive(group); |
michael@0 | 25 | is(contentWindow.GroupItems.getActiveGroupItem(), group, "new group is active"); |
michael@0 | 26 | |
michael@0 | 27 | // Create a bunch of tabs in the group |
michael@0 | 28 | let bg = {inBackground: true}; |
michael@0 | 29 | let datatext = win.gBrowser.loadOneTab("data:text/plain,bug610242", bg); |
michael@0 | 30 | let datahtml = win.gBrowser.loadOneTab("data:text/html,<h1>hi!</h1>", bg); |
michael@0 | 31 | let mozilla = win.gBrowser.loadOneTab("about:mozilla", bg); |
michael@0 | 32 | let synclog = win.gBrowser.loadOneTab("about:sync-log", bg); |
michael@0 | 33 | let html = win.gBrowser.loadOneTab("http://example.com", bg); |
michael@0 | 34 | let png = win.gBrowser.loadOneTab("http://mochi.test:8888/browser/browser/base/content/test/general/moz.png", bg); |
michael@0 | 35 | let svg = win.gBrowser.loadOneTab("http://mochi.test:8888/browser/browser/base/content/test/general/title_test.svg", bg); |
michael@0 | 36 | |
michael@0 | 37 | ok(!group.shouldStack(group._children.length), "Group should not stack."); |
michael@0 | 38 | |
michael@0 | 39 | // PREPARE FINISH: |
michael@0 | 40 | group.addSubscriber("close", function onClose() { |
michael@0 | 41 | group.removeSubscriber("close", onClose); |
michael@0 | 42 | |
michael@0 | 43 | ok(group.isEmpty(), "The group is empty again"); |
michael@0 | 44 | |
michael@0 | 45 | contentWindow.UI.setActive(currentGroup); |
michael@0 | 46 | isnot(contentWindow.GroupItems.getActiveGroupItem(), null, "There is an active group"); |
michael@0 | 47 | is(win.gBrowser.tabs.length, 1, "There is only one tab left"); |
michael@0 | 48 | is(win.gBrowser.visibleTabs.length, 1, "There is also only one visible tab"); |
michael@0 | 49 | |
michael@0 | 50 | whenTabViewIsHidden(function() { |
michael@0 | 51 | win.close(); |
michael@0 | 52 | ok(win.closed, "new window is closed"); |
michael@0 | 53 | finish(); |
michael@0 | 54 | }, win); |
michael@0 | 55 | win.gBrowser.selectedTab = originalTab; |
michael@0 | 56 | |
michael@0 | 57 | win.TabView.hide(); |
michael@0 | 58 | }); |
michael@0 | 59 | |
michael@0 | 60 | function check(tab, label, visible) { |
michael@0 | 61 | let display = contentWindow.getComputedStyle(tab._tabViewTabItem.$fav[0], null).getPropertyValue("display"); |
michael@0 | 62 | if (visible) { |
michael@0 | 63 | is(display, "block", label + " has favicon"); |
michael@0 | 64 | } else { |
michael@0 | 65 | is(display, "none", label + " has no favicon"); |
michael@0 | 66 | } |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | afterAllTabsLoaded(function() { |
michael@0 | 70 | let children = group.getChildren(); |
michael@0 | 71 | let len = children.length; |
michael@0 | 72 | let iconUpdateCounter = 0; |
michael@0 | 73 | |
michael@0 | 74 | children.forEach(function(tabItem) { |
michael@0 | 75 | tabItem.addSubscriber("iconUpdated", function onIconUpdated() { |
michael@0 | 76 | tabItem.removeSubscriber("iconUpdated", onIconUpdated); |
michael@0 | 77 | |
michael@0 | 78 | if (++iconUpdateCounter == len) { |
michael@0 | 79 | check(datatext, "datatext", false); |
michael@0 | 80 | check(datahtml, "datahtml", false); |
michael@0 | 81 | check(mozilla, "about:mozilla", false); |
michael@0 | 82 | check(synclog, "about:sync-log", true); |
michael@0 | 83 | check(html, "html", true); |
michael@0 | 84 | check(png, "png", false); |
michael@0 | 85 | check(svg, "svg", true); |
michael@0 | 86 | |
michael@0 | 87 | // Get rid of the group and its children |
michael@0 | 88 | // The group close will trigger a finish(). |
michael@0 | 89 | closeGroupItem(group); |
michael@0 | 90 | } |
michael@0 | 91 | }); |
michael@0 | 92 | }); |
michael@0 | 93 | |
michael@0 | 94 | afterAllTabItemsUpdated(function () {}, win); |
michael@0 | 95 | }, win); |
michael@0 | 96 | } |