let scopes = [];
let notifyPromise = promiseObserverNotification(
PushServiceComponent.pushTopic,
(subject, data) => scopes.push(data) == 2
);
let ackDone;
let ackPromise = new Promise(
resolve => (ackDone = after(records.length, resolve))
);
PushService.init({
serverURI: "wss://push.example.org/",
db: makeStub(db, {
getByKeyID(prev, channelID) { if (channelID == "3c3930ba-44de-40dc-a7ca-8a133ec1a866") { return Promise.reject("splines not reticulated");
} return prev.call(this, channelID);
},
}),
makeWebSocket(uri) { returnnew MockWebSocket(uri, {
onHello() { this.serverSendMsg(
JSON.stringify({
messageType: "hello",
status: 200,
uaid: userAgentID,
})
); this.serverSendMsg(
JSON.stringify({
messageType: "notification",
updates: records.map(({ channelID, version }) => ({
channelID,
version: ++version,
})),
})
);
}, // Should acknowledge all received updates, even if updating // IndexedDB fails.
onACK: ackDone,
});
},
});
await notifyPromise;
ok(
scopes.includes("https://example.com/a"), "Missing scope for notification A"
);
ok(
scopes.includes("https://example.com/c"), "Missing scope for notification C"
);
await ackPromise;
let aRecord = await db.getByIdentifiers({
scope: "https://example.com/a",
originAttributes,
});
equal(
aRecord.channelID, "f04f1e46-9139-4826-b2d1-9411b0821283", "Wrong channel ID for record A"
);
strictEqual(aRecord.version, 2, "Should return the new version for record A");
let bRecord = await db.getByIdentifiers({
scope: "https://example.com/b",
originAttributes,
});
equal(
bRecord.channelID, "3c3930ba-44de-40dc-a7ca-8a133ec1a866", "Wrong channel ID for record B"
);
strictEqual(
bRecord.version,
2, "Should return the previous version for record B"
);
let cRecord = await db.getByIdentifiers({
scope: "https://example.com/c",
originAttributes,
});
equal(
cRecord.channelID, "b63f7bef-0a0d-4236-b41e-086a69dfd316", "Wrong channel ID for record C"
);
strictEqual(cRecord.version, 4, "Should return the new version for record C");
});
Messung V0.5
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.