mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 20:59:16 +00:00
LibWeb: Allow changing the query of file:// URL via history.pushState()
The spec didn't match how other browsers behave, and we dutifully did what the spec said. A spec bug has been filed, so let's fix this locally for now with a FIXME.
This commit is contained in:
parent
faf097bb41
commit
e3408c4a7f
Notes:
github-actions[bot]
2024-08-06 14:34:16 +00:00
Author: https://github.com/awesomekling
Commit: e3408c4a7f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/993
3 changed files with 32 additions and 2 deletions
|
@ -0,0 +1,3 @@
|
|||
Good: changing the query via pushState()
|
||||
Good: threw on changing the filename via pushState()
|
||||
Good: going back to the original filename
|
|
@ -0,0 +1,24 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
asyncTest((done) => {
|
||||
try {
|
||||
history.pushState({}, null, "?tweaked");
|
||||
println("Good: changing the query via pushState()");
|
||||
} catch (e) {
|
||||
println("FAIL: Threw!");
|
||||
}
|
||||
try {
|
||||
history.pushState({}, null, "other.html");
|
||||
println("FAIL: Should have thrown!");
|
||||
} catch (e) {
|
||||
println("Good: threw on changing the filename via pushState()");
|
||||
}
|
||||
try {
|
||||
history.pushState({}, null, "History-pushState-change-query.html");
|
||||
println("Good: going back to the original filename");
|
||||
} catch (e) {
|
||||
println("FAIL: threw on going back to original filename");
|
||||
}
|
||||
done();
|
||||
});
|
||||
</script>
|
|
@ -148,9 +148,12 @@ bool can_have_its_url_rewritten(DOM::Document const& document, URL::URL const& t
|
|||
|
||||
// 4. If targetURL's scheme is "file", and targetURL and documentURL differ in their path component,
|
||||
// then return false. (Differences in query and fragment are allowed for file: URLs.)
|
||||
// FIXME: There's a bug in the spec here. We should return true if the scheme is "file" and the path components don't differ.
|
||||
// Spec bug: https://github.com/whatwg/html/issues/10551
|
||||
bool path_components_match = target_url.paths() == document_url.paths();
|
||||
if (target_url.scheme() == "file"sv && !path_components_match)
|
||||
return false;
|
||||
if (target_url.scheme() == "file"sv) {
|
||||
return path_components_match;
|
||||
}
|
||||
|
||||
// 5. If targetURL and documentURL differ in their path component or query components, then return false.
|
||||
// (Only differences in fragment are allowed for other types of URLs.)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue