bug 1334691 consolidate a couple of tests down r=bsilverberg
authorAndy McKay <amckay@mozilla.com>
Fri, 02 Jun 2017 15:34:46 -0700
changeset 600585 ce85883942f72709b6760fe842869049741fbecf
parent 600584 64412d8b6f4b4b64ace0c914fe897b4bc02cefbd
child 600586 5ce62f7e6633a7ac2fbff0c103d3b58b5ccb5b27
push id65795
push usergijskruitbosch@gmail.com
push dateTue, 27 Jun 2017 11:49:10 +0000
reviewersbsilverberg
bugs1334691
milestone56.0a1
bug 1334691 consolidate a couple of tests down r=bsilverberg MozReview-Commit-ID: KrlCtNdlKja
browser/components/extensions/test/browser/browser-common.ini
browser/components/extensions/test/browser/browser_ext_tabs_move.js
browser/components/extensions/test/browser/browser_ext_tabs_move_array.js
--- a/browser/components/extensions/test/browser/browser-common.ini
+++ b/browser/components/extensions/test/browser/browser-common.ini
@@ -119,17 +119,16 @@ skip-if = debug || asan # Bug 1354681
 [browser_ext_tabs_executeScript_good.js]
 [browser_ext_tabs_executeScript_bad.js]
 [browser_ext_tabs_executeScript_multiple.js]
 [browser_ext_tabs_executeScript_no_create.js]
 [browser_ext_tabs_executeScript_runAt.js]
 [browser_ext_tabs_getCurrent.js]
 [browser_ext_tabs_insertCSS.js]
 [browser_ext_tabs_removeCSS.js]
-[browser_ext_tabs_move.js]
 [browser_ext_tabs_move_array.js]
 [browser_ext_tabs_move_window.js]
 [browser_ext_tabs_move_window_multiple.js]
 [browser_ext_tabs_move_window_pinned.js]
 [browser_ext_tabs_onHighlighted.js]
 [browser_ext_tabs_onUpdated.js]
 [browser_ext_tabs_query.js]
 [browser_ext_tabs_reload.js]
