ladybird/Tests/LibWeb/Text/input/wpt-import/url/data-uri-fragment.html
Shannon Booth 51102254b5 LibWeb/HTML: Scroll to the fragment before loading the document
Otherwise nowhere ends up scrolling to the fragment specified by the
fragment in document's URL. This fixes ladybird scrolling to the
correct location in the document when navigating to a link that
has a fragment, e.g:

https://html.spec.whatwg.org/multipage/browsing-the-web.html#try-to-scroll-to-the-fragment

As well as use of the :target selector.
2025-01-15 12:43:48 +00:00

34 lines
1.2 KiB
HTML

<!DOCTYPE html>
<meta charset="utf-8">
<title>Data URI parsing of fragments</title>
<link rel="help" href="https://url.spec.whatwg.org/">
<meta name="assert" content="Fragments should not be included as part of a data URI's body">
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<iframe id="iframe"></iframe>
<script>
const IFRAME_DATA_SRC = `data:text/html,
<style>:target { color: green; }<\/style>
<script>window.addEventListener('load', function() {
const data = {
foo_matches_target_selector: document.getElementById('foo').matches(':target'),
body_html: document.body.innerHTML,
};
parent.postMessage(data, '*');
});<\/script>
<p id="foo">This should be the only visible text.</p>#foo`.replace('\n', '');
async_test(function(t) {
window.addEventListener("message", t.step_func_done(function(event) {
assert_true(event.data.foo_matches_target_selector);
assert_equals(event.data.body_html,
'<p id="foo">This should be the only visible text.</p>');
}));
const iframe = document.getElementById("iframe");
iframe.src = IFRAME_DATA_SRC;
});
</script>