Backed out changeset 88ea72c345ab (bug 1524655) for mochitest failures in dom/push/test/test_error_reporting.html

This commit is contained in:
Dorel Luca 2019-03-14 08:45:37 +02:00
Родитель 1dd267df2b
Коммит f1c7ba91fa
7 изменённых файлов: 90 добавлений и 12 удалений

Просмотреть файл

@ -217,6 +217,7 @@ var PushService = {
this._service.disconnect();
}
let records = await this.getAllUnexpired();
let broadcastListeners = await pushBroadcastService.getListeners();
// In principle, a listener could be added to the
@ -229,7 +230,13 @@ var PushService = {
// getListeners.
this._setState(PUSH_SERVICE_RUNNING);
this._service.connect(broadcastListeners);
if (records.length > 0 || prefs.get("alwaysConnect")) {
// Connect if we have existing subscriptions, or if the always-on pref
// is set. We gate on the pref to let us do load testing before
// turning it on for everyone, but if the user has push
// subscriptions, we need to connect them anyhow.
this._service.connect(records, broadcastListeners);
}
},
_changeStateConnectionEnabledEvent: function(enabled) {
@ -290,7 +297,7 @@ var PushService = {
CHANGING_SERVICE_EVENT)
);
} else if (aData == "dom.push.connection.enabled") {
} else if (aData == "dom.push.connection.enabled" || aData == "dom.push.alwaysConnect") {
this._stateChangeProcessEnqueue(_ =>
this._changeStateConnectionEnabledEvent(prefs.get("connection.enabled"))
);
@ -495,6 +502,8 @@ var PushService = {
// Used to monitor if the user wishes to disable Push.
prefs.observe("connection.enabled", this);
// Used to load-test the server-side infrastructure for broadcast.
prefs.observe("alwaysConnect", this);
// Prunes expired registrations and notifies dormant service workers.
Services.obs.addObserver(this, "idle-daily");
@ -578,6 +587,7 @@ var PushService = {
}
prefs.ignore("connection.enabled", this);
prefs.ignore("alwaysConnect", this);
Services.obs.removeObserver(this, "network:offline-status-changed");
Services.obs.removeObserver(this, "clear-origin-attributes-data");

Просмотреть файл

@ -425,8 +425,7 @@ var PushServiceHttp2 = {
return serverURI.scheme == "https";
},
async connect(broadcastListeners) {
let subscriptions = await this._mainPushService.getAllUnexpired();
connect: function(subscriptions, broadcastListeners) {
this.startConnections(subscriptions);
},

Просмотреть файл

@ -512,7 +512,7 @@ var PushServiceWebSocket = {
}
},
connect: function(broadcastListeners) {
connect: function(records, broadcastListeners) {
console.debug("connect()", broadcastListeners);
this._broadcastListeners = broadcastListeners;
this._beginWSSetup();

Просмотреть файл

@ -0,0 +1,73 @@
'use strict';
const {PushService, PushServiceWebSocket} = serviceExports;
function run_test() {
setPrefs();
do_get_profile();
run_next_test();
}
add_task(async function test_startup_error() {
let db = PushServiceWebSocket.newPushDB();
registerCleanupFunction(() => {return db.drop().then(_ => db.close());});
PushService.init({
serverURI: 'wss://push.example.org/',
db: makeStub(db, {
getAllExpired(prev) {
return Promise.reject('database corruption on startup');
},
}),
makeWebSocket(uri) {
return new MockWebSocket(uri, {
onHello(request) {
ok(false, 'Unexpected handshake');
},
onRegister(request) {
ok(false, 'Unexpected register request');
},
});
},
});
await rejects(
PushService.register({
scope: `https://example.net/1`,
originAttributes: ChromeUtils.originAttributesToSuffix(
{ appId: Ci.nsIScriptSecurityManager.NO_APP_ID, inIsolatedMozBrowser: false }),
}),
/Push service not active/,
'Should not register if startup failed'
);
PushService.uninit();
PushService.init({
serverURI: 'wss://push.example.org/',
db: makeStub(db, {
getAllUnexpired(prev) {
return Promise.reject('database corruption on connect');
},
}),
makeWebSocket(uri) {
return new MockWebSocket(uri, {
onHello(request) {
ok(false, 'Unexpected handshake');
},
onRegister(request) {
ok(false, 'Unexpected register request');
},
});
},
});
await rejects(
PushService.registration({
scope: `https://example.net/1`,
originAttributes: ChromeUtils.originAttributesToSuffix(
{ appId: Ci.nsIScriptSecurityManager.NO_APP_ID, inIsolatedMozBrowser: false }),
}),
/Push service not active/,
'Should not return registration if connection failed'
);
});

Просмотреть файл

@ -56,6 +56,7 @@ skip-if = os == "linux" # Bug 1265233
[test_retry_ws.js]
[test_service_parent.js]
[test_service_child.js]
[test_startup_error.js]
#http2 test
[test_resubscribe_4xxCode_http2.js]

Просмотреть файл

@ -5234,6 +5234,8 @@ pref("dom.battery.enabled", true);
// Push
pref("dom.push.alwaysConnect", false);
pref("dom.push.loglevel", "Error");
pref("dom.push.serverURL", "wss://push.services.mozilla.com/");

Просмотреть файл

@ -383,13 +383,6 @@ async function test_push_cleared() {
uaid: userAgentID,
}));
},
onUnregister(request) {
this.serverSendMsg(JSON.stringify({
messageType: "unregister",
status: 200,
channelID: request.channelID,
}));
},
});
},
});