Index: LayoutTests/http/tests/inspector/network/network-blocked-reason.html |
diff --git a/LayoutTests/http/tests/inspector/network/network-blocked-reason.html b/LayoutTests/http/tests/inspector/network/network-blocked-reason.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b01997652ada931e3080618414c268b3363b9f71 |
--- /dev/null |
+++ b/LayoutTests/http/tests/inspector/network/network-blocked-reason.html |
@@ -0,0 +1,75 @@ |
+<html> |
+<head> |
+<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'"> |
+<script src="/inspector/inspector-test.js"></script> |
+<script> |
+ |
+function sendCSPRequest() |
+{ |
+ var script = document.createElement("script"); |
+ script.src = "https://www.example.com/csp.js"; |
+ document.head.appendChild(script); |
+} |
+ |
+function addBlockedScript() |
+{ |
+ var script = document.createElement("script"); |
+ script.src = "resources/silent_script.js"; |
+ document.head.appendChild(script); |
+} |
+ |
+function test() |
+{ |
+ var requestName; |
+ var nextStep; |
+ var blockedSetting = WebInspector.settingForTest("blockedURLs"); |
+ |
+ function onRequest(event) |
+ { |
+ var request = event.data; |
+ if (request.name() !== requestName) |
+ return; |
+ requestName = undefined; |
+ InspectorTest.addResult(""); |
+ InspectorTest.addResult("Request: " + request.name()); |
+ InspectorTest.addResult("BlockedReason: " + request.blockedReason()); |
+ nextStep(); |
+ } |
+ |
+ InspectorTest.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.RequestFinished, onRequest); |
+ |
+ InspectorTest.runTestSuite([ |
+ function testCSP(next) |
+ { |
+ requestName = "csp.js"; |
+ nextStep = next; |
+ InspectorTest.evaluateInPage("sendCSPRequest()"); |
+ }, |
+ |
+ function testDevTools(next) |
+ { |
+ blockedSetting.set(["http://some.strange.origin/script.js", "resources/silent_script.js"]); |
+ nextStep = removeBlock; |
+ InspectorTest.runAfterPendingDispatches(addScript); |
+ |
+ function removeBlock() |
+ { |
+ blockedSetting.set(["http://some.strange.origin/script.js"]); |
+ nextStep = next; |
+ InspectorTest.runAfterPendingDispatches(addScript); |
+ } |
+ |
+ function addScript() |
+ { |
+ requestName = "silent_script.js"; |
+ InspectorTest.evaluateInPage("addBlockedScript()"); |
+ } |
+ } |
+ ]); |
+} |
+</script> |
+</head> |
+<body onload="runTest()"> |
+<p>Tests that blocked reason is recognized correctly.</p> |
+</body> |
+</html> |