Bug 1573647, try to make test_windowedhistoryframes.html less racy by using popstate event and not timeout, r=peterv
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Tue, 12 Nov 2019 17:14:51 +0000
changeset 501601 46948e618953a6cb0d7aa931ea94c4d64789dbdb
parent 501600 d1ea0724b6caa33111426ec69a7e288cfde79dee
child 501602 a2af5be34b6b8ee865a3283880e5b4b16bbbde30
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1573647
milestone72.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 1573647, try to make test_windowedhistoryframes.html less racy by using popstate event and not timeout, r=peterv Using popstate event in cases it is fired. Differential Revision: https://phabricator.services.mozilla.com/D52600
dom/tests/mochitest/general/historyframes.html
--- a/dom/tests/mochitest/general/historyframes.html
+++ b/dom/tests/mochitest/general/historyframes.html
@@ -83,16 +83,21 @@ function continue_test() {
   }
 }
 
 var gTestContinuation = null;
 function continueAsync() {
   setTimeout(function() { gTestContinuation.next(); })
 }
 
+function continueOnPopState() {
+  // Use continueAsync to avoid recursion within sync popstate listener.
+  window.addEventListener("popstate", continueAsync, { once: true });
+}
+
 function* test_basic_inner_navigation() {
   // Navigate the inner frame a few times
   yield loadContent(URL1);
   is(getURL(), URL1, "URL should be correct");
   is(getContent(), "Test1", "Page should be correct");
 
   yield loadContent(URL2);
 
@@ -118,36 +123,36 @@ function* test_state_navigation() {
   is(getContent(), "Test2", "Page should be correct");
 
   window.history.pushState("STATE2", window.location);
 
   is(getURL(), URL2, "URL should be correct");
   is(getContent(), "Test2", "Page should be correct");
 
   window.history.back();
-  continueAsync();
+  continueOnPopState();
   yield;
 
   is(gState, "STATE1", "State should be correct");
   is(getURL(), URL2, "URL should be correct");
   is(getContent(), "Test2", "Page should be correct");
 
   window.history.forward();
-  continueAsync();
+  continueOnPopState();
   yield;
 
   is(gState, "STATE2", "State should be correct");
   is(getURL(), URL2, "URL should be correct");
   is(getContent(), "Test2", "Page should be correct");
 
   window.history.back();
-  continueAsync();
+  continueOnPopState();
   yield;
   window.history.back();
-  continueAsync();
+  continueOnPopState();
   yield;
 
   is(gState, "START", "State should be correct");
   is(getURL(), URL2, "URL should be correct");
   is(getContent(), "Test2", "Page should be correct");
 
   window.history.back();
   continueAsync();