Bug 1368272 - Rewrite test_bug534149.html to not rely on the dispatching order of WindowDestroyedEvent; r=mystor
authorEhsan Akhgari <ehsan@mozilla.com>
Sat, 27 May 2017 15:13:06 -0400
changeset 409178 d1743afbf7ac41e11a73e7e765904150e3b3c426
parent 409177 0dbfdf0816b63b01f1076f118aad79b29a3cef22
child 409179 4541134e973a6bd5e667a603e844854c8e5361da
child 409190 e12fa325e11235635eaa49d553f89b8023e26c98
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)
reviewersmystor
bugs1368272, 534149
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 1368272 - Rewrite test_bug534149.html to not rely on the dispatching order of WindowDestroyedEvent; r=mystor
dom/tests/mochitest/bugs/test_bug534149.html
--- a/dom/tests/mochitest/bugs/test_bug534149.html
+++ b/dom/tests/mochitest/bugs/test_bug534149.html
@@ -30,51 +30,56 @@ function getIDs(iframe) {
 var i1 = document.createElement("iframe");
 var i2 = document.createElement("iframe");
 
 document.body.appendChild(i1);
 var [i1outer, i1inner] = getIDs(i1);
 
 document.body.appendChild(i2);
 var [i2outer, i2inner] = getIDs(i2);
-  
+
 is(i1inner, i1outer + 1, "For frame 1, inner should come right after outer");
 is(i2inner, i2outer + 1, "For frame 2, inner should come right after outer");
 is(i2outer, i1inner + 1, "Frame 2 comes right after frame 1");
 
-var innerWindowDestroyID;
-var outerWindowDestroyID;
+var innerWindowDestroyID = null;
+var outerWindowDestroyID = null;
 
 var outerObserver = {
   observe: function(id) {
     outerWindowDestroyID =
       SpecialPowers.wrap(id).QueryInterface(SpecialPowers.Ci.nsISupportsPRUint64).data;
+    SpecialPowers.removeObserver(outerObserver, "outer-window-destroyed");
+    maybeContinueTest();
   }
 };
 var innerObserver = {
   observe: function(id) {
-  innerWindowDestroyID =
-   SpecialPowers.wrap(id).QueryInterface(SpecialPowers.Ci.nsISupportsPRUint64).data;
+    innerWindowDestroyID =
+      SpecialPowers.wrap(id).QueryInterface(SpecialPowers.Ci.nsISupportsPRUint64).data;
+    SpecialPowers.removeObserver(innerObserver, "inner-window-destroyed");
+    maybeContinueTest();
   }
 };
 
 function removeFrame(iframe) {
   SpecialPowers.addObserver(outerObserver, "outer-window-destroyed");
   SpecialPowers.addObserver(innerObserver, "inner-window-destroyed");
 
   iframe.remove();
 }
 
+function maybeContinueTest() {
+  if (innerWindowDestroyID != null &&
+      outerWindowDestroyID != null) {
+    is(innerWindowDestroyID, i1inner, "inner window of frame 1 should be destroyed");
+    is(outerWindowDestroyID, i1outer, "outer window of frame 1 should be destroyed");
+    SimpleTest.finish();
+  }
+}
+
 removeFrame(i1);
 SimpleTest.waitForExplicitFinish();
-SimpleTest.executeSoon(function() {
-  is(innerWindowDestroyID, i1inner, "inner window of frame 1 should be destroyed");
-  is(outerWindowDestroyID, i1outer, "outer window of frame 1 should be destroyed");
-  SpecialPowers.removeObserver(outerObserver, "outer-window-destroyed");
-  SpecialPowers.removeObserver(innerObserver, "inner-window-destroyed");
-  SimpleTest.finish();
-});
-  
 
 </script>
 </pre>
 </body>
 </html>