mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1369436, Load PushComponents.js after startup. r=lina,mconley
Differential Revision: https://phabricator.services.mozilla.com/D45079 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
936753e05c
commit
6a0111db7b
@ -36,8 +36,6 @@ const startupPhases = {
|
|||||||
"resource://gre/modules/MainProcessSingleton.jsm",
|
"resource://gre/modules/MainProcessSingleton.jsm",
|
||||||
"resource://gre/modules/XPCOMUtils.jsm",
|
"resource://gre/modules/XPCOMUtils.jsm",
|
||||||
"resource://gre/modules/Services.jsm",
|
"resource://gre/modules/Services.jsm",
|
||||||
// Bugs to fix: The following components shouldn't be initialized that early.
|
|
||||||
"resource://gre/modules/PushComponents.jsm", // bug 1369436
|
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -95,6 +93,7 @@ const startupPhases = {
|
|||||||
"resource://gre/modules/FxAccountsStorage.jsm",
|
"resource://gre/modules/FxAccountsStorage.jsm",
|
||||||
"resource://gre/modules/PlacesBackups.jsm",
|
"resource://gre/modules/PlacesBackups.jsm",
|
||||||
"resource://gre/modules/PlacesSyncUtils.jsm",
|
"resource://gre/modules/PlacesSyncUtils.jsm",
|
||||||
|
"resource://gre/modules/PushComponents.jsm",
|
||||||
"resource://gre/modules/Sqlite.jsm",
|
"resource://gre/modules/Sqlite.jsm",
|
||||||
]),
|
]),
|
||||||
services: new Set([
|
services: new Set([
|
||||||
|
@ -20,6 +20,13 @@ ChromeUtils.defineModuleGetter(
|
|||||||
"resource://gre/modules/ActorManagerParent.jsm"
|
"resource://gre/modules/ActorManagerParent.jsm"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
XPCOMUtils.defineLazyServiceGetter(
|
||||||
|
this,
|
||||||
|
"PushService",
|
||||||
|
"@mozilla.org/push/Service;1",
|
||||||
|
"nsIPushService"
|
||||||
|
);
|
||||||
|
|
||||||
const PREF_PDFJS_ENABLED_CACHE_STATE = "pdfjs.enabledCache.state";
|
const PREF_PDFJS_ENABLED_CACHE_STATE = "pdfjs.enabledCache.state";
|
||||||
|
|
||||||
let ACTORS = {
|
let ACTORS = {
|
||||||
@ -1998,6 +2005,11 @@ BrowserGlue.prototype = {
|
|||||||
this._togglePermissionPromptTelemetry();
|
this._togglePermissionPromptTelemetry();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Begin listening for incoming push messages.
|
||||||
|
Services.tm.idleDispatchToMainThread(() => {
|
||||||
|
PushService.ensureReady();
|
||||||
|
});
|
||||||
|
|
||||||
Services.tm.idleDispatchToMainThread(() => {
|
Services.tm.idleDispatchToMainThread(() => {
|
||||||
this._recordContentBlockingTelemetry();
|
this._recordContentBlockingTelemetry();
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,2 @@
|
|||||||
category app-startup PushServiceParent @mozilla.org/push/Service;1 process=main
|
|
||||||
|
|
||||||
# For immediate loading of PushService instead of delayed loading.
|
# For immediate loading of PushService instead of delayed loading.
|
||||||
category android-push-service PushServiceParent @mozilla.org/push/Service;1 process=main
|
category android-push-service PushServiceParent @mozilla.org/push/Service;1 process=main
|
||||||
|
@ -69,7 +69,7 @@ PushServiceBase.prototype = {
|
|||||||
subscriptionChangeTopic: OBSERVER_TOPIC_SUBSCRIPTION_CHANGE,
|
subscriptionChangeTopic: OBSERVER_TOPIC_SUBSCRIPTION_CHANGE,
|
||||||
subscriptionModifiedTopic: OBSERVER_TOPIC_SUBSCRIPTION_MODIFIED,
|
subscriptionModifiedTopic: OBSERVER_TOPIC_SUBSCRIPTION_MODIFIED,
|
||||||
|
|
||||||
_handleReady() {},
|
ensureReady() {},
|
||||||
|
|
||||||
_addListeners() {
|
_addListeners() {
|
||||||
for (let message of this._messages) {
|
for (let message of this._messages) {
|
||||||
@ -82,18 +82,9 @@ PushServiceBase.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
observe(subject, topic, data) {
|
observe(subject, topic, data) {
|
||||||
if (topic === "app-startup") {
|
|
||||||
Services.obs.addObserver(this, "sessionstore-windows-restored", true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (topic === "sessionstore-windows-restored") {
|
|
||||||
Services.obs.removeObserver(this, "sessionstore-windows-restored");
|
|
||||||
this._handleReady();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (topic === "android-push-service") {
|
if (topic === "android-push-service") {
|
||||||
// Load PushService immediately.
|
// Load PushService immediately.
|
||||||
this._handleReady();
|
this.ensureReady();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -265,7 +256,7 @@ Object.assign(PushServiceParent.prototype, {
|
|||||||
.catch(Cu.reportError);
|
.catch(Cu.reportError);
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleReady() {
|
ensureReady() {
|
||||||
this.service.init();
|
this.service.init();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ XPCOMUtils.defineLazyGetter(this, "gDOMBundle", () =>
|
|||||||
|
|
||||||
XPCOMUtils.defineLazyGlobalGetters(this, ["crypto"]);
|
XPCOMUtils.defineLazyGlobalGetters(this, ["crypto"]);
|
||||||
|
|
||||||
const EXPORTED_SYMBOLS = ["PushCrypto", "concatArray"];
|
const EXPORTED_SYMBOLS = ["PushCrypto"];
|
||||||
|
|
||||||
const UTF8 = new TextEncoder("utf-8");
|
const UTF8 = new TextEncoder("utf-8");
|
||||||
|
|
||||||
@ -603,6 +603,8 @@ class aesgcm128Decoder extends OldSchemeDecoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var PushCrypto = {
|
var PushCrypto = {
|
||||||
|
concatArray,
|
||||||
|
|
||||||
generateAuthenticationSecret() {
|
generateAuthenticationSecret() {
|
||||||
return crypto.getRandomValues(new Uint8Array(16));
|
return crypto.getRandomValues(new Uint8Array(16));
|
||||||
},
|
},
|
||||||
|
@ -20,22 +20,6 @@ const { XPCOMUtils } = ChromeUtils.import(
|
|||||||
|
|
||||||
var PushServiceWebSocket, PushServiceHttp2;
|
var PushServiceWebSocket, PushServiceHttp2;
|
||||||
|
|
||||||
const CONNECTION_PROTOCOLS = (function() {
|
|
||||||
if ("android" != AppConstants.MOZ_WIDGET_TOOLKIT) {
|
|
||||||
({ PushServiceWebSocket } = ChromeUtils.import(
|
|
||||||
"resource://gre/modules/PushServiceWebSocket.jsm"
|
|
||||||
));
|
|
||||||
({ PushServiceHttp2 } = ChromeUtils.import(
|
|
||||||
"resource://gre/modules/PushServiceHttp2.jsm"
|
|
||||||
));
|
|
||||||
return [PushServiceWebSocket, PushServiceHttp2];
|
|
||||||
}
|
|
||||||
const { PushServiceAndroidGCM } = ChromeUtils.import(
|
|
||||||
"resource://gre/modules/PushServiceAndroidGCM.jsm"
|
|
||||||
);
|
|
||||||
return [PushServiceAndroidGCM];
|
|
||||||
})();
|
|
||||||
|
|
||||||
XPCOMUtils.defineLazyServiceGetter(
|
XPCOMUtils.defineLazyServiceGetter(
|
||||||
this,
|
this,
|
||||||
"gPushNotifier",
|
"gPushNotifier",
|
||||||
@ -58,6 +42,24 @@ ChromeUtils.defineModuleGetter(
|
|||||||
"PushCrypto",
|
"PushCrypto",
|
||||||
"resource://gre/modules/PushCrypto.jsm"
|
"resource://gre/modules/PushCrypto.jsm"
|
||||||
);
|
);
|
||||||
|
ChromeUtils.defineModuleGetter(
|
||||||
|
this,
|
||||||
|
"PushServiceAndroidGCM",
|
||||||
|
"resource://gre/modules/PushServiceAndroidGCM.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
|
const CONNECTION_PROTOCOLS = (function() {
|
||||||
|
if ("android" != AppConstants.MOZ_WIDGET_TOOLKIT) {
|
||||||
|
({ PushServiceWebSocket } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/PushServiceWebSocket.jsm"
|
||||||
|
));
|
||||||
|
({ PushServiceHttp2 } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/PushServiceHttp2.jsm"
|
||||||
|
));
|
||||||
|
return [PushServiceWebSocket, PushServiceHttp2];
|
||||||
|
}
|
||||||
|
return [PushServiceAndroidGCM];
|
||||||
|
})();
|
||||||
|
|
||||||
const EXPORTED_SYMBOLS = ["PushService"];
|
const EXPORTED_SYMBOLS = ["PushService"];
|
||||||
|
|
||||||
@ -100,6 +102,25 @@ const CHANGING_SERVICE_EVENT = 1;
|
|||||||
const STOPPING_SERVICE_EVENT = 2;
|
const STOPPING_SERVICE_EVENT = 2;
|
||||||
const UNINIT_EVENT = 3;
|
const UNINIT_EVENT = 3;
|
||||||
|
|
||||||
|
// Returns the backend for the given server URI.
|
||||||
|
function getServiceForServerURI(uri) {
|
||||||
|
// Insecure server URLs are allowed for development and testing.
|
||||||
|
let allowInsecure = prefs.get("testing.allowInsecureServerURL");
|
||||||
|
if (AppConstants.MOZ_WIDGET_TOOLKIT == "android") {
|
||||||
|
if (uri.scheme == "https" || (allowInsecure && uri.scheme == "http")) {
|
||||||
|
return CONNECTION_PROTOCOLS;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (uri.scheme == "wss" || (allowInsecure && uri.scheme == "ws")) {
|
||||||
|
return PushServiceWebSocket;
|
||||||
|
}
|
||||||
|
if (uri.scheme == "https" || (allowInsecure && uri.scheme == "http")) {
|
||||||
|
return PushServiceHttp2;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotates an error with an XPCOM result code. We use this helper
|
* Annotates an error with an XPCOM result code. We use this helper
|
||||||
* instead of `Components.Exception` because the latter can assert in
|
* instead of `Components.Exception` because the latter can assert in
|
||||||
@ -408,14 +429,12 @@ var PushService = {
|
|||||||
_findService(serverURL) {
|
_findService(serverURL) {
|
||||||
console.debug("findService()");
|
console.debug("findService()");
|
||||||
|
|
||||||
let uri;
|
|
||||||
let service;
|
|
||||||
|
|
||||||
if (!serverURL) {
|
if (!serverURL) {
|
||||||
console.warn("findService: No dom.push.serverURL found");
|
console.warn("findService: No dom.push.serverURL found");
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let uri;
|
||||||
try {
|
try {
|
||||||
uri = Services.io.newURI(serverURL);
|
uri = Services.io.newURI(serverURL);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -427,12 +446,7 @@ var PushService = {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let connProtocol of CONNECTION_PROTOCOLS) {
|
let service = getServiceForServerURI(uri);
|
||||||
if (connProtocol.validServerURI(uri)) {
|
|
||||||
service = connProtocol;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return [service, uri];
|
return [service, uri];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -79,25 +79,6 @@ var PushServiceAndroidGCM = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
validServerURI(serverURI) {
|
|
||||||
if (!serverURI) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serverURI.scheme == "https") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (serverURI.scheme == "http") {
|
|
||||||
// Allow insecure server URLs for development and testing.
|
|
||||||
return !!prefs.get("testing.allowInsecureServerURL");
|
|
||||||
}
|
|
||||||
console.info(
|
|
||||||
"Unsupported Android GCM dom.push.serverURL scheme",
|
|
||||||
serverURI.scheme
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
observe(subject, topic, data) {
|
observe(subject, topic, data) {
|
||||||
switch (topic) {
|
switch (topic) {
|
||||||
case "nsPref:changed":
|
case "nsPref:changed":
|
||||||
|
@ -18,7 +18,7 @@ const { clearTimeout, setTimeout } = ChromeUtils.import(
|
|||||||
"resource://gre/modules/Timer.jsm"
|
"resource://gre/modules/Timer.jsm"
|
||||||
);
|
);
|
||||||
|
|
||||||
const { PushCrypto, concatArray } = ChromeUtils.import(
|
const { PushCrypto } = ChromeUtils.import(
|
||||||
"resource://gre/modules/PushCrypto.jsm"
|
"resource://gre/modules/PushCrypto.jsm"
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ PushChannelListener.prototype = {
|
|||||||
encryption: getHeaderField(aRequest, "Encryption"),
|
encryption: getHeaderField(aRequest, "Encryption"),
|
||||||
encoding: getHeaderField(aRequest, "Content-Encoding"),
|
encoding: getHeaderField(aRequest, "Content-Encoding"),
|
||||||
};
|
};
|
||||||
let msg = concatArray(this._message);
|
let msg = PushCrypto.concatArray(this._message);
|
||||||
|
|
||||||
this._mainListener._pushService._pushChannelOnStop(
|
this._mainListener._pushService._pushChannelOnStop(
|
||||||
this._mainListener.uri,
|
this._mainListener.uri,
|
||||||
@ -425,13 +425,6 @@ var PushServiceHttp2 = {
|
|||||||
return this._mainPushService !== null;
|
return this._mainPushService !== null;
|
||||||
},
|
},
|
||||||
|
|
||||||
validServerURI(serverURI) {
|
|
||||||
if (serverURI.scheme == "http") {
|
|
||||||
return !!prefs.getBoolPref("testing.allowInsecureServerURL", false);
|
|
||||||
}
|
|
||||||
return serverURI.scheme == "https";
|
|
||||||
},
|
|
||||||
|
|
||||||
async connect(broadcastListeners) {
|
async connect(broadcastListeners) {
|
||||||
let subscriptions = await this._mainPushService.getAllUnexpired();
|
let subscriptions = await this._mainPushService.getAllUnexpired();
|
||||||
this.startConnections(subscriptions);
|
this.startConnections(subscriptions);
|
||||||
|
@ -254,13 +254,6 @@ var PushServiceWebSocket = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
validServerURI(serverURI) {
|
|
||||||
if (serverURI.scheme == "ws") {
|
|
||||||
return !!prefs.get("testing.allowInsecureServerURL");
|
|
||||||
}
|
|
||||||
return serverURI.scheme == "wss";
|
|
||||||
},
|
|
||||||
|
|
||||||
get _UAID() {
|
get _UAID() {
|
||||||
return prefs.get("userAgentID");
|
return prefs.get("userAgentID");
|
||||||
},
|
},
|
||||||
|
@ -1,211 +0,0 @@
|
|||||||
/* Any copyright is dedicated to the Public Domain.
|
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const { PushDB, PushService, PushServiceHttp2 } = serviceExports;
|
|
||||||
|
|
||||||
var serverPort = -1;
|
|
||||||
|
|
||||||
function run_test() {
|
|
||||||
serverPort = getTestServerPort();
|
|
||||||
|
|
||||||
do_get_profile();
|
|
||||||
setPrefs({
|
|
||||||
"testing.allowInsecureServerURL": true,
|
|
||||||
});
|
|
||||||
// Set to allow the cert presented by our H2 server
|
|
||||||
var oldPref = Services.prefs.getIntPref(
|
|
||||||
"network.http.speculative-parallel-limit"
|
|
||||||
);
|
|
||||||
Services.prefs.setIntPref("network.http.speculative-parallel-limit", 0);
|
|
||||||
Services.prefs.setBoolPref("dom.push.enabled", true);
|
|
||||||
Services.prefs.setBoolPref("dom.push.connection.enabled", true);
|
|
||||||
|
|
||||||
trustHttp2CA();
|
|
||||||
|
|
||||||
Services.prefs.setIntPref("network.http.speculative-parallel-limit", oldPref);
|
|
||||||
|
|
||||||
run_next_test();
|
|
||||||
}
|
|
||||||
|
|
||||||
add_task(async function test_pushNotifications() {
|
|
||||||
// /pushNotifications/subscription1 will send a message with no rs and padding
|
|
||||||
// length 1.
|
|
||||||
// /pushNotifications/subscription2 will send a message with no rs and padding
|
|
||||||
// length 16.
|
|
||||||
// /pushNotifications/subscription3 will send a message with rs equal 24 and
|
|
||||||
// padding length 16.
|
|
||||||
// /pushNotifications/subscription4 will send a message with no rs and padding
|
|
||||||
// length 256.
|
|
||||||
|
|
||||||
let db = PushServiceHttp2.newPushDB();
|
|
||||||
registerCleanupFunction(() => {
|
|
||||||
return db.drop().then(_ => db.close());
|
|
||||||
});
|
|
||||||
|
|
||||||
var serverURL = "https://localhost:" + serverPort;
|
|
||||||
|
|
||||||
let records = [
|
|
||||||
{
|
|
||||||
subscriptionUri: serverURL + "/pushNotifications/subscription1",
|
|
||||||
pushEndpoint: serverURL + "/pushEndpoint1",
|
|
||||||
pushReceiptEndpoint: serverURL + "/pushReceiptEndpoint1",
|
|
||||||
scope: "https://example.com/page/1",
|
|
||||||
p256dhPublicKey:
|
|
||||||
"BPCd4gNQkjwRah61LpdALdzZKLLnU5UAwDztQ5_h0QsT26jk0IFbqcK6-JxhHAm-rsHEwy0CyVJjtnfOcqc1tgA",
|
|
||||||
p256dhPrivateKey: {
|
|
||||||
crv: "P-256",
|
|
||||||
d: "1jUPhzVsRkzV0vIzwL4ZEsOlKdNOWm7TmaTfzitJkgM",
|
|
||||||
ext: true,
|
|
||||||
key_ops: ["deriveBits"],
|
|
||||||
kty: "EC",
|
|
||||||
x: "8J3iA1CSPBFqHrUul0At3NkosudTlQDAPO1Dn-HRCxM",
|
|
||||||
y: "26jk0IFbqcK6-JxhHAm-rsHEwy0CyVJjtnfOcqc1tgA",
|
|
||||||
},
|
|
||||||
originAttributes: ChromeUtils.originAttributesToSuffix({
|
|
||||||
inIsolatedMozBrowser: false,
|
|
||||||
}),
|
|
||||||
quota: Infinity,
|
|
||||||
systemRecord: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
subscriptionUri: serverURL + "/pushNotifications/subscription2",
|
|
||||||
pushEndpoint: serverURL + "/pushEndpoint2",
|
|
||||||
pushReceiptEndpoint: serverURL + "/pushReceiptEndpoint2",
|
|
||||||
scope: "https://example.com/page/2",
|
|
||||||
p256dhPublicKey:
|
|
||||||
"BPnWyUo7yMnuMlyKtERuLfWE8a09dtdjHSW2lpC9_BqR5TZ1rK8Ldih6ljyxVwnBA-nygQHGRpEmu1jV5K8437E",
|
|
||||||
p256dhPrivateKey: {
|
|
||||||
crv: "P-256",
|
|
||||||
d: "lFm4nPsUKYgNGBJb5nXXKxl8bspCSp0bAhCYxbveqT4",
|
|
||||||
ext: true,
|
|
||||||
key_ops: ["deriveBits"],
|
|
||||||
kty: "EC",
|
|
||||||
x: "-dbJSjvIye4yXIq0RG4t9YTxrT1212MdJbaWkL38GpE",
|
|
||||||
y: "5TZ1rK8Ldih6ljyxVwnBA-nygQHGRpEmu1jV5K8437E",
|
|
||||||
},
|
|
||||||
originAttributes: ChromeUtils.originAttributesToSuffix({
|
|
||||||
inIsolatedMozBrowser: false,
|
|
||||||
}),
|
|
||||||
quota: Infinity,
|
|
||||||
systemRecord: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
subscriptionUri: serverURL + "/pushNotifications/subscription3",
|
|
||||||
pushEndpoint: serverURL + "/pushEndpoint3",
|
|
||||||
pushReceiptEndpoint: serverURL + "/pushReceiptEndpoint3",
|
|
||||||
scope: "https://example.com/page/3",
|
|
||||||
p256dhPublicKey:
|
|
||||||
"BDhUHITSeVrWYybFnb7ylVTCDDLPdQWMpf8gXhcWwvaaJa6n3YH8TOcH8narDF6t8mKVvg2ioLW-8MH5O4dzGcI",
|
|
||||||
p256dhPrivateKey: {
|
|
||||||
crv: "P-256",
|
|
||||||
d: "Q1_SE1NySTYzjbqgWwPgrYh7XRg3adqZLkQPsy319G8",
|
|
||||||
ext: true,
|
|
||||||
key_ops: ["deriveBits"],
|
|
||||||
kty: "EC",
|
|
||||||
x: "OFQchNJ5WtZjJsWdvvKVVMIMMs91BYyl_yBeFxbC9po",
|
|
||||||
y: "Ja6n3YH8TOcH8narDF6t8mKVvg2ioLW-8MH5O4dzGcI",
|
|
||||||
},
|
|
||||||
originAttributes: ChromeUtils.originAttributesToSuffix({
|
|
||||||
inIsolatedMozBrowser: false,
|
|
||||||
}),
|
|
||||||
quota: Infinity,
|
|
||||||
systemRecord: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
subscriptionUri: serverURL + "/pushNotifications/subscription4",
|
|
||||||
pushEndpoint: serverURL + "/pushEndpoint4",
|
|
||||||
pushReceiptEndpoint: serverURL + "/pushReceiptEndpoint4",
|
|
||||||
scope: "https://example.com/page/4",
|
|
||||||
p256dhPublicKey: ChromeUtils.base64URLDecode(
|
|
||||||
"BEcvDzkWCrUtjU_wygL98sbQCQrW1lY9irtgGnlCc4B0JJXLCHB9MTM73qD6GZYfL0YOvKo8XLOflh-J4dMGklU",
|
|
||||||
{
|
|
||||||
padding: "reject",
|
|
||||||
}
|
|
||||||
),
|
|
||||||
p256dhPrivateKey: {
|
|
||||||
crv: "P-256",
|
|
||||||
d: "fWi7tZaX0Pk6WnLrjQ3kiRq_g5XStL5pdH4pllNCqXw",
|
|
||||||
ext: true,
|
|
||||||
key_ops: ["deriveBits"],
|
|
||||||
kty: "EC",
|
|
||||||
x: "Ry8PORYKtS2NT_DKAv3yxtAJCtbWVj2Ku2AaeUJzgHQ",
|
|
||||||
y: "JJXLCHB9MTM73qD6GZYfL0YOvKo8XLOflh-J4dMGklU",
|
|
||||||
},
|
|
||||||
authenticationSecret: ChromeUtils.base64URLDecode(
|
|
||||||
"cwDVC1iwAn8E37mkR3tMSg",
|
|
||||||
{
|
|
||||||
padding: "reject",
|
|
||||||
}
|
|
||||||
),
|
|
||||||
originAttributes: ChromeUtils.originAttributesToSuffix({
|
|
||||||
inIsolatedMozBrowser: false,
|
|
||||||
}),
|
|
||||||
quota: Infinity,
|
|
||||||
systemRecord: true,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
for (let record of records) {
|
|
||||||
await db.put(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
let notifyPromise = Promise.all([
|
|
||||||
promiseObserverNotification(PushServiceComponent.pushTopic, function(
|
|
||||||
subject,
|
|
||||||
data
|
|
||||||
) {
|
|
||||||
var message = subject.QueryInterface(Ci.nsIPushMessage).data;
|
|
||||||
if (message && data == "https://example.com/page/1") {
|
|
||||||
equal(message.text(), "Some message", "decoded message is incorrect");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}),
|
|
||||||
promiseObserverNotification(PushServiceComponent.pushTopic, function(
|
|
||||||
subject,
|
|
||||||
data
|
|
||||||
) {
|
|
||||||
var message = subject.QueryInterface(Ci.nsIPushMessage).data;
|
|
||||||
if (message && data == "https://example.com/page/2") {
|
|
||||||
equal(message.text(), "Some message", "decoded message is incorrect");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}),
|
|
||||||
promiseObserverNotification(PushServiceComponent.pushTopic, function(
|
|
||||||
subject,
|
|
||||||
data
|
|
||||||
) {
|
|
||||||
var message = subject.QueryInterface(Ci.nsIPushMessage).data;
|
|
||||||
if (message && data == "https://example.com/page/3") {
|
|
||||||
equal(message.text(), "Some message", "decoded message is incorrect");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}),
|
|
||||||
promiseObserverNotification(PushServiceComponent.pushTopic, function(
|
|
||||||
subject,
|
|
||||||
data
|
|
||||||
) {
|
|
||||||
var message = subject.QueryInterface(Ci.nsIPushMessage).data;
|
|
||||||
if (message && data == "https://example.com/page/4") {
|
|
||||||
equal(
|
|
||||||
message.text(),
|
|
||||||
"Yet another message",
|
|
||||||
"decoded message is incorrect"
|
|
||||||
);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
|
|
||||||
PushService.init({
|
|
||||||
serverURI: serverURL,
|
|
||||||
db,
|
|
||||||
});
|
|
||||||
|
|
||||||
await notifyPromise;
|
|
||||||
});
|
|
@ -1,212 +0,0 @@
|
|||||||
/* Any copyright is dedicated to the Public Domain.
|
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const { PushDB, PushService, PushServiceHttp2 } = serviceExports;
|
|
||||||
|
|
||||||
var serverURL;
|
|
||||||
|
|
||||||
var serverPort = -1;
|
|
||||||
|
|
||||||
function run_test() {
|
|
||||||
serverPort = getTestServerPort();
|
|
||||||
|
|
||||||
do_get_profile();
|
|
||||||
|
|
||||||
serverURL = "https://localhost:" + serverPort;
|
|
||||||
|
|
||||||
run_next_test();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Connection will fail because of the certificates.
|
|
||||||
add_task(async function test_pushSubscriptionNoConnection() {
|
|
||||||
let db = PushServiceHttp2.newPushDB();
|
|
||||||
registerCleanupFunction(() => {
|
|
||||||
return db.drop().then(_ => db.close());
|
|
||||||
});
|
|
||||||
|
|
||||||
PushService.init({
|
|
||||||
serverURI: serverURL + "/pushSubscriptionNoConnection/subscribe",
|
|
||||||
db,
|
|
||||||
});
|
|
||||||
|
|
||||||
await Assert.rejects(
|
|
||||||
PushService.register({
|
|
||||||
scope: "https://example.net/page/invalid-response",
|
|
||||||
originAttributes: ChromeUtils.originAttributesToSuffix({
|
|
||||||
inIsolatedMozBrowser: false,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
/Registration error/,
|
|
||||||
"Expected error for not being able to establish connecion."
|
|
||||||
);
|
|
||||||
|
|
||||||
let record = await db.getAllKeyIDs();
|
|
||||||
ok(
|
|
||||||
record.length === 0,
|
|
||||||
"Should not store records when connection couldn't be established."
|
|
||||||
);
|
|
||||||
PushService.uninit();
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_TLS() {
|
|
||||||
// Set to allow the cert presented by our H2 server
|
|
||||||
var oldPref = Services.prefs.getIntPref(
|
|
||||||
"network.http.speculative-parallel-limit"
|
|
||||||
);
|
|
||||||
Services.prefs.setIntPref("network.http.speculative-parallel-limit", 0);
|
|
||||||
|
|
||||||
trustHttp2CA();
|
|
||||||
|
|
||||||
Services.prefs.setIntPref("network.http.speculative-parallel-limit", oldPref);
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_pushSubscriptionMissingLocation() {
|
|
||||||
let db = PushServiceHttp2.newPushDB();
|
|
||||||
registerCleanupFunction(() => {
|
|
||||||
return db.drop().then(_ => db.close());
|
|
||||||
});
|
|
||||||
|
|
||||||
PushService.init({
|
|
||||||
serverURI: serverURL + "/pushSubscriptionMissingLocation/subscribe",
|
|
||||||
db,
|
|
||||||
});
|
|
||||||
|
|
||||||
await Assert.rejects(
|
|
||||||
PushService.register({
|
|
||||||
scope: "https://example.net/page/invalid-response",
|
|
||||||
originAttributes: ChromeUtils.originAttributesToSuffix({
|
|
||||||
inIsolatedMozBrowser: false,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
/Registration error/,
|
|
||||||
"Expected error for the missing location header."
|
|
||||||
);
|
|
||||||
|
|
||||||
let record = await db.getAllKeyIDs();
|
|
||||||
ok(
|
|
||||||
record.length === 0,
|
|
||||||
"Should not store records when the location header is missing."
|
|
||||||
);
|
|
||||||
PushService.uninit();
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_pushSubscriptionMissingLink() {
|
|
||||||
let db = PushServiceHttp2.newPushDB();
|
|
||||||
registerCleanupFunction(() => {
|
|
||||||
return db.drop().then(_ => db.close());
|
|
||||||
});
|
|
||||||
|
|
||||||
PushService.init({
|
|
||||||
serverURI: serverURL + "/pushSubscriptionMissingLink/subscribe",
|
|
||||||
db,
|
|
||||||
});
|
|
||||||
|
|
||||||
await Assert.rejects(
|
|
||||||
PushService.register({
|
|
||||||
scope: "https://example.net/page/invalid-response",
|
|
||||||
originAttributes: ChromeUtils.originAttributesToSuffix({
|
|
||||||
inIsolatedMozBrowser: false,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
/Registration error/,
|
|
||||||
"Expected error for the missing link header."
|
|
||||||
);
|
|
||||||
|
|
||||||
let record = await db.getAllKeyIDs();
|
|
||||||
ok(
|
|
||||||
record.length === 0,
|
|
||||||
"Should not store records when a link header is missing."
|
|
||||||
);
|
|
||||||
PushService.uninit();
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_pushSubscriptionMissingLink1() {
|
|
||||||
let db = PushServiceHttp2.newPushDB();
|
|
||||||
registerCleanupFunction(() => {
|
|
||||||
return db.drop().then(_ => db.close());
|
|
||||||
});
|
|
||||||
|
|
||||||
PushService.init({
|
|
||||||
serverURI: serverURL + "/pushSubscriptionMissingLink1/subscribe",
|
|
||||||
db,
|
|
||||||
});
|
|
||||||
|
|
||||||
await Assert.rejects(
|
|
||||||
PushService.register({
|
|
||||||
scope: "https://example.net/page/invalid-response",
|
|
||||||
originAttributes: ChromeUtils.originAttributesToSuffix({
|
|
||||||
inIsolatedMozBrowser: false,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
/Registration error/,
|
|
||||||
"Expected error for the missing push endpoint."
|
|
||||||
);
|
|
||||||
|
|
||||||
let record = await db.getAllKeyIDs();
|
|
||||||
ok(
|
|
||||||
record.length === 0,
|
|
||||||
"Should not store records when the push endpoint is missing."
|
|
||||||
);
|
|
||||||
PushService.uninit();
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_pushSubscriptionLocationBogus() {
|
|
||||||
let db = PushServiceHttp2.newPushDB();
|
|
||||||
registerCleanupFunction(() => {
|
|
||||||
return db.drop().then(_ => db.close());
|
|
||||||
});
|
|
||||||
|
|
||||||
PushService.init({
|
|
||||||
serverURI: serverURL + "/pushSubscriptionLocationBogus/subscribe",
|
|
||||||
db,
|
|
||||||
});
|
|
||||||
|
|
||||||
await Assert.rejects(
|
|
||||||
PushService.register({
|
|
||||||
scope: "https://example.net/page/invalid-response",
|
|
||||||
originAttributes: ChromeUtils.originAttributesToSuffix({
|
|
||||||
inIsolatedMozBrowser: false,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
/Registration error/,
|
|
||||||
"Expected error for the bogus location"
|
|
||||||
);
|
|
||||||
|
|
||||||
let record = await db.getAllKeyIDs();
|
|
||||||
ok(
|
|
||||||
record.length === 0,
|
|
||||||
"Should not store records when location header is bogus."
|
|
||||||
);
|
|
||||||
PushService.uninit();
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_pushSubscriptionNot2xxCode() {
|
|
||||||
let db = PushServiceHttp2.newPushDB();
|
|
||||||
registerCleanupFunction(() => {
|
|
||||||
return db.drop().then(_ => db.close());
|
|
||||||
});
|
|
||||||
|
|
||||||
PushService.init({
|
|
||||||
serverURI: serverURL + "/pushSubscriptionNot201Code/subscribe",
|
|
||||||
db,
|
|
||||||
});
|
|
||||||
|
|
||||||
await Assert.rejects(
|
|
||||||
PushService.register({
|
|
||||||
scope: "https://example.net/page/invalid-response",
|
|
||||||
originAttributes: ChromeUtils.originAttributesToSuffix({
|
|
||||||
inIsolatedMozBrowser: false,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
/Registration error/,
|
|
||||||
"Expected error for not 201 responce code."
|
|
||||||
);
|
|
||||||
|
|
||||||
let record = await db.getAllKeyIDs();
|
|
||||||
ok(
|
|
||||||
record.length === 0,
|
|
||||||
"Should not store records when respons code is not 201."
|
|
||||||
);
|
|
||||||
});
|
|
@ -1,157 +0,0 @@
|
|||||||
/* Any copyright is dedicated to the Public Domain.
|
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const { PushDB, PushService, PushServiceHttp2 } = serviceExports;
|
|
||||||
|
|
||||||
var serverURL;
|
|
||||||
var serverPort = -1;
|
|
||||||
var pushEnabled;
|
|
||||||
var pushConnectionEnabled;
|
|
||||||
var db;
|
|
||||||
|
|
||||||
function run_test() {
|
|
||||||
serverPort = getTestServerPort();
|
|
||||||
|
|
||||||
do_get_profile();
|
|
||||||
pushEnabled = Services.prefs.getBoolPref("dom.push.enabled");
|
|
||||||
pushConnectionEnabled = Services.prefs.getBoolPref(
|
|
||||||
"dom.push.connection.enabled"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Set to allow the cert presented by our H2 server
|
|
||||||
var oldPref = Services.prefs.getIntPref(
|
|
||||||
"network.http.speculative-parallel-limit"
|
|
||||||
);
|
|
||||||
Services.prefs.setIntPref("network.http.speculative-parallel-limit", 0);
|
|
||||||
Services.prefs.setBoolPref("dom.push.enabled", true);
|
|
||||||
Services.prefs.setBoolPref("dom.push.connection.enabled", true);
|
|
||||||
|
|
||||||
trustHttp2CA();
|
|
||||||
|
|
||||||
Services.prefs.setIntPref("network.http.speculative-parallel-limit", oldPref);
|
|
||||||
|
|
||||||
serverURL = "https://localhost:" + serverPort;
|
|
||||||
|
|
||||||
run_next_test();
|
|
||||||
}
|
|
||||||
|
|
||||||
add_task(async function test_setup() {
|
|
||||||
db = PushServiceHttp2.newPushDB();
|
|
||||||
registerCleanupFunction(() => {
|
|
||||||
return db.drop().then(_ => db.close());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_pushSubscriptionSuccess() {
|
|
||||||
PushService.init({
|
|
||||||
serverURI: serverURL + "/pushSubscriptionSuccess/subscribe",
|
|
||||||
db,
|
|
||||||
});
|
|
||||||
|
|
||||||
let newRecord = await PushService.register({
|
|
||||||
scope: "https://example.org/1",
|
|
||||||
originAttributes: ChromeUtils.originAttributesToSuffix({
|
|
||||||
inIsolatedMozBrowser: false,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
var subscriptionUri = serverURL + "/pushSubscriptionSuccesss";
|
|
||||||
var pushEndpoint = serverURL + "/pushEndpointSuccess";
|
|
||||||
var pushReceiptEndpoint = serverURL + "/receiptPushEndpointSuccess";
|
|
||||||
equal(
|
|
||||||
newRecord.endpoint,
|
|
||||||
pushEndpoint,
|
|
||||||
"Wrong push endpoint in registration record"
|
|
||||||
);
|
|
||||||
|
|
||||||
equal(
|
|
||||||
newRecord.pushReceiptEndpoint,
|
|
||||||
pushReceiptEndpoint,
|
|
||||||
"Wrong push endpoint receipt in registration record"
|
|
||||||
);
|
|
||||||
|
|
||||||
let record = await db.getByKeyID(subscriptionUri);
|
|
||||||
equal(
|
|
||||||
record.subscriptionUri,
|
|
||||||
subscriptionUri,
|
|
||||||
"Wrong subscription ID in database record"
|
|
||||||
);
|
|
||||||
equal(
|
|
||||||
record.pushEndpoint,
|
|
||||||
pushEndpoint,
|
|
||||||
"Wrong push endpoint in database record"
|
|
||||||
);
|
|
||||||
equal(
|
|
||||||
record.pushReceiptEndpoint,
|
|
||||||
pushReceiptEndpoint,
|
|
||||||
"Wrong push endpoint receipt in database record"
|
|
||||||
);
|
|
||||||
equal(
|
|
||||||
record.scope,
|
|
||||||
"https://example.org/1",
|
|
||||||
"Wrong scope in database record"
|
|
||||||
);
|
|
||||||
|
|
||||||
PushService.uninit();
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_pushSubscriptionMissingLink2() {
|
|
||||||
PushService.init({
|
|
||||||
serverURI: serverURL + "/pushSubscriptionMissingLink2/subscribe",
|
|
||||||
db,
|
|
||||||
});
|
|
||||||
|
|
||||||
let newRecord = await PushService.register({
|
|
||||||
scope: "https://example.org/no_receiptEndpoint",
|
|
||||||
originAttributes: ChromeUtils.originAttributesToSuffix({
|
|
||||||
inIsolatedMozBrowser: false,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
var subscriptionUri = serverURL + "/subscriptionMissingLink2";
|
|
||||||
var pushEndpoint = serverURL + "/pushEndpointMissingLink2";
|
|
||||||
var pushReceiptEndpoint = "";
|
|
||||||
equal(
|
|
||||||
newRecord.endpoint,
|
|
||||||
pushEndpoint,
|
|
||||||
"Wrong push endpoint in registration record"
|
|
||||||
);
|
|
||||||
|
|
||||||
equal(
|
|
||||||
newRecord.pushReceiptEndpoint,
|
|
||||||
pushReceiptEndpoint,
|
|
||||||
"Wrong push endpoint receipt in registration record"
|
|
||||||
);
|
|
||||||
|
|
||||||
let record = await db.getByKeyID(subscriptionUri);
|
|
||||||
equal(
|
|
||||||
record.subscriptionUri,
|
|
||||||
subscriptionUri,
|
|
||||||
"Wrong subscription ID in database record"
|
|
||||||
);
|
|
||||||
equal(
|
|
||||||
record.pushEndpoint,
|
|
||||||
pushEndpoint,
|
|
||||||
"Wrong push endpoint in database record"
|
|
||||||
);
|
|
||||||
equal(
|
|
||||||
record.pushReceiptEndpoint,
|
|
||||||
pushReceiptEndpoint,
|
|
||||||
"Wrong push endpoint receipt in database record"
|
|
||||||
);
|
|
||||||
equal(
|
|
||||||
record.scope,
|
|
||||||
"https://example.org/no_receiptEndpoint",
|
|
||||||
"Wrong scope in database record"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_complete() {
|
|
||||||
Services.prefs.setBoolPref("dom.push.enabled", pushEnabled);
|
|
||||||
Services.prefs.setBoolPref(
|
|
||||||
"dom.push.connection.enabled",
|
|
||||||
pushConnectionEnabled
|
|
||||||
);
|
|
||||||
});
|
|
@ -63,42 +63,6 @@ skip-if = os == "linux" # Bug 1265233
|
|||||||
[test_resubscribe_listening_for_msg_error_http2.js]
|
[test_resubscribe_listening_for_msg_error_http2.js]
|
||||||
[test_register_5xxCode_http2.js]
|
[test_register_5xxCode_http2.js]
|
||||||
[test_updateRecordNoEncryptionKeys_http2.js]
|
[test_updateRecordNoEncryptionKeys_http2.js]
|
||||||
[test_register_success_http2.js]
|
|
||||||
# This used to be hasNode, but that caused too many issues with tests being
|
|
||||||
# silently disabled, so now we explicitly call out the platforms not known
|
|
||||||
# to have node installed.
|
|
||||||
skip-if = os == "android"
|
|
||||||
run-sequentially = node server exceptions dont replay well
|
|
||||||
[test_register_error_http2.js]
|
|
||||||
# This used to be hasNode, but that caused too many issues with tests being
|
|
||||||
# silently disabled, so now we explicitly call out the platforms not known
|
|
||||||
# to have node installed.
|
|
||||||
skip-if = os == "android"
|
|
||||||
run-sequentially = node server exceptions dont replay well
|
|
||||||
[test_unregister_success_http2.js]
|
|
||||||
# This used to be hasNode, but that caused too many issues with tests being
|
|
||||||
# silently disabled, so now we explicitly call out the platforms not known
|
|
||||||
# to have node installed.
|
|
||||||
skip-if = os == "android"
|
|
||||||
run-sequentially = node server exceptions dont replay well
|
|
||||||
[test_notification_http2.js]
|
|
||||||
# This used to be hasNode, but that caused too many issues with tests being
|
|
||||||
# silently disabled, so now we explicitly call out the platforms not known
|
|
||||||
# to have node installed.
|
|
||||||
skip-if = os == "android"
|
|
||||||
run-sequentially = node server exceptions dont replay well
|
|
||||||
[test_registration_success_http2.js]
|
|
||||||
# This used to be hasNode, but that caused too many issues with tests being
|
|
||||||
# silently disabled, so now we explicitly call out the platforms not known
|
|
||||||
# to have node installed.
|
|
||||||
skip-if = os == "android"
|
|
||||||
run-sequentially = node server exceptions dont replay well
|
|
||||||
[test_registration_error_http2.js]
|
|
||||||
# This used to be hasNode, but that caused too many issues with tests being
|
|
||||||
# silently disabled, so now we explicitly call out the platforms not known
|
|
||||||
# to have node installed.
|
|
||||||
skip-if = os == "android"
|
|
||||||
run-sequentially = node server exceptions dont replay well
|
|
||||||
[test_clearAll_successful.js]
|
[test_clearAll_successful.js]
|
||||||
# This used to be hasNode, but that caused too many issues with tests being
|
# This used to be hasNode, but that caused too many issues with tests being
|
||||||
# silently disabled, so now we explicitly call out the platforms not known
|
# silently disabled, so now we explicitly call out the platforms not known
|
||||||
|
Loading…
Reference in New Issue
Block a user