Bug 1400528 - Make test_bug574663.html wait until the 'blank' attribute has actually been removed. r=mconley, a=test-only
authorFlorian Quèze <florian@queze.net>
Fri, 22 Sep 2017 00:50:54 +0200
changeset 669785 5c81435741d74e0596874277f4796ec47e2a87c3
parent 669784 9c49f9ce76fa4746d788284702442c9b3215d5bd
child 669786 ecd8fc49d159299a38c568de20ed59effa07306a
push id81427
push userluca.greco@alcacoop.it
push dateMon, 25 Sep 2017 11:52:41 +0000
reviewersmconley, test-only
bugs1400528, 574663
milestone57.0
Bug 1400528 - Make test_bug574663.html wait until the 'blank' attribute has actually been removed. r=mconley, a=test-only
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);