Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
navigator.storage.getDirectory()
fails in nested workers with an `I…
…nvalidStateError` https://bugs.webkit.org/show_bug.cgi?id=255458 rdar://108069396 Reviewed by Chris Dumez. WorkerStorageConnection assumes its Worker's loader is a Document, and thus posts tasks to main thread and asks for StorageConnection from its loader (WorkerLoaderProxy) directly. This is no longer true after nested worker is enabled -- the loader might be another Worker. Therefore it should get StorageConnection from the real main thread loader (via WorkerLoaderProxy::postTaskToLoader). Test: storage/storagemanager/nested-dedicated-workers.html * LayoutTests/TestExpectations: * LayoutTests/platform/wk2/TestExpectations: * LayoutTests/storage/storagemanager/nested-dedicated-workers-expected.txt: Added. * LayoutTests/storage/storagemanager/nested-dedicated-workers.html: Added. * LayoutTests/storage/storagemanager/resources/nested-dedicated-workers.js: Added. (nestedWorker.onmessage): (nestedWorker.onerror): * LayoutTests/storage/storagemanager/resources/nested-dedicated-workers2.js: Added. (navigator.storage.navigator.storage.estimate.then): (navigator.storage.catch): * Source/WebCore/Modules/storage/WorkerStorageConnection.cpp: (WebCore::WorkerStorageConnection::getPersisted): (WebCore::WorkerStorageConnection::getEstimate): (WebCore::WorkerStorageConnection::fileSystemGetDirectory): * Source/WebCore/workers/WorkerLoaderProxy.h: (WebCore::WorkerLoaderProxy::storageConnection): Deleted. * Source/WebCore/workers/WorkerMessagingProxy.cpp: (WebCore::WorkerMessagingProxy::storageConnection): Deleted. * Source/WebCore/workers/WorkerMessagingProxy.h: Canonical link: https://commits.webkit.org/263075@main
- Loading branch information
Showing
10 changed files
with
78 additions
and
29 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
12 changes: 12 additions & 0 deletions
12
LayoutTests/storage/storagemanager/nested-dedicated-workers-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,12 @@ | ||
[Worker] This test ensures StorageManager API works in nested dedicated workers. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
Starting worker: resources/nested-dedicated-workers.js | ||
PASS [Worker] estimate.quota is non-null. | ||
PASS [Worker] estimate.usage is non-null. | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
12 changes: 12 additions & 0 deletions
12
LayoutTests/storage/storagemanager/nested-dedicated-workers.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,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="../../resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
jsTestIsAsync = true; | ||
worker = startWorker('resources/nested-dedicated-workers.js'); | ||
</script> | ||
</body> | ||
</html> |
19 changes: 19 additions & 0 deletions
19
LayoutTests/storage/storagemanager/resources/nested-dedicated-workers.js
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,19 @@ | ||
if (this.importScripts) { | ||
importScripts('../../../resources/js-test.js'); | ||
} | ||
|
||
description("This test ensures StorageManager API works in nested dedicated workers."); | ||
|
||
var estimate = null; | ||
var nestedWorker = new Worker('nested-dedicated-workers2.js'); | ||
nestedWorker.onmessage = (event) => { | ||
estimate = event.data; | ||
shouldBeNonNull("estimate.quota"); | ||
shouldBeNonNull("estimate.usage"); | ||
finishJSTest(); | ||
}; | ||
|
||
nestedWorker.onerror = (event) => { | ||
testFailed('nestedWorker has error ' + event.message()); | ||
finishJSTest(); | ||
} |
9 changes: 9 additions & 0 deletions
9
LayoutTests/storage/storagemanager/resources/nested-dedicated-workers2.js
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,9 @@ | ||
if (navigator.storage) { | ||
navigator.storage.estimate().then((estimate) => { | ||
self.postMessage(estimate); | ||
}).catch((error) => { | ||
self.postMessage('fail'); | ||
}); | ||
} else { | ||
self.postMessage('navigator.storage is not available'); | ||
} |
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
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