Files
palemoon27/dom/push/PushClient.js
T
roytam1 f579c98b65 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1195755: Don't assert recursion depth sanity on Mac, because there is none. r=me (e25096acc1)
- Bug 1217940 - remove BindingUtils.h from CycleCollectedJSRuntime.cpp; r=mccr8 (012fad0b80)
- Bug 1118285 - The browser.newtab.url preference is abused and should be removed. (ca573649c6)
- Bug 1209591 - allow loadURI consumers to expose whether an error page was immediately loaded as result of an error, r=smaug,mak (c033d86f07)
- Bug 1167132 - Part 14: [NetworkManager] Move network information into a separate interface (NetStats). r=ethan (87acc048cc)
- Bug 1167132 - Part 15: [NetworkManager] Move network information into a separate interface (NetworkInterfaceList). r=echen (a2a96e481e)
- Bug 1205240 - Add JSON Validation code in order to prevent invalid file. r=seanlin (8c7261ba8c)
- Bug 1215429 - Add import statement in order to access file object in chrome code of TVSimulatorService. r=seanlin (5ba9e78581)
- Bug 1217093 - Remove for-each from dom/. r=smaug (5af3efbd62)
- var-let (576b2489ec)
- Bug 1183440 - Replaces Promise.defer() with the Promise constructor in push tests. r=kitcambridge (16dfaa59b3)
- Bug 1191453 - Drop subscriptions for a site when the user revokes push permissions. r=mt,MattN (5edd10e5ad)
- Bug 1159641, Part 1 - Skip the permission check in `pushManager.getSubscription()`. r=mt (d399c496d7)
- Bug 1159641, Part 2 - Use tasks in the Push permissions test. r=mt (132484c355)
- Bug 1206302 - Use DOMException for Push errors. r=mt (5a675714fa)
- Bug 1193365 - Disable push debug. r=kitcambridge (1dc20e69b0)
- Bug 1219063, Part 1 - Use transactions for updating Push subscription permissions. r=mt (8c28453942)
- Bug 1219063, Part 2 - Remove obsolete "push" permission. r=mt (84a36931cd)
- Bug 1217065 - Unconditionally ack incoming updates. r=dragana,benbangert (e0bfa4454f)
- Bug 1212593 - Fix PushService behavior when we are switching between push servers. r=kcambridge (0afa39e743)
- Bug 1206163 - Retry failed register requests on reconnect. r=dragana (6ed1258b15)
- Bug 1218591 - Reset the WebSocket retry counter when the server replies. r=dragana (64e800db60)
- Bug 1210943 - Drop subscriptions unconditionally if the UAID changes. r=benbangert (52f538a7de)
- Bug 1214366 - Part 1: Don't preprocess PushServiceWebSocket.jsm. r=kitcambridge (a78b9fc838)
- Bug 1214366 - Part 3: Use getLastVisited equivalent in PushService.jsm. r=kitcambridge,rnewman (bc7004ad32)
- Bug 1210896, Part 1 - Use Console.jsm to log Push errors. r=mt (04335cc37f)
- Bug 1216683 - For the WebSocket version unregister should return true even if we are offline. r=kitcambridge (0f6e397a03)
- Bug 1210896, Part 2 - Use JS errors to reject internal Push promises. r=mt (3546b2f7c8)
- Bug 1223481 - Use the "potentially trustworthy origin" helper to validate Push server URLs. r=dragana (0c21f551f3)
- Bug 1223202 - Only send subscription change events if the Push permission is granted. r=mt (afeaf0dceb)
- Bug 1201128 - Don't send channel IDs in the Push handshake. r=nsm (dbbadb5c16)
- var-let (a35cb6aeca)
- Bug 1210211 - Part 1: Delay updating push quota. r=kitcambridge (53f5735ff0)
- Bug 1210211 - Part 2: Notify Push service of visible notifications. r=baku (9182bcb7d1)
- Bug 1170115 - Use clear-origin-data to remove Push records. r=allstars.chh (47f1070bab)
- Bug 1211418 - Part 1: Ensure Data Consistency after Collision of SMS Segment. r=echen. (f2d5221984)
- Bug 1211418 - Part 2: Add Test Coverage for the Collision of SMS Segment. r=echen. (06f7ba7308)
- Bug 1159132 - Part 1: Use dun apn only when config ro.tethering.dun_required is set. r=echen (bbb4fd2798)
- Bug 1159132 - Part 2: Set ro.tethering.dun_required when running dun test case. r=echen (11fe9344be)
- Bug 1187262 - Let the flag 'Services.io.offline' reference the state of tethering. r=jjong (ee22fd9358)
- Bug 1148671 - ipv6 and dual stack support on Lollipop. r=hchang (a9f7dc570e)
- Bug 1173671 - just warn if we fail to remove old default routes. r=echen (b4ab24da9f)
- Bug 1175817 - [NetworkManager] remove old default routes explicitly. r=echen,smaug (3f9a0b98ab)
- Bug 1174998 - Part 1: add setMtu() support in NetworkService. r=echen,smaug (9621036470)
- Bug 1174998 - Part 2: Set MTU for connected network interfaces. r=echen (397c898942)
- Bug 1197667 - [NetworkManager] Part 1: add missing implementation for 'allNetworkInfo'. r=echen (a49fd3498b)
- Bug 1197667 - [NetworkManager] Part 2: add test case for 'allNetworkInfo'. r=echen (942a52b0d4)
- Bug 1057091 - Add USB tethring command supporting IPv6 outgoing interface. r=hchang (9210eb5a1d)
- Bug 1177236 - Usage alert doesn't work when tethering is enabled. r=ethan (4bdd8ae226)
- Bug 1168938 - Memory safety bug in NetworkUtils::postTetherInterfaceList. r=fabrice (97485ac95c)
- Bug 1138757 - Part 1: Fix the logic of checking invalid port in CDMA WAP Push. r=echen (68dac00e52)
- Bug 1138757 - Part 2: Add Test Coverage for CDMA Wap Push. r=echen (9d54278aa9)
- Bug 1209891 - Do Not Reply Read-Report if a MMS Message Was Marked from Unread to Read Multiple Times. r=echen (421550db06)
- var-let (2ed380bb64)
- bug 1175005: performance regression. backout_f081c464c1e2 (28e1ee74b9)
- Bug 1207665 - Block Intel GMA 3150 for d3d11/d2d on all drivers. (bug 1207665 part 1, r=jrmuizel). r=jrmuizel (bb8eac6fa8)
- Bug 1188105: Parse bad driver versions. r=botond (8c856cac36)
- Bug 1075089 - Move popup menu frame offset to LookAndFeel and fix default offset for OS X. r=Enn (e1f7d0c418)
- Bug 1134385. Delete main thread assertion in CompositorVsyncDispatcher. r=kats (0945e91185)
- some profiler stuff (d3d68abdad)
- Bug 1156283 - Avoid shutdown observer race when shutting down gfx on Mac. r=roc (f66195546b)
2023-01-21 00:07:37 +08:00

