Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1013)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/subresource_filter/image-allow-disallow-transitions.html

Issue 2535383003: Collapse images disallowed by the Safe Browsing Subresource Filter. (Closed)
Patch Set: Rebase. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/subresource_filter/image-allow-disallow-transitions.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/subresource_filter/image-allow-disallow-transitions.html b/third_party/WebKit/LayoutTests/http/tests/subresource_filter/image-allow-disallow-transitions.html
new file mode 100644
index 0000000000000000000000000000000000000000..168c1e9e318cf6ee4a0dfaf3aaafa60c039ce1ec
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/subresource_filter/image-allow-disallow-transitions.html
@@ -0,0 +1,77 @@
+<!DOCTYPE html>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<body>
+<script type="text/javascript">
+// Verify that when the 'src' attribute for an <img> element is changed, the
+// element transitions properly between states where primary content is shown,
+// fallback content is shown, and when the element is collapsed.
+//
+// This test is carried out using a matrix of <img> elements. Initially, all
+// images in the first row are set to show primary content, all images in the
+// second row are set to show fallback content, etc. Once everything is loaded,
+// the 'src' URLs are changed so that all images in the first column should show
+// primary content, in the second column fallback content, etc.
+
+var INITIAL_URLS = {
+ "primary": "resources/alpha.png",
+ "fallback": "resources/non-existent-1.png",
+ "collapsed": "resources/gamma.png"
+};
+
+var FINAL_URLS = {
+ "primary": "resources/beta.png",
+ "fallback": "resources/non-existent-2.png",
+ "collapsed": "resources/delta.png"
+};
+
+var EXPECTED_LOADEND_EVENT = {
+ "primary": "load",
+ "fallback": "error",
+ "collapsed": "error"
+};
+
+var EXPECTED_WIDTH = {
+ "primary": 100,
+ "fallback": 20,
+ "collapsed": 0
+};
+
+var numPendingImages =
+ Object.keys(INITIAL_URLS).length * Object.keys(FINAL_URLS).length;
+
+if (window.testRunner)
+ testRunner.setDisallowedSubresourcePathSuffixes(["gamma.png", "delta.png"]);
+
+let table = document.createElement("table");
+let headerRow = table.insertRow();
+
+headerRow.insertCell().innerHTML = "- - - - \\ Final<br>Initial \\";
+for (let finalState of Object.keys(FINAL_URLS)) {
+ headerRow.insertCell().textContent = finalState;
+}
+
+for (let [initialState, initialUrl] of Object.entries(INITIAL_URLS)) {
+ let row = table.insertRow();
+ row.insertCell().textContent = initialState;
+ for (let [finalState, finalUrl] of Object.entries(FINAL_URLS)) {
+ let cell = row.insertCell();
+ let img = document.createElement("img");
+ img.src = initialUrl;
+ async_test(t => {
+ let eventWatcher = new EventWatcher(t, img, ["load", "error"]);
+ eventWatcher.wait_for(EXPECTED_LOADEND_EVENT[initialState])
+ .then(_ => {
+ window.setTimeout(_ => img.src = finalUrl);
+ return eventWatcher.wait_for(EXPECTED_LOADEND_EVENT[finalState]);
+ })
+ .then(t.step_func_done(_ => {
+ assert_equals(img.clientWidth, EXPECTED_WIDTH[finalState],
+ "Image has incorrect width for the expected final state.");
+ }));
+ }, "State transition " + initialState + " to " + finalState);
+ cell.append(img);
+ }
+}
+document.body.append(table);
+</script>

Powered by Google App Engine
This is Rietveld 408576698