Bug 1199800 - [webext] Add browser_tabs_query.js test (r=gabor)
authorBill McCloskey <billm@mozilla.com>
Thu, 27 Aug 2015 17:47:05 -0700
changeset 260929 c67b71d50d325e7362cce2df7b33a73bc9fa00bc
parent 260928 f17813c7200a771ef1e6736de53c2d5dd8b1e3db
child 260930 64f12a2877b5a3ccc1f8e616206b35a0e86670f6
push id64624
push userwmccloskey@mozilla.com
push dateFri, 04 Sep 2015 16:45:15 +0000
treeherdermozilla-inbound@3be72de9ac6a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs1199800
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1199800 - [webext] Add browser_tabs_query.js test (r=gabor)
browser/components/extensions/test/browser/browser.ini
browser/components/extensions/test/browser/browser_ext_tabs_query.js
--- a/browser/components/extensions/test/browser/browser.ini
+++ b/browser/components/extensions/test/browser/browser.ini
@@ -1,1 +1,2 @@
 [browser_extensions_simple.js]
+[browser_ext_tabs_query.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_query.js
@@ -0,0 +1,48 @@
+add_task(function* () {
+  let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:robots");
+  let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:config");
+
+  gBrowser.selectedTab = tab1;
+
+  let extension = ExtensionTestUtils.loadExtension({
+    manifest: {
+      "permissions": ["tabs"]
+    },
+
+    background: function() {
+      browser.tabs.query({
+        lastFocusedWindow: true
+      }, function(tabs) {
+        browser.test.assertEq(tabs.length, 3, "should have three tabs");
+
+        tabs.sort(function (tab1, tab2) { return tab1.index - tab2.index; });
+
+        browser.test.assertEq(tabs[0].url, "about:blank", "first tab blank");
+        tabs.shift();
+
+        browser.test.assertTrue(tabs[0].active, "tab 0 active");
+        browser.test.assertFalse(tabs[1].active, "tab 1 inactive");
+
+        browser.test.assertFalse(tabs[0].pinned, "tab 0 unpinned");
+        browser.test.assertFalse(tabs[1].pinned, "tab 1 unpinned");
+
+        browser.test.assertEq(tabs[0].url, "about:robots", "tab 0 url correct");
+        browser.test.assertEq(tabs[1].url, "about:config", "tab 1 url correct");
+
+        browser.test.assertEq(tabs[0].status, "complete", "tab 0 status correct");
+        browser.test.assertEq(tabs[1].status, "complete", "tab 1 status correct");
+
+        browser.test.assertEq(tabs[0].title, "Gort! Klaatu barada nikto!", "tab 0 title correct");
+
+        browser.test.notifyPass("tabs.query");
+      });
+    },
+  });
+
+  yield extension.startup();
+  yield extension.awaitFinish("tabs.query");
+  yield extension.unload();
+
+  yield BrowserTestUtils.removeTab(tab1);
+  yield BrowserTestUtils.removeTab(tab2);
+});