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 | let activeTab; |
michael@0 | 5 | let testTab; |
michael@0 | 6 | let testGroup; |
michael@0 | 7 | let contentWindow; |
michael@0 | 8 | |
michael@0 | 9 | function test() { |
michael@0 | 10 | waitForExplicitFinish(); |
michael@0 | 11 | |
michael@0 | 12 | // create new tab |
michael@0 | 13 | testTab = gBrowser.addTab("about:blank"); |
michael@0 | 14 | |
michael@0 | 15 | window.addEventListener("tabviewshown", onTabViewWindowLoaded, false); |
michael@0 | 16 | TabView.toggle(); |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | function onTabViewWindowLoaded() { |
michael@0 | 20 | window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false); |
michael@0 | 21 | ok(TabView.isVisible(), "Tab View is visible"); |
michael@0 | 22 | |
michael@0 | 23 | contentWindow = document.getElementById("tab-view").contentWindow; |
michael@0 | 24 | |
michael@0 | 25 | // create group |
michael@0 | 26 | let testGroupRect = new contentWindow.Rect(20, 20, 300, 300); |
michael@0 | 27 | testGroup = new contentWindow.GroupItem([], { bounds: testGroupRect }); |
michael@0 | 28 | ok(testGroup.isEmpty(), "This group is empty"); |
michael@0 | 29 | |
michael@0 | 30 | ok(testTab._tabViewTabItem, "tab item exists"); |
michael@0 | 31 | |
michael@0 | 32 | // place tab in group |
michael@0 | 33 | let testTabItem = testTab._tabViewTabItem; |
michael@0 | 34 | |
michael@0 | 35 | if (testTabItem.parent) |
michael@0 | 36 | testTabItem.parent.remove(testTabItem); |
michael@0 | 37 | testGroup.add(testTabItem); |
michael@0 | 38 | |
michael@0 | 39 | ok(testTab._tabViewTabItem, "tab item exists after adding to group"); |
michael@0 | 40 | |
michael@0 | 41 | // record last update time of tab canvas |
michael@0 | 42 | let initialUpdateTime = testTabItem._lastTabUpdateTime; |
michael@0 | 43 | |
michael@0 | 44 | // simulate resize |
michael@0 | 45 | let resizer = contentWindow.iQ('.iq-resizable-handle', testGroup.container)[0]; |
michael@0 | 46 | let offsetX = 100; |
michael@0 | 47 | let offsetY = 100; |
michael@0 | 48 | let delay = 500; |
michael@0 | 49 | |
michael@0 | 50 | let funcChain = new Array(); |
michael@0 | 51 | funcChain.push(function() { |
michael@0 | 52 | EventUtils.synthesizeMouse( |
michael@0 | 53 | resizer, 1, 1, { type: "mousedown" }, contentWindow); |
michael@0 | 54 | setTimeout(funcChain.shift(), delay); |
michael@0 | 55 | }); |
michael@0 | 56 | // drag |
michael@0 | 57 | for (let i = 4; i >= 0; i--) { |
michael@0 | 58 | funcChain.push(function() { |
michael@0 | 59 | EventUtils.synthesizeMouse( |
michael@0 | 60 | resizer, Math.round(offsetX/4), Math.round(offsetY/4), |
michael@0 | 61 | { type: "mousemove" }, contentWindow); |
michael@0 | 62 | setTimeout(funcChain.shift(), delay); |
michael@0 | 63 | }); |
michael@0 | 64 | } |
michael@0 | 65 | funcChain.push(function() { |
michael@0 | 66 | EventUtils.synthesizeMouse(resizer, 0, 0, { type: "mouseup" }, |
michael@0 | 67 | contentWindow); |
michael@0 | 68 | setTimeout(funcChain.shift(), delay); |
michael@0 | 69 | }); |
michael@0 | 70 | funcChain.push(function() { |
michael@0 | 71 | // verify that update time has changed after last update |
michael@0 | 72 | let lastTime = testTabItem._lastTabUpdateTime; |
michael@0 | 73 | let hbTiming = contentWindow.TabItems._heartbeatTiming; |
michael@0 | 74 | ok((lastTime - initialUpdateTime) > hbTiming, "Tab has been updated:"+lastTime+"-"+initialUpdateTime+">"+hbTiming); |
michael@0 | 75 | |
michael@0 | 76 | // clean up |
michael@0 | 77 | testGroup.remove(testTab._tabViewTabItem); |
michael@0 | 78 | testTab._tabViewTabItem.close(); |
michael@0 | 79 | testGroup.close(); |
michael@0 | 80 | |
michael@0 | 81 | let currentTabs = contentWindow.TabItems.getItems(); |
michael@0 | 82 | ok(currentTabs[0], "A tab item exists to make active"); |
michael@0 | 83 | contentWindow.UI.setActive(currentTabs[0]); |
michael@0 | 84 | |
michael@0 | 85 | window.addEventListener("tabviewhidden", finishTest, false); |
michael@0 | 86 | TabView.toggle(); |
michael@0 | 87 | }); |
michael@0 | 88 | setTimeout(funcChain.shift(), delay); |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | function finishTest() { |
michael@0 | 92 | window.removeEventListener("tabviewhidden", finishTest, false); |
michael@0 | 93 | ok(!TabView.isVisible(), "Tab View is not visible"); |
michael@0 | 94 | |
michael@0 | 95 | finish(); |
michael@0 | 96 | } |