| Index: LayoutTests/inspector-protocol/network/resource-type.html
|
| diff --git a/LayoutTests/inspector-protocol/network/resource-type.html b/LayoutTests/inspector-protocol/network/resource-type.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4bdbdb2a241536da8acd6b2ea428613b8db716a3
|
| --- /dev/null
|
| +++ b/LayoutTests/inspector-protocol/network/resource-type.html
|
| @@ -0,0 +1,86 @@
|
| +<!DOCTYPE html>
|
| +<html>
|
| +<head>
|
| +<script src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
|
| +<script>
|
| +function appendIframe()
|
| +{
|
| + var iframe = document.createElement("iframe");
|
| + iframe.src = "resources/resources-page.html";
|
| + document.body.appendChild(iframe);
|
| +}
|
| +
|
| +function test()
|
| +{
|
| + InspectorTest.eventHandler["Network.responseReceived"] = onResponseReceived;
|
| +
|
| + function enableNetwork()
|
| + {
|
| + InspectorTest.log("Test started");
|
| + InspectorTest.sendCommand("Network.enable", {}, didEnableNetwork);
|
| + }
|
| +
|
| + function didEnableNetwork(messageObject)
|
| + {
|
| + if (messageObject.error) {
|
| + InspectorTest.log("FAIL: Couldn't enable network agent" + messageObject.error.message);
|
| + InspectorTest.completeTest();
|
| + return;
|
| + }
|
| + InspectorTest.log("Network agent enabled");
|
| + InspectorTest.sendCommand("Runtime.evaluate", { "expression": "appendIframe()"});
|
| + }
|
| +
|
| + var resources = [
|
| + { url: '/resources-page.html', type: "Document" },
|
| + { url: '/stylesheet.css', type: "Stylesheet" },
|
| + { url: '/script.js', type: "Script" },
|
| + { url: '/abe.png', type: "Image" },
|
| + { url: '/test.wav', type: "Media" },
|
| + { url: '/test.ogv', type: "Media" },
|
| + { url: '/simple-captions.vtt', type: "TextTrack" },
|
| + ];
|
| + var resourcesLeft = resources.length;
|
| +
|
| + function onResponseReceived(event)
|
| + {
|
| + var url = event.params.response.url;
|
| + var type = event.params.type;
|
| + for (var i = 0; i < resources.length; ++i) {
|
| + var resource = resources[i];
|
| + if (url.substring(url.length - resource.url.length) === resource.url) {
|
| + if (resource.gotType) {
|
| + InspectorTest.log("FAIL: Received resource " + url + " twice.");
|
| + InspectorTest.completeTest();
|
| + }
|
| + resource.gotType = type;
|
| + resource.gotUrl = url;
|
| + resourcesLeft -= 1;
|
| + if (resourcesLeft === 0)
|
| + receivedAllResources();
|
| + return;
|
| + }
|
| + }
|
| + InspectorTest.log("FAIL: received unexpected resource " + url);
|
| + InspectorTest.completeTest();
|
| + }
|
| +
|
| + function receivedAllResources()
|
| + {
|
| + for (var i = 0; i < resources.length; ++i) {
|
| + var resource = resources[i];
|
| + InspectorTest.log("Resource " + resource.url + " got type " + resource.gotType);
|
| + InspectorTest.assertEquals(resource.type, resource.gotType);
|
| + }
|
| + InspectorTest.completeTest();
|
| + }
|
| +
|
| + enableNetwork();
|
| +}
|
| +</script>
|
| +</head>
|
| +<body onload="runTest();">
|
| +<p>Tests that responseReceived contains the
|
| + <a href="https://developers.google.com/chrome-developer-tools/docs/protocol/tot/page#type-ResourceType">documented resource types</a>.
|
| +</p>
|
| +</body>
|
|
|