| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/testharness.js"></script> |
| 3 <script src="../../../resources/testharnessreport.js"></script> |
| 4 <body> |
| 5 <iframe src="about:blank" id="nested"></iframe> |
| 6 <script type="text/javascript"> |
| 7 // Fallback content is implemented by means of shadow DOM, using a dumbed-down |
| 8 // HTMLImageElement instance inside to render the broken image icon. This inner |
| 9 // image element displays a hard-coded ImageResource, and has no 'src' attribute |
| 10 // so normally the `update image data` [1] algorithm is never invoked. |
| 11 // |
| 12 // However the `update image data` algorithm will be unconditionally invoked in |
| 13 // response to an image element (inner or not) being adopted [2], e.g. when a |
| 14 // subtree containing an image element (potentially in a shadow tree) is moved |
| 15 // across documents. |
| 16 // |
| 17 // In Blink, when 'src' is empty, as is the case for the inner fallback image, |
| 18 // the `update image data` algorithm will synchronously fail and create the |
| 19 // shadow tree to render fallback content. |
| 20 // |
| 21 // Therefore special care must be taken to prevent creating the shadow tree |
| 22 // for the inner fallback image itself, otherwise the recursive adoption |
| 23 // algorithm would reach those nodes in the newly created shadow tree next, and |
| 24 // the same thing would happen again and we end up with infinite nesting. |
| 25 // |
| 26 // [1]: https://html.spec.whatwg.org/multipage/embedded-content.html#update-the-
image-data |
| 27 // [2]: https://html.spec.whatwg.org/multipage/embedded-content.html#reacting-to
-dom-mutations |
| 28 |
| 29 var nestedDocument = document.getElementById("nested").contentDocument; |
| 30 |
| 31 promise_test(t => { |
| 32 let i = nestedDocument.createElement("img"); |
| 33 i.src = "non-existent/gives-404.png"; |
| 34 window.setTimeout(_ => nestedDocument.body.append(i)); |
| 35 |
| 36 let eventWatcher = new EventWatcher(t, i, [ "load", "error" ]); |
| 37 return eventWatcher.wait_for("error").then(_ => { |
| 38 window.setTimeout(_ => document.body.append(i)); |
| 39 return eventWatcher.wait_for("error").then(_ => { |
| 40 assert_equals(i.clientWidth, 20, "Fallback content should be displayed."); |
| 41 }); |
| 42 }); |
| 43 }, "Infinitely nested fallback content shadow trees should not be created, or th
is test will never terminate."); |
| 44 |
| 45 </script> |
| OLD | NEW |