Bug 1242234 - Wait for page load to finish before continuing in browser_webconsole_netlogging.js. r=linclark
authorSami Jaktholm <sjakthol@outlook.com>
Thu, 31 Mar 2016 08:49:38 +0300
changeset 291291 5174488b2a590ce8c6ba9bed2d8458252af3b282
parent 291290 527346010e0fabf5a754308560c276ef36e0d05c
child 291292 b932cef38db8ae5957d2b49a4f47f067938a09a0
push id30131
push userkwierso@gmail.com
push dateFri, 01 Apr 2016 22:43:45 +0000
treeherdermozilla-central@c40c0b2f3b4c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslinclark
bugs1242234
milestone48.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 1242234 - Wait for page load to finish before continuing in browser_webconsole_netlogging.js. r=linclark 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;