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

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/HTMLImageElement/fallback-image-moved-across-documents.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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/subresource_filter/image-allow-disallow-transitions.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/dom/HTMLImageElement/fallback-image-moved-across-documents.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/HTMLImageElement/fallback-image-moved-across-documents.html b/third_party/WebKit/LayoutTests/fast/dom/HTMLImageElement/fallback-image-moved-across-documents.html
new file mode 100644
index 0000000000000000000000000000000000000000..11017f40f744ec60f101653997b4afc40b7811f0
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/dom/HTMLImageElement/fallback-image-moved-across-documents.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<body>
+<iframe src="about:blank" id="nested"></iframe>
+<script type="text/javascript">
+// Fallback content is implemented by means of shadow DOM, using a dumbed-down
+// HTMLImageElement instance inside to render the broken image icon. This inner
+// image element displays a hard-coded ImageResource, and has no 'src' attribute
+// so normally the `update image data` [1] algorithm is never invoked.
+//
+// However the `update image data` algorithm will be unconditionally invoked in
+// response to an image element (inner or not) being adopted [2], e.g. when a
+// subtree containing an image element (potentially in a shadow tree) is moved
+// across documents.
+//
+// In Blink, when 'src' is empty, as is the case for the inner fallback image,
+// the `update image data` algorithm will synchronously fail and create the
+// shadow tree to render fallback content.
+//
+// Therefore special care must be taken to prevent creating the shadow tree
+// for the inner fallback image itself, otherwise the recursive adoption
+// algorithm would reach those nodes in the newly created shadow tree next, and
+// the same thing would happen again and we end up with infinite nesting.
+//
+// [1]: https://html.spec.whatwg.org/multipage/embedded-content.html#update-the-image-data
+// [2]: https://html.spec.whatwg.org/multipage/embedded-content.html#reacting-to-dom-mutations
+
+var nestedDocument = document.getElementById("nested").contentDocument;
+
+promise_test(t => {
+ let i = nestedDocument.createElement("img");
+ i.src = "non-existent/gives-404.png";
+ window.setTimeout(_ => nestedDocument.body.append(i));
+
+ let eventWatcher = new EventWatcher(t, i, [ "load", "error" ]);
+ return eventWatcher.wait_for("error").then(_ => {
+ window.setTimeout(_ => document.body.append(i));
+ return eventWatcher.wait_for("error").then(_ => {
+ assert_equals(i.clientWidth, 20, "Fallback content should be displayed.");
+ });
+ });
+}, "Infinitely nested fallback content shadow trees should not be created, or this test will never terminate.");
+
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/subresource_filter/image-allow-disallow-transitions.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698