Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/subresource_filter/image-disallowed.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/subresource_filter/image-disallowed.html b/third_party/WebKit/LayoutTests/http/tests/subresource_filter/image-disallowed.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6e852fff926da1e1f1d8bf934c61fcfe5210d8b8 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/subresource_filter/image-disallowed.html |
| @@ -0,0 +1,38 @@ |
| +<!DOCTYPE html> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<body> |
| +<script type="text/javascript"> |
| +// Tests that when resource loads initiated by <img> elements are disallowed, |
| +// the corresponding image is collapsed in the layout. |
| + |
| +if (window.testRunner) { |
| + // Inject a subresource filter to disallow 'beta.png' (but not 'alpha.png'). |
| + testRunner.setDisallowedSubresourcePathSuffixes(["beta.png"]); |
| +} |
| + |
| +async_test(t => { |
| + let i = document.createElement("img"); |
| + i.onload = t.step_func_done(_ => { |
| + assert_equals(i.clientWidth, 100, "Images that are not disallowed are displayed at their natural width."); |
|
dominicc (has gone to gerrit)
2016/12/05 03:30:55
Consider 'should be' instead of 'are'. When an ass
engedy
2016/12/06 15:27:57
Good point, done everywhere.
|
| + assert_equals(i.clientHeight, 100, "Images that are not disallowed are displayed at their natural height."); |
| + }); |
| + i.onerror = t.unreached_func(); |
| + i.src = "resources/alpha.png"; |
| + document.body.appendChild(i); |
| +}, "Images whose URLs are not disallowed are still displayed as normal."); |
| + |
| +async_test(t => { |
| + let i = document.createElement("img"); |
| + i.onload = t.unreached_func(); |
| + i.onerror = t.step_func_done(_ => { |
| + assert_equals(i.clientWidth, 0, "Images that are disallowed are collapsed."); |
| + assert_equals(i.clientHeight, 0, "Images that are disallowed are collapsed."); |
| + assert_equals(i.naturalWidth, 0, "Images that are disallowed are not loaded."); |
| + assert_equals(i.naturalHeight, 0, "Images that are disallowed are not loaded."); |
| + }); |
| + i.src = "resources/beta.png"; |
| + document.body.appendChild(i); |
|
dominicc (has gone to gerrit)
2016/12/05 03:30:55
Consider using 'append', which is a wee bit shorte
engedy
2016/12/06 15:27:57
Done everywhere.
|
| +}, "Images whose initial URL is disallowed are not loaded and collapsed in the layout."); |
| + |
| +</script> |