Commit 8b84279b authored by yhirano's avatar yhirano Committed by Commit bot

Deflake inspector-protocol/network/resource-type.html

Test test reads body right after receiving a response, but it leads to some
flakiness. It is not guaranteed that the response body is available at the
moment.

This change fixes the problem by reading response body after the loading
finishes.

BUG=675924
R=dgozman@chromium.org

Review-Url: https://codereview.chromium.org/2592663002
Cr-Commit-Position: refs/heads/master@{#439844}
parent 64b24317
...@@ -13,6 +13,7 @@ function appendIframe() ...@@ -13,6 +13,7 @@ function appendIframe()
function test() function test()
{ {
InspectorTest.eventHandler["Network.responseReceived"] = onResponseReceived; InspectorTest.eventHandler["Network.responseReceived"] = onResponseReceived;
InspectorTest.eventHandler["Network.loadingFinished"] = onLoadingFinished;
function enableNetwork() function enableNetwork()
{ {
...@@ -60,10 +61,7 @@ function test() ...@@ -60,10 +61,7 @@ function test()
} }
resource.gotType = type; resource.gotType = type;
resource.gotUrl = url; resource.gotUrl = url;
if ("responseAvailable" in resource) resource.requestId = requestId;
onResponseReady();
else
InspectorTest.sendCommand("Network.getResponseBody", { "requestId": requestId }, onResponseBody.bind(null, resource));
return; return;
} }
} }
...@@ -71,6 +69,21 @@ function test() ...@@ -71,6 +69,21 @@ function test()
InspectorTest.completeTest(); InspectorTest.completeTest();
} }
function onLoadingFinished(event)
{
const requestId = event.params.requestId;
for (const resource of resources) {
if (resource.requestId !== requestId) {
continue;
}
if ("responseAvailable" in resource) {
onResponseReady();
} else {
InspectorTest.sendCommand("Network.getResponseBody", { "requestId": requestId }, onResponseBody.bind(null, resource));
}
}
}
function onResponseReady() function onResponseReady()
{ {
resourcesLeft -= 1; resourcesLeft -= 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment