Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Throw when constructing a SharedWorker in a detached document
https://bugs.webkit.org/show_bug.cgi?id=258477 rdar://110231627 Reviewed by Sihui Liu and Brent Fulgham. Throw an exception when constructing a SharedWorker in a detached iframe, similarly to what Chrome and Firefox are already doing. Previously, we would successfully create the SharedWorker but the topOrigin would be wrong in the case of a third-party iframe and we would hit an assertion later on. * LayoutTests/http/tests/workers/shared/resources/start-worker-detached-frame-iframe.html: Added. * LayoutTests/http/tests/workers/shared/start-worker-detached-frame-expected.txt: Added. * LayoutTests/http/tests/workers/shared/start-worker-detached-frame.html: Added. * Source/WebCore/workers/shared/SharedWorker.cpp: (WebCore::SharedWorker::create): Canonical link: https://commits.webkit.org/265483@main
- Loading branch information
Showing
4 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
LayoutTests/http/tests/workers/shared/resources/start-worker-detached-frame-iframe.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,15 @@ | ||
<!DOCTYPE html> | ||
<script> | ||
onload = () => { | ||
let parentWindow = window.parent; | ||
// Detach iframe. | ||
parentWindow.document.getElementById("testFrame").remove(); | ||
try { | ||
new SharedWorker('../../navigation/resources/shared-worker-script.js'); | ||
parentWindow.testFailed("Starting the shared worker in a detached iframe did not throw an exception"); | ||
} catch (e) { | ||
parentWindow.testPassed("Starting the shared worker in a detached iframe threw an exception: " + e); | ||
} | ||
parentWindow.finishJSTest(); | ||
}; | ||
</script> |
10 changes: 10 additions & 0 deletions
10
LayoutTests/http/tests/workers/shared/start-worker-detached-frame-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 @@ | ||
Tests starting a shared worker in a frame that is already detached. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS Starting the shared worker in a detached iframe threw an exception: InvalidStateError: No browsing context | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
11 changes: 11 additions & 0 deletions
11
LayoutTests/http/tests/workers/shared/start-worker-detached-frame.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,11 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
<script> | ||
description("Tests starting a shared worker in a frame that is already detached."); | ||
jsTestIsAsync = true; | ||
</script> | ||
<iframe id="testFrame" src="resources/start-worker-detached-frame-iframe.html"></iframe> | ||
</body> | ||
</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