Bug 1242234 - Wait for page load to finish before continuing in browser_webconsole_netlogging.js. r?linclark draft
authorSami Jaktholm <sjakthol@outlook.com>
Thu, 31 Mar 2016 08:49:38 +0300
changeset 346231 7945bf42c9ae459cf41883c492802a0ce51ae868
parent 346007 e14db462d31d566570e3bece66d5380f7b1ad400
child 517371 52f652276efcf749ee7d269d8fe8847b96c0b929
push id14295
push usersjakthol@outlook.com
push dateThu, 31 Mar 2016 11:05:27 +0000
reviewerslinclark
bugs1242234
milestone48.0a1
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;