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

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: Initial draft. 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..7e83d4a8261dace50a400b645db0922567a5e913
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/subresource_filter/image-allow-disallow-transitions.html
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<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 numPendingImages =
+ Object.keys(INITIAL_URLS).length * Object.keys(FINAL_URLS).length;
+
+if (window.testRunner) {
+ testRunner.setDisallowedSubresourcePathSuffixes(["gamma.png", "delta.png"]);
+ testRunner.waitUntilDone();
+}
+
+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 of Object.keys(INITIAL_URLS)) {
+ let row = table.insertRow();
+ row.insertCell().textContent = initialState;
+ for (let finalState of Object.keys(FINAL_URLS)) {
+ let cell = row.insertCell();
+ let img = document.createElement("img");
+ img.src = INITIAL_URLS[initialState];
+ window.addEventListener("load", _ => {
+ img.src = FINAL_URLS[finalState];
+ img.onload = img.onerror = function() {
+ if (window.testRunner && --numPendingImages == 0)
+ testRunner.notifyDone();
+ };
+ });
+ cell.appendChild(img);
+ }
+}
+document.body.appendChild(table);
+</script>

Powered by Google App Engine
This is Rietveld 408576698