Bug 1370101 - Make test_windowProxyDeadWrapper.html 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>
Tue, 30 May 2017 00:34:51 -0400
changeset 410362 be7ee8326facc899155d9d1c6573f73731921b9b
parent 410361 1002aa75bf5df4820646ddc76e39752ef2116d34
child 410363 5dd5d16e708558e464ef335c67defdf41838cea8
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
bugs1370101
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 1370101 - Make test_windowProxyDeadWrapper.html correctly wait for the window to be destroyed instead of relying on the scheduling of the corresponding event; r=kmag
js/xpconnect/tests/chrome/test_windowProxyDeadWrapper.html
--- a/js/xpconnect/tests/chrome/test_windowProxyDeadWrapper.html
+++ b/js/xpconnect/tests/chrome/test_windowProxyDeadWrapper.html
@@ -7,16 +7,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <meta charset="utf-8">
   <title>Test for Bug 1223372</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
   <script type="application/javascript">
 
 /** Test for Bug 1223372 **/
+Components.utils.import("resource://testing-common/TestUtils.jsm");
 
 function go() {
     SimpleTest.waitForExplicitFinish();
 
     var frame = $('subframe');
     frame.onload = null;
 
     var w = frame.contentWindow;
@@ -35,21 +36,28 @@ function go() {
 
     function tryWindow() {
         if (w.document.title != 'empty test page') {
             info("Document not loaded yet - retrying");
             SimpleTest.executeSoon(tryWindow);
             return;
         }
 
+        let winID = w.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+                     .getInterface(Components.interfaces.nsIDOMWindowUtils)
+                     .outerWindowID;
         // Remove the frame. This will nuke the WindowProxy wrapper from our chrome
-        // document's global, so evaluating 'this' in it will return a dead wrapper.
+        // document's global, so evaluating 'this' in it will return a dead wrapper
+        // once the window is destroyed.
         frame.remove();
 
-        SimpleTest.executeSoon(function() {
+        TestUtils.topicObserved("outer-window-destroyed", (subject, data) => {
+            let id = subject.QueryInterface(SpecialPowers.Ci.nsISupportsPRUint64).data;
+            return id == winID;
+        }).then(() => {
             ok(checkDead(), "Expected a dead object wrapper");
 
             // Wrapping the Window should throw now.
             var exc;
             try {
                 Components.utils.getGlobalForObject(getObject());
             } catch(e) {
                 exc = e;