diff --git a/packages/service-worker/worker/src/driver.ts b/packages/service-worker/worker/src/driver.ts index 7837b45d89..a80b69ede5 100644 --- a/packages/service-worker/worker/src/driver.ts +++ b/packages/service-worker/worker/src/driver.ts @@ -224,7 +224,7 @@ export class Driver implements Debuggable, UpdateSource { } // Handle the push and keep the SW alive until it's handled. - msg.waitUntil(this.handlePush(msg.data)); + msg.waitUntil(this.handlePush(msg.data.json())); } private async handleMessage(msg: MsgAny&{action: string}, from: Client): Promise { diff --git a/packages/service-worker/worker/testing/scope.ts b/packages/service-worker/worker/testing/scope.ts index bb97a2deaa..2599c04a36 100644 --- a/packages/service-worker/worker/testing/scope.ts +++ b/packages/service-worker/worker/testing/scope.ts @@ -324,7 +324,10 @@ class MockMessageEvent extends MockExtendableEvent { } class MockPushEvent extends MockExtendableEvent { - constructor(readonly data: Object) { super(); } + constructor(private _data: Object) { super(); } + data = { + json: () => this._data, + }; } class MockInstallEvent extends MockExtendableEvent {}