Index: third_party/WebKit/LayoutTests/http/tests/subresource_filter/resource-in-import-disallowed.html |
diff --git a/third_party/WebKit/LayoutTests/http/tests/subresource_filter/resource-in-import-disallowed.html b/third_party/WebKit/LayoutTests/http/tests/subresource_filter/resource-in-import-disallowed.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2f9c6c4bb9667a62a0b55ebf5b4d292e6f11a1a3 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/http/tests/subresource_filter/resource-in-import-disallowed.html |
@@ -0,0 +1,46 @@ |
+<!DOCTYPE html> |
+<html> |
+<head> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+</head> |
+<body> |
+<script type="text/javascript"> |
+if (window.testRunner) { |
+ // Inject a subresource filter to disallow 'beta.js' (but not 'alpha.js'). |
+ // Furthermore, try to block the imported document itself, which should have no effect |
+ // as subresource filtering should not apply directly to import document resources. |
+ testRunner.setDisallowedSubresourcePathSuffixes(["beta.js", "include-scripts.html"]); |
+} |
+ |
+document.scriptsLoaded = []; |
+document.notifyScriptLoaded = function(basename) { |
+ document.scriptsLoaded.push(basename); |
+} |
+ |
+document.scriptsFailed = []; |
+document.notifyScriptFailed = function(basename) { |
+ document.scriptsFailed.push(basename); |
+} |
+ |
+document.scriptsExecuted = []; |
+document.notifyScriptExecuted = function(basename) { |
+ document.scriptsExecuted.push(basename); |
+} |
+ |
+async_test(t => { |
+ var i = document.createElement("link"); |
+ i.rel = "import"; |
+ i.onload = t.step_func_done(_ => { |
+ assert_array_equals(document.scriptsLoaded, ["alpha"], "Resources whose URLs are not disallowed are still loaded."); |
+ assert_array_equals(document.scriptsFailed, ["beta"], "Resources whose URLs are disallowed are not loaded."); |
+ assert_array_equals(document.scriptsExecuted, ["alpha"], "Scripts that are not disallowed are executed."); |
+ }); |
+ i.onerror = t.unreached_func("Subresouce filter should not apply directly to HTML import documents."); |
+ i.href = "resources/include-scripts.html"; |
+ document.body.appendChild(i); |
+}, "Resource loads in import documents respect the subresource filter of the master document."); |
+ |
+</script> |
+</body> |
+</html> |