Bug 615194: add test to check isActive annotation is correct for tabs. r=bzbarsky, a=blocker
authorGavin Sharp <gavin@gavinsharp.com>
Tue, 30 Nov 2010 17:57:20 -0500
changeset 58401 ab7bccf8e4e412b9d534bd1dd43c7b46ce76ab22
parent 58400 6ec5b1133f6a8c45f0476c5ed2c7ae106577d7d7
child 58402 c334590653876d3b63c8a2b1a8cd196a937da08e
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersbzbarsky, blocker
bugs615194
milestone2.0b8pre
Bug 615194: add test to check isActive annotation is correct for tabs. r=bzbarsky, a=blocker
browser/base/content/test/Makefile.in
browser/base/content/test/browser_tabs_isActive.js
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -193,16 +193,17 @@ endif
                  browser_sanitize-sitepermissions.js \
                  browser_sanitize-timespans.js \
                  browser_sanitizeDialog.js \
                  browser_scope.js \
                  browser_selectTabAtIndex.js \
                  browser_tab_dragdrop2.js \
                  browser_tab_dragdrop2_frame1.xul \
                  browser_tabfocus.js \
+                 browser_tabs_isActive.js \
                  browser_tabs_owner.js \
                  browser_visibleFindSelection.js \
                  browser_visibleTabs.js \
                  browser_visibleTabs_contextMenu.js \
                  browser_visibleTabs_bookmarkAllPages.js \
                  browser_visibleTabs_bookmarkAllTabs.js \
                  browser_visibleTabs_tabPreview.js \
                  bug592338.html \
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/browser_tabs_isActive.js
@@ -0,0 +1,29 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function test() {
+  test_tab("about:blank");
+  test_tab("about:license");
+}
+
+function test_tab(url) {
+  let originalTab = gBrowser.selectedTab;
+  let newTab = gBrowser.addTab(url, {skipAnimation: true});
+  is(tabIsActive(newTab), false, "newly added " + url + " tab is not active");
+  is(tabIsActive(originalTab), true, "original tab is active initially");
+
+  gBrowser.selectedTab = newTab;
+  is(tabIsActive(newTab), true, "newly added " + url + " tab is active after selection");
+  is(tabIsActive(originalTab), false, "original tab is not active while unselected");
+
+  gBrowser.selectedTab = originalTab;
+  is(tabIsActive(newTab), false, "newly added " + url + " tab is not active after switch back");
+  is(tabIsActive(originalTab), true, "original tab is active again after switch back");
+  
+  gBrowser.removeTab(newTab);
+}
+
+function tabIsActive(tab) {
+  let browser = tab.linkedBrowser;
+  return browser.docShell.isActive;
+}