| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../inspector-protocol/inspector-protocol-test.js"></script> |
| 3 <script src="/resources/get-host-info.js"></script> |
| 4 <script> |
| 5 function sendRequest(policy) { |
| 6 var img = document.createElement("img"); |
| 7 img.referrerPolicy = policy; |
| 8 img.src = "/resources/square.png?" + Math.random(); |
| 9 document.body.appendChild(img); |
| 10 } |
| 11 |
| 12 function test() { |
| 13 var policy_num = 0; |
| 14 var policies = [ |
| 15 "unsafe-url", "no-referrer-when-downgrade", "no-referrer", "origin", |
| 16 "origin-when-cross-origin" |
| 17 ]; |
| 18 |
| 19 InspectorTest.eventHandler["Network.requestWillBeSent"] = onRequestWillBeSent; |
| 20 InspectorTest.sendCommand("Network.enable", {}, didEnableNetwork); |
| 21 |
| 22 function onRequestWillBeSent(evt) { |
| 23 var req = evt.params.request; |
| 24 if (req.referrerPolicy == policies[policy_num]) { |
| 25 InspectorTest.log("PASS: Request with expected policy " + |
| 26 policies[policy_num] + " observed"); |
| 27 } else { |
| 28 InspectorTest.log("FAIL: Request with policy " + req.referrerPolicy + |
| 29 " observed (expected " + policies[policy_num] + ")"); |
| 30 } |
| 31 policy_num++; |
| 32 if (policy_num >= policies.length) { |
| 33 InspectorTest.completeTest(); |
| 34 } else { |
| 35 InspectorTest.sendCommand( |
| 36 "Runtime.evaluate", |
| 37 {"expression" : "sendRequest('" + policies[policy_num] + "')"}); |
| 38 } |
| 39 } |
| 40 |
| 41 function didEnableNetwork(messageObject) { |
| 42 if (messageObject.error) { |
| 43 InspectorTest.log("FAIL: Couldn't enable network agent " + |
| 44 messageObject.error.message); |
| 45 InspectorTest.completeTest(); |
| 46 return; |
| 47 } |
| 48 InspectorTest.log("Network agent enabled"); |
| 49 InspectorTest.sendCommand( |
| 50 "Runtime.evaluate", |
| 51 {"expression" : "sendRequest('" + policies[policy_num] + "')"}); |
| 52 } |
| 53 } |
| 54 </script> |
| 55 <body onload="runTest()"> |
| 56 <p> |
| 57 Tests that network requests are annotated with the correct referrer |
| 58 policy. |
| 59 </p> |
| 60 </body> |
| OLD | NEW |