OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-in
line'"> |
| 4 <script src="/inspector/inspector-test.js"></script> |
| 5 <script> |
| 6 |
| 7 function sendCSPRequest() |
| 8 { |
| 9 var script = document.createElement("script"); |
| 10 script.src = "https://www.example.com/csp.js"; |
| 11 document.head.appendChild(script); |
| 12 } |
| 13 |
| 14 function addBlockedScript() |
| 15 { |
| 16 var script = document.createElement("script"); |
| 17 script.src = "resources/silent_script.js"; |
| 18 document.head.appendChild(script); |
| 19 } |
| 20 |
| 21 function test() |
| 22 { |
| 23 var requestName; |
| 24 var nextStep; |
| 25 var blockedSetting = WebInspector.settingForTest("blockedURLs"); |
| 26 |
| 27 function onRequest(event) |
| 28 { |
| 29 var request = event.data; |
| 30 if (request.name() !== requestName) |
| 31 return; |
| 32 requestName = undefined; |
| 33 InspectorTest.addResult(""); |
| 34 InspectorTest.addResult("Request: " + request.name()); |
| 35 InspectorTest.addResult("BlockedReason: " + request.blockedReason()); |
| 36 nextStep(); |
| 37 } |
| 38 |
| 39 InspectorTest.networkManager.addEventListener(WebInspector.NetworkManager.Ev
entTypes.RequestFinished, onRequest); |
| 40 |
| 41 InspectorTest.runTestSuite([ |
| 42 function testCSP(next) |
| 43 { |
| 44 requestName = "csp.js"; |
| 45 nextStep = next; |
| 46 InspectorTest.evaluateInPage("sendCSPRequest()"); |
| 47 }, |
| 48 |
| 49 function testDevTools(next) |
| 50 { |
| 51 blockedSetting.set(["http://some.strange.origin/script.js", "resourc
es/silent_script.js"]); |
| 52 nextStep = removeBlock; |
| 53 InspectorTest.runAfterPendingDispatches(addScript); |
| 54 |
| 55 function removeBlock() |
| 56 { |
| 57 blockedSetting.set(["http://some.strange.origin/script.js"]); |
| 58 nextStep = next; |
| 59 InspectorTest.runAfterPendingDispatches(addScript); |
| 60 } |
| 61 |
| 62 function addScript() |
| 63 { |
| 64 requestName = "silent_script.js"; |
| 65 InspectorTest.evaluateInPage("addBlockedScript()"); |
| 66 } |
| 67 } |
| 68 ]); |
| 69 } |
| 70 </script> |
| 71 </head> |
| 72 <body onload="runTest()"> |
| 73 <p>Tests that blocked reason is recognized correctly.</p> |
| 74 </body> |
| 75 </html> |
OLD | NEW |