deleted file mode 100644
--- a/browser/components/extensions/test/browser/browser_ext_tabs_move.js
+++ /dev/null
@@ -1,103 +0,0 @@
-/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set sts=2 sw=2 et tw=80: */
-"use strict";
-
-add_task(async function() {
-  let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:robots");
-  let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:config");
-
-  gBrowser.selectedTab = tab1;
-
-  let extension = ExtensionTestUtils.loadExtension({
-    manifest: {
-      "permissions": ["tabs"],
-    },
-
-    background: async function() {
-      let [tab] = await browser.tabs.query({lastFocusedWindow: true});
-
-      browser.tabs.move(tab.id, {index: 0});
-      let tabs = await browser.tabs.query({lastFocusedWindow: true});
-
-      browser.test.assertEq(tabs[0].url, tab.url, "should be first tab");
-      browser.test.notifyPass("tabs.move.single");
-    },
-  });
-
-  await extension.startup();
-  await extension.awaitFinish("tabs.move.single");
-  await extension.unload();
-
-  extension = ExtensionTestUtils.loadExtension({
-    manifest: {
-      "permissions": ["tabs"],
-    },
-
-    background: async function() {
-      let tabs = await browser.tabs.query({lastFocusedWindow: true});
-
-      tabs.sort(function(a, b) { return a.url > b.url; });
-
-      browser.tabs.move(tabs.map(tab => tab.id), {index: 0});
-
-      tabs = await browser.tabs.query({lastFocusedWindow: true});
-
-      browser.test.assertEq(tabs[0].url, "about:blank", "should be first tab");
-      browser.test.assertEq(tabs[1].url, "about:config", "should be second tab");
-      browser.test.assertEq(tabs[2].url, "about:robots", "should be third tab");
-
-      browser.test.notifyPass("tabs.move.multiple");
-    },
-  });
-
-  await extension.startup();
-  await extension.awaitFinish("tabs.move.multiple");
-  await extension.unload();
-
-  extension = ExtensionTestUtils.loadExtension({
-    manifest: {
-      "permissions": ["tabs"],
-    },
-
-    async background() {
-      let [, tab] = await browser.tabs.query({lastFocusedWindow: true});
-
-      // Assuming that tab.id of 12345 does not exist.
-      await browser.test.assertRejects(
-        browser.tabs.move([tab.id, 12345], {index: 0}),
-        /Invalid tab/,
-        "Should receive invalid tab error");
-
-      let tabs = await browser.tabs.query({lastFocusedWindow: true});
-      browser.test.assertEq(tabs[1].url, tab.url, "should be second tab");
-      browser.test.notifyPass("tabs.move.invalid");
-    },
-  });
-
-  await extension.startup();
-  await extension.awaitFinish("tabs.move.invalid");
-  await extension.unload();
-
-  extension = ExtensionTestUtils.loadExtension({
-    manifest: {
-      "permissions": ["tabs"],
-    },
-
-    background: async function() {
-      let [tab] = await browser.tabs.query({lastFocusedWindow: true});
-      browser.tabs.move(tab.id, {index: -1});
-
-      let tabs = await browser.tabs.query({lastFocusedWindow: true});
-
-      browser.test.assertEq(tabs[2].url, tab.url, "should be last tab");
-      browser.test.notifyPass("tabs.move.last");
-    },
-  });
-
-  await extension.startup();
-  await extension.awaitFinish("tabs.move.last");
-  await extension.unload();
-
-  await BrowserTestUtils.removeTab(tab1);
-  await BrowserTestUtils.removeTab(tab2);
-});
--- a/browser/components/extensions/test/browser/browser_ext_tabs_move_array.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_move_array.js
@@ -36,33 +36,45 @@ add_task(async function moveMultiple() {
       async function move(moveIndexes, moveTo) {
         let tabs = await browser.tabs.query({url: "http://example.com/*"});
         await browser.tabs.move(
           moveIndexes.map(e => tabs[e - 1].id),
           {index: moveTo});
       }
 
       let tests = [
+        {"move": [2], "index": 0, "result": [2, 1, 3, 4]},
+        {"move": [2], "index": -1, "result": [1, 3, 4, 2]},
         // Start -> After first tab  -> After second tab
+        {"move": [4, 3], "index":  0, "result": [4, 3, 1, 2]},
         // [1, 2, 3, 4] -> [1, 4, 2, 3] -> [1, 4, 3, 2]
         {"move": [4, 3], "index":  1, "result": [1, 4, 3, 2]},
         // [1, 2, 3, 4] -> [2, 3, 1, 4] -> [3, 1, 2, 4]
         {"move": [1, 2], "index":  2, "result": [3, 1, 2, 4]},
         // [1, 2, 3, 4] -> [1, 2, 4, 3] -> [2, 4, 1, 3]
         {"move": [4, 1], "index":  2, "result": [2, 4, 1, 3]},
         // [1, 2, 3, 4] -> [2, 3, 1, 4] -> [2, 3, 1, 4]
         {"move": [1, 4], "index":  2, "result": [2, 3, 1, 4]},
       ];
 
       for (let test of tests) {
         await reset();
         await move(test.move, test.index);
         await check(test.result);
       }
 
+      let firstId = (await browser.tabs.query({url: "http://example.com/*"}))[0].id;
+      // Assuming that tab.id of 12345 does not exist.
+      await browser.test.assertRejects(
+        browser.tabs.move([firstId, 12345], {index: -1}),
+        /Invalid tab/,
+        "Should receive invalid tab error");
+      // The first argument got moved, the second on failed.
+      await check([2, 3, 1, 4]);
+
       browser.test.notifyPass("tabs.move");
     },
   });
 
   await extension.startup();
   await extension.awaitFinish("tabs.move");
   await extension.unload();