Bug 1368285 - Make test_nuke_webextension_wrappers.js correctly wait for the window to be destroyed instead of relying on the scheduling of the corresponding event; r=kmag
authorEhsan Akhgari <ehsan@mozilla.com>
Sat, 27 May 2017 19:12:42 -0400
changeset 409674 4747ae7509f187cfea6b3b8d05c85cc566b4151b
parent 409673 dd37a9cce28d8ce293cddc6e499c19d0397aac0d
child 409675 3eccf32d5a838447166427f391b0d5a929161a3c
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1368285
milestone55.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 1368285 - Make test_nuke_webextension_wrappers.js correctly wait for the window to be destroyed instead of relying on the scheduling of the corresponding event; r=kmag
js/xpconnect/tests/unit/test_nuke_webextension_wrappers.js
--- a/js/xpconnect/tests/unit/test_nuke_webextension_wrappers.js
+++ b/js/xpconnect/tests/unit/test_nuke_webextension_wrappers.js
@@ -1,21 +1,16 @@
 // See https://bugzilla.mozilla.org/show_bug.cgi?id=1273251
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/NetUtil.jsm");
 Cu.import("resource://gre/modules/Timer.jsm");
-
-function promiseEvent(target, event) {
-  return new Promise(resolve => {
-    target.addEventListener(event, resolve, {capture: true, once: true});
-  });
-}
+Cu.import("resource://testing-common/TestUtils.jsm");
 
 let aps = Cc["@mozilla.org/addons/policy-service;1"].getService(Ci.nsIAddonPolicyService).wrappedJSObject;
 
 let oldAddonIdCallback = aps.setExtensionURIToAddonIdCallback(uri => uri.host);
 do_register_cleanup(() => {
   aps.setExtensionURIToAddonIdCallback(oldAddonIdCallback);
 });
 
@@ -58,18 +53,18 @@ add_task(function*() {
     }
   }));
 
   // Check that the object can be accessed normally before windowB is closed.
   equal(getThing(), "bar");
 
   webnavB.close();
 
-  // Wrappers are nuked asynchronously, so wait a tick.
-  yield new Promise(resolve => setTimeout(resolve, 0));
+  // Wrappers are destroyed asynchronously, so wait for that to happen.
+  yield TestUtils.topicObserved("inner-window-destroyed");
 
   // Check that it can't be accessed after he window has been closed.
   let result = getThing();
   ok(/dead object/.test(result),
      `Result should show a dead wrapper error: ${result}`);
 
   webnavA.close();
 });