Bug 1400528 - make test_bug574663.html wait until the 'blank' attribute has actually been removed, r=mconley.
authorFlorian Quèze <florian@queze.net>
Fri, 22 Sep 2017 00:50:54 +0200
changeset 668872 976a82102f131f232cca5e88d1746fb63226c3f9
parent 668871 8871efefdba925fd4fa7e8741cb545dd64131271
child 668873 fdffa3d2976838b613580035b2f031adba29976c
push id81146
push userbmo:topwu.tw@gmail.com
push dateFri, 22 Sep 2017 05:24:51 +0000
reviewersmconley
bugs1400528, 574663
milestone58.0a1
Bug 1400528 - make test_bug574663.html wait until the 'blank' attribute has actually been removed, r=mconley.
dom/events/test/test_bug574663.html
dom/events/test/window_wheel_default_action.html
--- a/dom/events/test/test_bug574663.html
+++ b/dom/events/test/test_bug574663.html
@@ -100,22 +100,30 @@ function runTest() {
   var win = open('bug574663.html', '_blank', 'width=300,height=300');
   let winUtils = SpecialPowers.getDOMWindowUtils(win);
 
   let waitUntilPainted = function(callback) {
     // Until the first non-blank paint, the parent will set the opacity of our
     // browser to 0 using the 'blank' attribute.
     // Until the blank attribute is removed, we can't send scroll events.
     SimpleTest.waitForFocus(function() {
-      SpecialPowers.loadChromeScript(_ => {
+      let chromeScript = SpecialPowers.loadChromeScript(_ => {
         Components.utils.import("resource://gre/modules/Services.jsm");
-        Services.wm.getMostRecentWindow("navigator:browser")
-                .gBrowser.selectedBrowser.removeAttribute("blank");
+        let win = Services.wm.getMostRecentWindow("navigator:browser");
+        win.requestAnimationFrame(() => {
+          win.gBrowser.selectedBrowser.removeAttribute("blank");
+          win.requestAnimationFrame(() => {
+            sendAsyncMessage("blank-attribute-removed");
+          });
+        });
       });
-      waitForPaint(win, winUtils, callback);
+      chromeScript.promiseOneMessage("blank-attribute-removed").then(() => {
+        chromeScript.destroy();
+        waitForPaint(win, winUtils, callback);
+      });
     }, win);
   };
 
   waitUntilPainted(function () {
     var scrollbox = win.document.getElementById("scrollbox");
     let outstandingTests = [
       [false, false],
       [false, true],
--- a/dom/events/test/window_wheel_default_action.html
+++ b/dom/events/test/window_wheel_default_action.html
@@ -47,22 +47,30 @@
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 // Until the first non-blank paint, the parent will set the opacity of our
 // browser to 0 using the 'blank' attribute.
 // Until the blank attribute is removed, we can't send scroll events.
 SimpleTest.waitForFocus(function() {
-  SpecialPowers.loadChromeScript(_ => {
+  let chromeScript = SpecialPowers.loadChromeScript(_ => {
     Components.utils.import("resource://gre/modules/Services.jsm");
-    Services.wm.getMostRecentWindow("navigator:browser")
-            .gBrowser.selectedBrowser.removeAttribute("blank");
+    let win = Services.wm.getMostRecentWindow("navigator:browser");
+    win.requestAnimationFrame(() => {
+      win.gBrowser.selectedBrowser.removeAttribute("blank");
+      win.requestAnimationFrame(() => {
+        sendAsyncMessage("blank-attribute-removed");
+      });
+    });
   });
-  runTests();
+  chromeScript.promiseOneMessage("blank-attribute-removed").then(() => {
+    chromeScript.destroy();
+    runTests();
+  });
 }, window);
 
 SimpleTest.requestFlakyTimeout("untriaged");
 
 var winUtils = SpecialPowers.getDOMWindowUtils(window);
 // grab refresh driver
 winUtils.advanceTimeAndRefresh(100);