-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb/HTML: Scroll to the fragment before loading the document
Otherwise nowhere may end up scrolling to the fragment to set the target element for a document before script can observe it. This also 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
- Loading branch information
1 parent
b43bb24
commit e3bb4b4
Showing
4 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
Tests/LibWeb/Text/expected/wpt-import/url/data-uri-fragment.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Harness status: OK | ||
|
||
Found 1 tests | ||
|
||
1 Pass | ||
Pass Data URI parsing of fragments |
34 changes: 34 additions & 0 deletions
34
Tests/LibWeb/Text/input/wpt-import/url/data-uri-fragment.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!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> |