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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/inspector-protocol/override-referrer.html

Issue 2703253002: devtools: Make it possible to override the navigation referrer (Closed)
Patch Set: Reworked into a inspector protocol test Created 3 years, 10 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
Index: third_party/WebKit/LayoutTests/http/tests/inspector-protocol/override-referrer.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/override-referrer.html b/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/override-referrer.html
new file mode 100644
index 0000000000000000000000000000000000000000..3526740e615eb434d323e669975f1e965ea6306e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/override-referrer.html
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="inspector-protocol-test.js"></script>
+<script>
+
+function test()
+{
+ let referrers = [];
+
+ InspectorTest.eventHandler["Network.requestWillBeSent"] = onRequestWillBeSent;
+ enableNetwork();
+
+ function enableNetwork()
+ {
+ InspectorTest.sendCommandOrDie("Network.enable", {}, didEnableNetwork);
+ }
+
+ function didEnableNetwork()
+ {
+ // Prepare for a "reload" to avoid having the test harness loaded by
+ // image.html initiate the test again.
+ InspectorTest.evaluateInPage(
+ "prepareForReload(), window.location.href", navigate);
+ }
+
+ function navigate(currentUrl)
+ {
+ let url = currentUrl.replace(
+ "override-referrer.html", "resources/image.html");
+ InspectorTest.sendCommandOrDie("Page.navigate", {
+ url: url,
+ referrer: "http://referrer.com/"
+ });
+ }
+
+ function onRequestWillBeSent(event)
+ {
+ let params = event.params;
+ let referrer = params.request.headers.Referer;
+ if (!referrer)
+ return;
+
+ referrers.push(InspectorTest.parseURL(referrer).host);
+ if (referrers.length === 2) {
+ // Only log the list the found referrers at the end of the test.
+ // Otherwise the first one will be lost because the target page is in
+ // the middle of loading.
+ InspectorTest.log("Referrers: " + JSON.stringify(referrers));
+ testRunner.logToStderr(JSON.stringify(referrers));
+ InspectorTest.completeTest();
+ }
+ }
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>Tests that the navigation referrer can be overridden.</p>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698