Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick e9dd88d. rdar://problem/105158419
window.onload is repeatedly re-executed when changing URL fragment during onload https://bugs.webkit.org/show_bug.cgi?id=252931 rdar://105158419 Reviewed by Chris Dumez. When a cross-origin iframe changes its fragment identifier while its load event is being processed, we end up in a state where we will continually re-fire window.onload. We should fix this by only firing the load event on the frame's owner element. This still addresses the concern the original change fixed (259384@main), but without needing to always re-fire the window load event. * LayoutTests/http/tests/navigation/cross-origin-iframe-location-hash-reexecute-onload-expected.txt: Added. * LayoutTests/http/tests/navigation/cross-origin-iframe-location-hash-reexecute-onload.html: Added. * LayoutTests/http/tests/navigation/resources/change-location-hash-onload.html: Added. * Source/WebCore/loader/FrameLoader.cpp: (WebCore::FrameLoader::loadInSameDocument): Canonical link: https://commits.webkit.org/260860@main Canonical link: https://commits.webkit.org/259548.306@safari-7615-branch
- Loading branch information
1 parent
55109fa
commit bb40c5b
Showing
4 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
...sts/http/tests/navigation/cross-origin-iframe-location-hash-reexecute-onload-expected.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,10 @@ | ||
This tests that the load event is only fired twice when the location hash is changed in an embedded iframe's window.load. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS onload fired twice. | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
27 changes: 27 additions & 0 deletions
27
LayoutTests/http/tests/navigation/cross-origin-iframe-location-hash-reexecute-onload.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,27 @@ | ||
<html> | ||
<head> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
description("This tests that the load event is only fired twice when the location hash is changed in an embedded iframe's window.load."); | ||
jsTestIsAsync = true; | ||
|
||
let onloadCount = 0; | ||
|
||
window.addEventListener("message", () => { | ||
if (onloadCount == 2) | ||
testPassed("onload fired twice."); | ||
else | ||
testFailed("onload fired " + onloadCount + " time(s)."); | ||
|
||
finishJSTest(); | ||
}); | ||
|
||
function onloadFired() { | ||
onloadCount++; | ||
} | ||
</script> | ||
<iframe src="http://localhost:8000/navigation/resources/change-location-hash-onload.html" onload="onloadFired()"></iframe> | ||
</body> | ||
</html> |
8 changes: 8 additions & 0 deletions
8
LayoutTests/http/tests/navigation/resources/change-location-hash-onload.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,8 @@ | ||
<html> | ||
<script> | ||
window.onload = () => { | ||
window.location.hash = Math.random(); | ||
window.parent.postMessage("hashchange", "*"); | ||
} | ||
</script> | ||
</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