diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/push/test/xpcshell/test_unregister_error.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/push/test/xpcshell/test_unregister_error.js')
-rw-r--r-- | dom/push/test/xpcshell/test_unregister_error.js | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/dom/push/test/xpcshell/test_unregister_error.js b/dom/push/test/xpcshell/test_unregister_error.js new file mode 100644 index 000000000..53d592918 --- /dev/null +++ b/dom/push/test/xpcshell/test_unregister_error.js @@ -0,0 +1,68 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +'use strict'; + +const {PushDB, PushService, PushServiceWebSocket} = serviceExports; + +const channelID = '00c7fa13-7b71-447d-bd27-a91abc09d1b2'; + +function run_test() { + do_get_profile(); + setPrefs(); + run_next_test(); +} + +add_task(function* test_unregister_error() { + let db = PushServiceWebSocket.newPushDB(); + do_register_cleanup(() => {return db.drop().then(_ => db.close());}); + yield db.put({ + channelID: channelID, + pushEndpoint: 'https://example.org/update/failure', + scope: 'https://example.net/page/failure', + originAttributes: '', + version: 1, + quota: Infinity, + }); + + let unregisterDone; + let unregisterPromise = new Promise(resolve => unregisterDone = resolve); + PushService.init({ + serverURI: "wss://push.example.org/", + db, + makeWebSocket(uri) { + return new MockWebSocket(uri, { + onHello(request) { + this.serverSendMsg(JSON.stringify({ + messageType: 'hello', + status: 200, + uaid: '083e6c17-1063-4677-8638-ab705aebebc2' + })); + }, + onUnregister(request) { + // The server is notified out-of-band. Since channels may be pruned, + // any failures are swallowed. + equal(request.channelID, channelID, 'Unregister: wrong channel ID'); + this.serverSendMsg(JSON.stringify({ + messageType: 'unregister', + status: 500, + error: 'omg, everything is exploding', + channelID + })); + unregisterDone(); + } + }); + } + }); + + yield PushService.unregister({ + scope: 'https://example.net/page/failure', + originAttributes: '', + }); + + let result = yield db.getByKeyID(channelID); + ok(!result, 'Deleted push record exists'); + + // Make sure we send a request to the server. + yield unregisterPromise; +}); |