Bug 1370100 - Make browser_dead_object.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>
Mon, 29 May 2017 23:41:19 -0400
changeset 410416 b393ec48b4d01e83c5eae7234542d51fc169d7db
parent 410388 da5a14ae4ce3084aa63a502e96af1a4c6ef76853
child 410417 08ba2d5f6d3bdfc53d0681e1f990dfc456b04f30
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
bugs1370100
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 1370100 - Make browser_dead_object.js correctly wait for the window to be destroyed instead of relying on the scheduling of the corresponding event; r=kmag
js/xpconnect/tests/browser/browser_dead_object.js
--- a/js/xpconnect/tests/browser/browser_dead_object.js
+++ b/js/xpconnect/tests/browser/browser_dead_object.js
@@ -4,18 +4,23 @@
  */
 
 // For bug 773980, test that Components.utils.isDeadWrapper works as expected.
 
 add_task(function* test() {
   const url = "http://mochi.test:8888/browser/js/xpconnect/tests/browser/browser_deadObjectOnUnload.html";
   let newTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, url);
   let browser = gBrowser.selectedBrowser;
-  let contentDocDead = yield ContentTask.spawn(browser,{}, function*(browser){
+  let innerWindowId = browser.innerWindowID;
+  let contentDocDead = yield ContentTask.spawn(browser,{innerWindowId}, function*(args){
     let doc = content.document;
-    let promise = ContentTaskUtils.waitForEvent(this, "DOMContentLoaded", true);
+    let {TestUtils} = Components.utils.import("resource://testing-common/TestUtils.jsm", {});
+    let promise = TestUtils.topicObserved("inner-window-destroyed", (subject, data) => {
+      let id = subject.QueryInterface(Components.interfaces.nsISupportsPRUint64).data;
+      return id == args.innerWindowId;
+    });
     content.location = "about:home";
     yield promise;
     return Components.utils.isDeadWrapper(doc);
   });
   is(contentDocDead, true, "wrapper is dead");
   yield BrowserTestUtils.removeTab(newTab); 
 });