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
--- 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;