diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /browser/base/content/test/general/browser_tabReorder.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/base/content/test/general/browser_tabReorder.js')
-rw-r--r-- | browser/base/content/test/general/browser_tabReorder.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/browser/base/content/test/general/browser_tabReorder.js b/browser/base/content/test/general/browser_tabReorder.js new file mode 100644 index 000000000..9e0503e95 --- /dev/null +++ b/browser/base/content/test/general/browser_tabReorder.js @@ -0,0 +1,49 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +function test() { + let initialTabsLength = gBrowser.tabs.length; + + let newTab1 = gBrowser.selectedTab = gBrowser.addTab("about:robots", {skipAnimation: true}); + let newTab2 = gBrowser.selectedTab = gBrowser.addTab("about:about", {skipAnimation: true}); + let newTab3 = gBrowser.selectedTab = gBrowser.addTab("about:config", {skipAnimation: true}); + registerCleanupFunction(function () { + while (gBrowser.tabs.length > initialTabsLength) { + gBrowser.removeTab(gBrowser.tabs[initialTabsLength]); + } + }); + + is(gBrowser.tabs.length, initialTabsLength + 3, "new tabs are opened"); + is(gBrowser.tabs[initialTabsLength], newTab1, "newTab1 position is correct"); + is(gBrowser.tabs[initialTabsLength + 1], newTab2, "newTab2 position is correct"); + is(gBrowser.tabs[initialTabsLength + 2], newTab3, "newTab3 position is correct"); + + let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. + getService(Ci.mozIJSSubScriptLoader); + let EventUtils = {}; + scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils); + + function dragAndDrop(tab1, tab2, copy) { + let rect = tab2.getBoundingClientRect(); + let event = { + ctrlKey: copy, + altKey: copy, + clientX: rect.left + rect.width / 2 + 10, + clientY: rect.top + rect.height / 2, + }; + + EventUtils.synthesizeDrop(tab1, tab2, null, copy ? "copy" : "move", window, window, event); + } + + dragAndDrop(newTab1, newTab2, false); + is(gBrowser.tabs.length, initialTabsLength + 3, "tabs are still there"); + is(gBrowser.tabs[initialTabsLength], newTab2, "newTab2 and newTab1 are swapped"); + is(gBrowser.tabs[initialTabsLength + 1], newTab1, "newTab1 and newTab2 are swapped"); + is(gBrowser.tabs[initialTabsLength + 2], newTab3, "newTab3 stays same place"); + + dragAndDrop(newTab2, newTab1, true); + is(gBrowser.tabs.length, initialTabsLength + 4, "a tab is duplicated"); + is(gBrowser.tabs[initialTabsLength], newTab2, "newTab2 stays same place"); + is(gBrowser.tabs[initialTabsLength + 1], newTab1, "newTab1 stays same place"); + is(gBrowser.tabs[initialTabsLength + 3], newTab3, "a new tab is inserted before newTab3"); +} |