Bug 1270234 - Fix intermittent browser_bug664688_sandbox_update_after_navigation.js. r=bgrins, a=test-only
authorSami Jaktholm <sjakthol@outlook.com>
Sat, 30 Jul 2016 13:35:36 +0300
changeset 349765 185eea0d3e023a0ddf27be25889e1c22e1445d9a
parent 349764 002e71897e08600cbf7fd8c71e2ea2d46c71d28f
child 349766 92938f4fa0d08753fff2b8902417d30561efc6c0
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins, test-only
bugs1270234
milestone50.0a2
Bug 1270234 - Fix intermittent browser_bug664688_sandbox_update_after_navigation.js. r=bgrins, a=test-only Page navigation triggers a chain of events that lead to the console being cleared. If the stars are perfectly aligned, the clear is triggered after |window.location.href| is executed but before waitForMessages() looks at the existing messages in the console. This causes the input line to be lost and the test times out waiting for it. These changes make the test to wait for the first clear to happen before continuing the test. MozReview-Commit-ID: LWuR8wxc5Lh
devtools/client/webconsole/test/browser_bug664688_sandbox_update_after_navigation.js
--- a/devtools/client/webconsole/test/browser_bug664688_sandbox_update_after_navigation.js
+++ b/devtools/client/webconsole/test/browser_bug664688_sandbox_update_after_navigation.js
@@ -67,27 +67,34 @@ add_task(function* () {
         category: CATEGORY_OUTPUT,
       },
     ],
   });
 
   is(hud.outputNode.textContent.indexOf("Permission denied"), -1,
      "no permission denied errors");
 
+  // Navigation clears messages. Wait for that clear to happen before
+  // continuing the test or it might destroy messages we wait later on (Bug
+  // 1270234).
+  let cleared = hud.jsterm.once("messages-cleared");
+
   gBrowser.goBack();
 
+  info("Waiting for page to navigate");
   yield waitForSuccess({
     name: "go back",
     validator: function () {
       return content.location.href == TEST_URI1;
     },
   });
 
-  hud.jsterm.clearOutput();
-  executeSoon(() => {
-    hud.jsterm.execute("window.location.href");
-  });
+  info("Waiting for messages to be cleared due to navigation");
+  yield cleared;
+
+  info("Messages cleared after navigation; checking location");
+  hud.jsterm.execute("window.location.href");
 
   info("wait for window.location.href after goBack()");
   yield waitForMessages(msgForLocation1);
   is(hud.outputNode.textContent.indexOf("Permission denied"), -1,
      "no permission denied errors");
 });