OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="inspector-protocol-test.js"></script> |
| 5 <script> |
| 6 |
| 7 function test() |
| 8 { |
| 9 let referrers = []; |
| 10 |
| 11 InspectorTest.eventHandler["Network.requestWillBeSent"] = onRequestWillBeSen
t; |
| 12 enableNetwork(); |
| 13 |
| 14 function enableNetwork() |
| 15 { |
| 16 InspectorTest.sendCommandOrDie("Network.enable", {}, didEnableNetwork); |
| 17 } |
| 18 |
| 19 function didEnableNetwork() |
| 20 { |
| 21 // Prepare for a "reload" to avoid having the test harness loaded by |
| 22 // image.html initiate the test again. |
| 23 InspectorTest.evaluateInPage( |
| 24 "prepareForReload(), window.location.href", navigate); |
| 25 } |
| 26 |
| 27 function navigate(currentUrl) |
| 28 { |
| 29 let url = currentUrl.replace( |
| 30 "override-referrer.html", "resources/image.html"); |
| 31 InspectorTest.sendCommandOrDie("Page.navigate", { |
| 32 url: url, |
| 33 referrer: "http://referrer.com/" |
| 34 }); |
| 35 } |
| 36 |
| 37 function onRequestWillBeSent(event) |
| 38 { |
| 39 let params = event.params; |
| 40 let referrer = params.request.headers.Referer; |
| 41 if (!referrer) |
| 42 return; |
| 43 |
| 44 referrers.push(InspectorTest.parseURL(referrer).host); |
| 45 if (referrers.length === 2) { |
| 46 // Only log the list the found referrers at the end of the test. |
| 47 // Otherwise the first one will be lost because the target page is in |
| 48 // the middle of loading. |
| 49 InspectorTest.log("Referrers: " + JSON.stringify(referrers)); |
| 50 testRunner.logToStderr(JSON.stringify(referrers)); |
| 51 InspectorTest.completeTest(); |
| 52 } |
| 53 } |
| 54 } |
| 55 </script> |
| 56 </head> |
| 57 <body onload="runTest()"> |
| 58 <p>Tests that the navigation referrer can be overridden.</p> |
| 59 </body> |
| 60 </html> |
OLD | NEW |