| Index: third_party/WebKit/LayoutTests/http/tests/inspector-protocol/request-referrer-policy.html
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/request-referrer-policy.html b/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/request-referrer-policy.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..de4331a51f0936992efbc5fb64fa9add31ceab7a
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/request-referrer-policy.html
|
| @@ -0,0 +1,60 @@
|
| +<!DOCTYPE html>
|
| +<script src="../inspector-protocol/inspector-protocol-test.js"></script>
|
| +<script src="/resources/get-host-info.js"></script>
|
| +<script>
|
| +function sendRequest(policy) {
|
| + var img = document.createElement("img");
|
| + img.referrerPolicy = policy;
|
| + img.src = "/resources/square.png?" + Math.random();
|
| + document.body.appendChild(img);
|
| +}
|
| +
|
| +function test() {
|
| + var policy_num = 0;
|
| + var policies = [
|
| + "unsafe-url", "no-referrer-when-downgrade", "no-referrer", "origin",
|
| + "origin-when-cross-origin"
|
| + ];
|
| +
|
| + InspectorTest.eventHandler["Network.requestWillBeSent"] = onRequestWillBeSent;
|
| + InspectorTest.sendCommand("Network.enable", {}, didEnableNetwork);
|
| +
|
| + function onRequestWillBeSent(evt) {
|
| + var req = evt.params.request;
|
| + if (req.referrerPolicy == policies[policy_num]) {
|
| + InspectorTest.log("PASS: Request with expected policy " +
|
| + policies[policy_num] + " observed");
|
| + } else {
|
| + InspectorTest.log("FAIL: Request with policy " + req.referrerPolicy +
|
| + " observed (expected " + policies[policy_num] + ")");
|
| + }
|
| + policy_num++;
|
| + if (policy_num >= policies.length) {
|
| + InspectorTest.completeTest();
|
| + } else {
|
| + InspectorTest.sendCommand(
|
| + "Runtime.evaluate",
|
| + {"expression" : "sendRequest('" + policies[policy_num] + "')"});
|
| + }
|
| + }
|
| +
|
| + 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" : "sendRequest('" + policies[policy_num] + "')"});
|
| + }
|
| +}
|
| +</script>
|
| +<body onload="runTest()">
|
| + <p>
|
| + Tests that network requests are annotated with the correct referrer
|
| + policy.
|
| + </p>
|
| +</body>
|
|
|