Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/inspector-protocol/request-referrer-policy.html

Issue 2603593002: Expose per-request referrer policy in devtools (Closed)
Patch Set: Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 var policies; // Will be set by test()
6
7 function sendRequest(policy_num) {
8 var img = document.createElement("img");
9 img.referrerPolicy = policies[policy_num];
10 img.src = "/resources/square.png?" + Math.random();
11 document.body.appendChild(img);
12 }
13
14 function test() {
15 var policy_num = 0;
16 var policies = [
17 "unsafe-url", "no-referrer-when-downgrade", "no-referrer", "origin",
18 "origin-when-cross-origin"
19 ];
20
21 InspectorTest.eventHandler["Network.requestWillBeSent"] = onRequestWillBeSent;
22 InspectorTest.sendCommand("Runtime.evaluate", {
23 "expression" :
24 "policies = [" + policies.map(p => "'" + p + "'").toString() + "]"
dgozman 2016/12/27 19:45:36 It would be easier to pass the policy string in se
jochen (gone - plz use gerrit) 2017/01/02 07:38:05 done
25 });
26 InspectorTest.sendCommand("Network.enable", {}, didEnableNetwork);
27
28 function onRequestWillBeSent(evt) {
29 var req = evt.params.request;
30 if (req.referrerPolicy == policies[policy_num]) {
31 InspectorTest.log("PASS: Request with expected policy " +
32 policies[policy_num] + " observed");
33 } else {
34 InspectorTest.log("FAIL: Request with policy " + req.referrerPolicy +
35 " observed (expected " + policies[policy_num] + ")");
36 }
37 policy_num++;
38 if (policy_num >= policies.length) {
39 InspectorTest.completeTest();
40 } else {
41 InspectorTest.sendCommand(
42 "Runtime.evaluate",
43 {"expression" : "sendRequest(" + policy_num + ")"});
44 }
45 }
46
47 function didEnableNetwork(messageObject) {
48 if (messageObject.error) {
49 InspectorTest.log("FAIL: Couldn't enable network agent " +
50 messageObject.error.message);
51 InspectorTest.completeTest();
52 return;
53 }
54 InspectorTest.log("Network agent enabled");
55 InspectorTest.sendCommand("Runtime.evaluate",
56 {"expression" : "sendRequest(0)"});
57 }
58 }
59 </script>
60 <body onload="runTest()">
61 <p>
62 Tests that network requests are annotated with the correct referrer
63 policy.
64 </p>
65 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698