Bug 1140221 - Attempt to fix intermittent test-tabs.js.testIgnoreClosing by waiting for focus directly. r=erikvold, a=test-only
authorDave Townsend <dtownsend@oxymoronical.com>
Mon, 20 Apr 2015 08:53:00 -0700
changeset 265683 0b450b40bed31d774317f40914c5f4cdfcc115ab
parent 265682 4ffd34ccca5d9c49d0f4d710cdba811dd81147ca
child 265684 95e4109eeb365e3f440ba4660c248abee000aa62
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserikvold, test-only
bugs1140221
milestone39.0a2
Bug 1140221 - Attempt to fix intermittent test-tabs.js.testIgnoreClosing by waiting for focus directly. r=erikvold, a=test-only
addon-sdk/source/test/tabs/test-firefox-tabs.js
--- a/addon-sdk/source/test/tabs/test-firefox-tabs.js
+++ b/addon-sdk/source/test/tabs/test-firefox-tabs.js
@@ -366,39 +366,40 @@ exports.testTabMove = function(assert, d
         assert.equal(tab.index, 0, "tab index after move matches");
         close(window).then(done).then(null, assert.fail);
       }
     });
   }).then(null, assert.fail);
 };
 
 exports.testIgnoreClosing = function(assert, done) {
-  let originalWindow = browserWindows.activeWindow;
+  let originalWindow = viewFor(browserWindows.activeWindow);
   openBrowserWindow(function(window, browser) {
-    let url = "data:text/html;charset=utf-8,foobar";
+    onFocus(window).then(() => {
+      let url = "data:text/html;charset=utf-8,foobar";
 
-    assert.equal(tabs.length, 2, "should be two windows open each with one tab");
+      assert.equal(tabs.length, 2, "should be two windows open each with one tab");
 
-    tabs.on('ready', function onReady(tab) {
-      tabs.removeListener('ready', onReady);
+      tabs.on('ready', function onReady(tab) {
+        tabs.removeListener('ready', onReady);
 
-      let win = tab.window;
-      assert.equal(win.tabs.length, 2, "should be two tabs in the new window");
-      assert.equal(tabs.length, 3, "should be three tabs in total");
+        let win = tab.window;
+        assert.equal(win.tabs.length, 2, "should be two tabs in the new window");
+        assert.equal(tabs.length, 3, "should be three tabs in total");
 
-      tab.close(function() {
-        assert.equal(win.tabs.length, 1, "should be one tab in the new window");
-        assert.equal(tabs.length, 2, "should be two tabs in total");
+        tab.close(function() {
+          assert.equal(win.tabs.length, 1, "should be one tab in the new window");
+          assert.equal(tabs.length, 2, "should be two tabs in total");
 
-        originalWindow.once("activate", done);
-        close(window);
+          close(window).then(onFocus(originalWindow)).then(done).then(null, assert.fail);
+        });
       });
+
+      tabs.open(url);
     });
-
-    tabs.open(url);
   });
 };
 
 // TEST: open tab with default options
 exports.testOpen = function(assert, done) {
   let url = "data:text/html;charset=utf-8,default";
   tabs.open({
     url: url,