fix(service-worker): PushEvent.data has to be decoded (#19764)
PushEvent.data is not the data object itself, but an instance representing the data in wire format, with methods to synchronously decode it to JSON, ArrayBuffer, etc. NGSW assumes all push data is in JSON format. PR Close #19764
This commit is contained in:
parent
396c2417d9
commit
3bcf0cf472
|
@ -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<void> {
|
||||
|
|
|
@ -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 {}
|
||||
|
|
Loading…
Reference in New Issue