Bug 1242234 - Wait for page load to finish before continuing in browser_webconsole_netlogging.js. r=linclark, a=test-only
authorSami Jaktholm <sjakthol@outlook.com>
Thu, 31 Mar 2016 08:49:38 +0300
changeset 323767 53ae6c43eee21597c55e5f7ff5f65728d44cbabb
parent 323766 3efaae4308c69b90a3756a04a53c3814b852e27a
child 323768 9539d658b1a944f159893900ce0ec658ff89bfb2
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslinclark, test-only
bugs1242234
milestone47.0a2
Bug 1242234 - Wait for page load to finish before continuing in browser_webconsole_netlogging.js. r=linclark, a=test-only The problem with this test is that loadPageAndGetHud() resolves once the console message about the request is rendered. However, the message is logged immediately when enough info has been received instead of waiting for all updates, such as headers, body and timings, to be received. By the time the test calls waitForFinishedRequest(PAGE_REQUEST_PREDICATE), the initial request is still pending and the resulting promise resolves once the initial GET request finishes instead of the POST request triggered by the form submission causing the test failures. MozReview-Commit-ID: HkDdKTmzJfM
devtools/client/webconsole/test/browser_webconsole_netlogging.js
--- a/devtools/client/webconsole/test/browser_webconsole_netlogging.js
+++ b/devtools/client/webconsole/test/browser_webconsole_netlogging.js
@@ -80,18 +80,22 @@ add_task(function* testXhrPost() {
 
   is(request.request.method, "POST", "Method is correct");
   is(postData.postData.text, "Hello world!", "Request body was logged");
   is(responseContent.content.text, TEST_DATA_JSON_CONTENT,
     "Response is correct");
 });
 
 add_task(function* testFormSubmission() {
+  let pageLoadRequestFinished = waitForFinishedRequest(PAGE_REQUEST_PREDICATE);
   let hud = yield loadPageAndGetHud(TEST_NETWORK_REQUEST_URI);
 
+  info("Waiting for the page load to be finished.")
+  yield pageLoadRequestFinished;
+
   // The form POSTs to the page URL but over https (page over http).
   let finishedRequest = waitForFinishedRequest(PAGE_REQUEST_PREDICATE);
   ContentTask.spawn(gBrowser.selectedBrowser, { }, `function()
   {
     let form = content.document.querySelector("form");
     form.submit();
   }`);
   let request = yield finishedRequest;