Bug 1558098 - postMessage to a redundant service worker should drop silently r=dom-worker-reviewers,asuth

Differential Revision: https://phabricator.services.mozilla.com/D162596
This commit is contained in:
Joshua Marshall 2022-11-22 22:02:44 +00:00
parent 1fc6ac5d91
commit aa87b835c9
2 changed files with 7 additions and 3 deletions

View File

@ -236,8 +236,14 @@ void ServiceWorker::GetScriptURL(nsString& aURL) const {
void ServiceWorker::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
const Sequence<JSObject*>& aTransferable,
ErrorResult& aRv) {
// Step 6.1 of
// https://w3c.github.io/ServiceWorker/#service-worker-postmessage-options
// invokes
// https://w3c.github.io/ServiceWorker/#run-service-worker
// which returns failure in step 3 if the ServiceWorker state is redundant.
// This will result in the "in parallel" step 6.1 of postMessage itself early
// returning without starting the ServiceWorker and without throwing an error.
if (State() == ServiceWorkerState::Redundant) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}

View File

@ -1,5 +1,3 @@
[postmessage.https.html]
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[postMessage to a redundant worker]
expected: FAIL