| <!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> |