Bug 1000894 - Fix browser-chrome tests in dom/tests/browser/ to not replace the original tab. r=ehsan, a=test-only
authorNathan Froyd <froydnj@mozilla.com>
Thu, 24 Apr 2014 21:02:59 -0400
changeset 192115 45fd8b9ec808a23077b18686a4cbe0078ffc6025
parent 192114 f19024e5e5d53ea3dc1bdee2eccaf1fd9f6992ba
child 192116 f238addfdac3ffdebd518a6d186734352572b1ce
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, test-only
bugs1000894
milestone30.0a2
Bug 1000894 - Fix browser-chrome tests in dom/tests/browser/ to not replace the original tab. r=ehsan, a=test-only
dom/tests/browser/browser_focus_steal_from_chrome.js
dom/tests/browser/browser_focus_steal_from_chrome_during_mousedown.js
--- a/dom/tests/browser/browser_focus_steal_from_chrome.js
+++ b/dom/tests/browser/browser_focus_steal_from_chrome.js
@@ -3,17 +3,18 @@ function test() {
 
   let secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
                          .getService(Components.interfaces
                                                .nsIScriptSecurityManager);
 
   let fm = Components.classes["@mozilla.org/focus-manager;1"]
                      .getService(Components.interfaces.nsIFocusManager);
 
-  let tabs = [ gBrowser.selectedTab, gBrowser.addTab() ];
+  let tabs = [ gBrowser.addTab(), gBrowser.addTab() ];
+  gBrowser.selectedTab = tabs[0];
 
   let testingList = [
     { uri: "data:text/html,<body onload=\"setTimeout(function () { document.getElementById('target').focus(); }, 10);\"><input id='target'></body>",
       tagName: "INPUT", methodName: "focus" },
     { uri: "data:text/html,<body onload=\"setTimeout(function () { document.getElementById('target').select(); }, 10);\"><input id='target'></body>",
       tagName: "INPUT", methodName: "select" },
     { uri: "data:text/html,<body onload=\"setTimeout(function () { document.getElementById('target').focus(); }, 10);\"><a href='about:blank' id='target'>anchor</a></body>",
       tagName: "A", methodName: "focus" },
@@ -56,17 +57,16 @@ function test() {
   let canRetry;
   let callback;
   let loadedCount;
   let setFocusToChrome;
 
   function runNextTest() {
     if (++testingIndex >= testingList.length) {
       // cleaning-up...
-      gBrowser.addTab();
       for (let i = 0; i < tabs.length; i++) {
         gBrowser.removeTab(tabs[i]);
       }
       finish();
       return;
     }
     callback = doTest1;
     loadTestPage(false);
--- a/dom/tests/browser/browser_focus_steal_from_chrome_during_mousedown.js
+++ b/dom/tests/browser/browser_focus_steal_from_chrome_during_mousedown.js
@@ -8,17 +8,18 @@ function test() {
     "    document.getElementById('willBeFocused').focus();" +
     "    aEvent.preventDefault();" +
     "  }" +
     "</script>" +
     "<body id=\"body\">" +
     "<button id=\"eventTarget\" onmousedown=\"onMouseDown(event);\">click here</button>" +
     "<input id=\"willBeFocused\"></body>";
 
-  let tab = gBrowser.selectedTab;
+  let tab = gBrowser.addTab();
+  gBrowser.selectedTab = tab;
 
   // Set the focus to the contents.
   tab.linkedBrowser.focus();
   // Load on the tab
   tab.linkedBrowser.addEventListener("load", onLoadTab, true);
   tab.linkedBrowser.loadURI(kTestURI);
 
   function onLoadTab() {
@@ -47,13 +48,12 @@ function test() {
       is(e.id, "willBeFocused",
          "The input element isn't active element: button=" + button);
 
       is(fm.focusedElement, e,
          "The active element isn't focused element in App level: button=" +
          button);
     }
 
-    gBrowser.addTab();
     gBrowser.removeTab(tab);
     finish();
   }
 }