1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug587231.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,96 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +let activeTab; 1.8 +let testTab; 1.9 +let testGroup; 1.10 +let contentWindow; 1.11 + 1.12 +function test() { 1.13 + waitForExplicitFinish(); 1.14 + 1.15 + // create new tab 1.16 + testTab = gBrowser.addTab("about:blank"); 1.17 + 1.18 + window.addEventListener("tabviewshown", onTabViewWindowLoaded, false); 1.19 + TabView.toggle(); 1.20 +} 1.21 + 1.22 +function onTabViewWindowLoaded() { 1.23 + window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false); 1.24 + ok(TabView.isVisible(), "Tab View is visible"); 1.25 + 1.26 + contentWindow = document.getElementById("tab-view").contentWindow; 1.27 + 1.28 + // create group 1.29 + let testGroupRect = new contentWindow.Rect(20, 20, 300, 300); 1.30 + testGroup = new contentWindow.GroupItem([], { bounds: testGroupRect }); 1.31 + ok(testGroup.isEmpty(), "This group is empty"); 1.32 + 1.33 + ok(testTab._tabViewTabItem, "tab item exists"); 1.34 + 1.35 + // place tab in group 1.36 + let testTabItem = testTab._tabViewTabItem; 1.37 + 1.38 + if (testTabItem.parent) 1.39 + testTabItem.parent.remove(testTabItem); 1.40 + testGroup.add(testTabItem); 1.41 + 1.42 + ok(testTab._tabViewTabItem, "tab item exists after adding to group"); 1.43 + 1.44 + // record last update time of tab canvas 1.45 + let initialUpdateTime = testTabItem._lastTabUpdateTime; 1.46 + 1.47 + // simulate resize 1.48 + let resizer = contentWindow.iQ('.iq-resizable-handle', testGroup.container)[0]; 1.49 + let offsetX = 100; 1.50 + let offsetY = 100; 1.51 + let delay = 500; 1.52 + 1.53 + let funcChain = new Array(); 1.54 + funcChain.push(function() { 1.55 + EventUtils.synthesizeMouse( 1.56 + resizer, 1, 1, { type: "mousedown" }, contentWindow); 1.57 + setTimeout(funcChain.shift(), delay); 1.58 + }); 1.59 + // drag 1.60 + for (let i = 4; i >= 0; i--) { 1.61 + funcChain.push(function() { 1.62 + EventUtils.synthesizeMouse( 1.63 + resizer, Math.round(offsetX/4), Math.round(offsetY/4), 1.64 + { type: "mousemove" }, contentWindow); 1.65 + setTimeout(funcChain.shift(), delay); 1.66 + }); 1.67 + } 1.68 + funcChain.push(function() { 1.69 + EventUtils.synthesizeMouse(resizer, 0, 0, { type: "mouseup" }, 1.70 + contentWindow); 1.71 + setTimeout(funcChain.shift(), delay); 1.72 + }); 1.73 + funcChain.push(function() { 1.74 + // verify that update time has changed after last update 1.75 + let lastTime = testTabItem._lastTabUpdateTime; 1.76 + let hbTiming = contentWindow.TabItems._heartbeatTiming; 1.77 + ok((lastTime - initialUpdateTime) > hbTiming, "Tab has been updated:"+lastTime+"-"+initialUpdateTime+">"+hbTiming); 1.78 + 1.79 + // clean up 1.80 + testGroup.remove(testTab._tabViewTabItem); 1.81 + testTab._tabViewTabItem.close(); 1.82 + testGroup.close(); 1.83 + 1.84 + let currentTabs = contentWindow.TabItems.getItems(); 1.85 + ok(currentTabs[0], "A tab item exists to make active"); 1.86 + contentWindow.UI.setActive(currentTabs[0]); 1.87 + 1.88 + window.addEventListener("tabviewhidden", finishTest, false); 1.89 + TabView.toggle(); 1.90 + }); 1.91 + setTimeout(funcChain.shift(), delay); 1.92 +} 1.93 + 1.94 +function finishTest() { 1.95 + window.removeEventListener("tabviewhidden", finishTest, false); 1.96 + ok(!TabView.isVisible(), "Tab View is not visible"); 1.97 + 1.98 + finish(); 1.99 +}