161 lines
4.8 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const Cr = Components.results;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGetter(this, "console", () => {
let {ConsoleAPI} = Cu.import("resource://gre/modules/Console.jsm", {});
return new ConsoleAPI({
maxLogLevelPref: "dom.push.loglevel",
prefix: "PushClient",
});
});
const kMessages = [
"PushService:Register:OK",
"PushService:Register:KO",
"PushService:Registration:OK",
"PushService:Registration:KO",
"PushService:Unregister:OK",
"PushService:Unregister:KO",
];
this.PushClient = function PushClient() {
console.debug("PushClient()");
this._cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]
.getService(Ci.nsISyncMessageSender);
this._requests = {};
this.addListeners();
};
PushClient.prototype = {
classID: Components.ID("{16042199-bec0-484a-9640-25ecc0c0a149}"),
contractID: "@mozilla.org/push/PushClient;1",
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference,
Ci.nsIPushClient,
Ci.nsIMessageListener,]),
_getRandomId: function() {
return Cc["@mozilla.org/uuid-generator;1"]
.getService(Ci.nsIUUIDGenerator).generateUUID().toString();
},
addRequest: function(data) {
let id = this._getRandomId();
this._requests[id] = data;
return id;
},
takeRequest: function(requestId) {
let d = this._requests[requestId];
delete this._requests[requestId];
return d;
},
addListeners: function() {
for (let message of kMessages) {
this._cpmm.addWeakMessageListener(message, this);
}
},
subscribe: function(scope, principal, callback) {
console.debug("subscribe()", scope);
let requestId = this.addRequest(callback);
this._cpmm.sendAsyncMessage("Push:Register", {
scope: scope,
requestID: requestId,
}, null, principal);
},
unsubscribe: function(scope, principal, callback) {
console.debug("unsubscribe()", scope);
let requestId = this.addRequest(callback);
this._cpmm.sendAsyncMessage("Push:Unregister", {
scope: scope,
requestID: requestId,
}, null, principal);
},
getSubscription: function(scope, principal, callback) {
console.debug("getSubscription()", scope);
let requestId = this.addRequest(callback);
console.debug("getSubscription: Going to send", scope, principal,
requestId);
this._cpmm.sendAsyncMessage("Push:Registration", {
scope: scope,
requestID: requestId,
}, null, principal);
},
_deliverPushEndpoint: function(request, registration) {
if (!registration) {
request.onPushEndpoint(Cr.NS_OK, "", 0, null);
return;
}
if (registration.p256dhKey) {
let key = new Uint8Array(registration.p256dhKey);
request.onPushEndpoint(Cr.NS_OK,
registration.pushEndpoint,
key.length,
key);
return;
}
request.onPushEndpoint(Cr.NS_OK, registration.pushEndpoint, 0, null);
},
receiveMessage: function(aMessage) {
console.debug("receiveMessage()", aMessage);
let json = aMessage.data;
let request = this.takeRequest(json.requestID);
if (!request) {
console.error("receiveMessage: Unknown request ID", json.requestID);
return;
}
switch (aMessage.name) {
case "PushService:Register:OK":
case "PushService:Registration:OK":
this._deliverPushEndpoint(request, json.result);
break;
case "PushService:Register:KO":
case "PushService:Registration:KO":
request.onPushEndpoint(Cr.NS_ERROR_FAILURE, "", 0, null);
break;
case "PushService:Unregister:OK":
if (typeof json.result !== "boolean") {
console.error("receiveMessage: Expected boolean for unregister response",
json.result);
request.onUnsubscribe(Cr.NS_ERROR_FAILURE, false);
return;
}
request.onUnsubscribe(Cr.NS_OK, json.result);
break;
case "PushService:Unregister:KO":
request.onUnsubscribe(Cr.NS_ERROR_FAILURE, false);
break;
default:
console.error("receiveMessage: NOT IMPLEMENTED!", aMessage.name);
}
},
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([PushClient]);