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

Unified 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: updates 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector-protocol/request-referrer-policy-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector-protocol/request-referrer-policy-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698