michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: let activeTab; michael@0: let testTab; michael@0: let testGroup; michael@0: let contentWindow; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: // create new tab michael@0: testTab = gBrowser.addTab("about:blank"); michael@0: michael@0: window.addEventListener("tabviewshown", onTabViewWindowLoaded, false); michael@0: TabView.toggle(); michael@0: } michael@0: michael@0: function onTabViewWindowLoaded() { michael@0: window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false); michael@0: ok(TabView.isVisible(), "Tab View is visible"); michael@0: michael@0: contentWindow = document.getElementById("tab-view").contentWindow; michael@0: michael@0: // create group michael@0: let testGroupRect = new contentWindow.Rect(20, 20, 300, 300); michael@0: testGroup = new contentWindow.GroupItem([], { bounds: testGroupRect }); michael@0: ok(testGroup.isEmpty(), "This group is empty"); michael@0: michael@0: ok(testTab._tabViewTabItem, "tab item exists"); michael@0: michael@0: // place tab in group michael@0: let testTabItem = testTab._tabViewTabItem; michael@0: michael@0: if (testTabItem.parent) michael@0: testTabItem.parent.remove(testTabItem); michael@0: testGroup.add(testTabItem); michael@0: michael@0: ok(testTab._tabViewTabItem, "tab item exists after adding to group"); michael@0: michael@0: // record last update time of tab canvas michael@0: let initialUpdateTime = testTabItem._lastTabUpdateTime; michael@0: michael@0: // simulate resize michael@0: let resizer = contentWindow.iQ('.iq-resizable-handle', testGroup.container)[0]; michael@0: let offsetX = 100; michael@0: let offsetY = 100; michael@0: let delay = 500; michael@0: michael@0: let funcChain = new Array(); michael@0: funcChain.push(function() { michael@0: EventUtils.synthesizeMouse( michael@0: resizer, 1, 1, { type: "mousedown" }, contentWindow); michael@0: setTimeout(funcChain.shift(), delay); michael@0: }); michael@0: // drag michael@0: for (let i = 4; i >= 0; i--) { michael@0: funcChain.push(function() { michael@0: EventUtils.synthesizeMouse( michael@0: resizer, Math.round(offsetX/4), Math.round(offsetY/4), michael@0: { type: "mousemove" }, contentWindow); michael@0: setTimeout(funcChain.shift(), delay); michael@0: }); michael@0: } michael@0: funcChain.push(function() { michael@0: EventUtils.synthesizeMouse(resizer, 0, 0, { type: "mouseup" }, michael@0: contentWindow); michael@0: setTimeout(funcChain.shift(), delay); michael@0: }); michael@0: funcChain.push(function() { michael@0: // verify that update time has changed after last update michael@0: let lastTime = testTabItem._lastTabUpdateTime; michael@0: let hbTiming = contentWindow.TabItems._heartbeatTiming; michael@0: ok((lastTime - initialUpdateTime) > hbTiming, "Tab has been updated:"+lastTime+"-"+initialUpdateTime+">"+hbTiming); michael@0: michael@0: // clean up michael@0: testGroup.remove(testTab._tabViewTabItem); michael@0: testTab._tabViewTabItem.close(); michael@0: testGroup.close(); michael@0: michael@0: let currentTabs = contentWindow.TabItems.getItems(); michael@0: ok(currentTabs[0], "A tab item exists to make active"); michael@0: contentWindow.UI.setActive(currentTabs[0]); michael@0: michael@0: window.addEventListener("tabviewhidden", finishTest, false); michael@0: TabView.toggle(); michael@0: }); michael@0: setTimeout(funcChain.shift(), delay); michael@0: } michael@0: michael@0: function finishTest() { michael@0: window.removeEventListener("tabviewhidden", finishTest, false); michael@0: ok(!TabView.isVisible(), "Tab View is not visible"); michael@0: michael@0: finish(); michael@0: }