| Stephen McGruer | 29bac74 | 2017-11-14 14:55:19 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <meta charset="utf-8"> |
| 3 | <title>Data URI parsing of fragments</title> |
| 4 | <link rel="help" href="https://url.spec.whatwg.org/"> |
| 5 | <meta name="assert" content="Fragments should not be included as part of a data URI's body"> |
| 6 | |
| 7 | <script src="/resources/testharness.js"></script> |
| 8 | <script src="/resources/testharnessreport.js"></script> |
| 9 | |
| 10 | <iframe id="iframe"></iframe> |
| 11 | |
| 12 | <script> |
| 13 | const IFRAME_DATA_SRC = `data:text/html, |
| 14 | <style>:target { color: green; }<\/style> |
| 15 | <script>window.addEventListener('load', function() { |
| 16 | const data = { |
| 17 | foo_matches_target_selector: document.getElementById('foo').matches(':target'), |
| 18 | body_html: document.body.innerHTML, |
| 19 | }; |
| 20 | parent.postMessage(data, '*'); |
| 21 | });<\/script> |
| 22 | <p id="foo">This should be the only visible text.</p>#foo`.replace('\n', ''); |
| 23 | |
| 24 | async_test(function(t) { |
| 25 | window.addEventListener("message", t.step_func_done(function(event) { |
| 26 | assert_true(event.data.foo_matches_target_selector); |
| 27 | assert_equals(event.data.body_html, |
| 28 | '<p id="foo">This should be the only visible text.</p>'); |
| 29 | })); |
| 30 | |
| 31 | const iframe = document.getElementById("iframe"); |
| 32 | iframe.src = IFRAME_DATA_SRC; |
| 33 | }); |
| 34 | </script> |