mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1149274 - Clear site-permissions should clear all registered push notifications. r=nsm
This commit is contained in:
parent
91dc34937f
commit
bdcca49c7d
@ -486,6 +486,11 @@ Sanitizer.prototype = {
|
|||||||
.getService(Ci.nsISiteSecurityService);
|
.getService(Ci.nsISiteSecurityService);
|
||||||
sss.clearAll();
|
sss.clearAll();
|
||||||
|
|
||||||
|
// Clear all push notification subscriptions
|
||||||
|
var push = Cc["@mozilla.org/push/NotificationService;1"]
|
||||||
|
.getService(Ci.nsIPushNotificationService);
|
||||||
|
push.clearAll();
|
||||||
|
|
||||||
TelemetryStopwatch.finish("FX_SANITIZE_SITESETTINGS");
|
TelemetryStopwatch.finish("FX_SANITIZE_SITESETTINGS");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* uses service workers to notify applications. This interface exists to allow
|
* uses service workers to notify applications. This interface exists to allow
|
||||||
* privileged code to receive messages without migrating to service workers.
|
* privileged code to receive messages without migrating to service workers.
|
||||||
*/
|
*/
|
||||||
[scriptable, uuid(32028e38-903b-4a64-a180-5857eb4cb3dd)]
|
[scriptable, uuid(3da6a16c-69f8-4843-9149-1e89d58a53e2)]
|
||||||
interface nsIPushNotificationService : nsISupports
|
interface nsIPushNotificationService : nsISupports
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -46,4 +46,9 @@ interface nsIPushNotificationService : nsISupports
|
|||||||
* given |scope|, or `null` if the |scope| does not have a subscription.
|
* given |scope|, or `null` if the |scope| does not have a subscription.
|
||||||
*/
|
*/
|
||||||
jsval registration(in string scope);
|
jsval registration(in string scope);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear all subscriptions
|
||||||
|
*/
|
||||||
|
jsval clearAll();
|
||||||
};
|
};
|
||||||
|
@ -50,6 +50,10 @@ PushNotificationService.prototype = {
|
|||||||
return PushService._registration({scope});
|
return PushService._registration({scope});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clearAll: function clearAll() {
|
||||||
|
return PushService._clearAll();
|
||||||
|
},
|
||||||
|
|
||||||
observe: function observe(subject, topic, data) {
|
observe: function observe(subject, topic, data) {
|
||||||
switch (topic) {
|
switch (topic) {
|
||||||
case "app-startup":
|
case "app-startup":
|
||||||
|
@ -135,6 +135,19 @@ this.PushDB.prototype = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clearAll: function clear(aSuccessCb, aErrorCb) {
|
||||||
|
this.newTxn(
|
||||||
|
"readwrite",
|
||||||
|
kPUSHDB_STORE_NAME,
|
||||||
|
function (aTxn, aStore) {
|
||||||
|
debug("Going to clear all!");
|
||||||
|
aStore.clear();
|
||||||
|
},
|
||||||
|
aSuccessCb,
|
||||||
|
aErrorCb
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
getByPushEndpoint: function(aPushEndpoint, aSuccessCb, aErrorCb) {
|
getByPushEndpoint: function(aPushEndpoint, aSuccessCb, aErrorCb) {
|
||||||
debug("getByPushEndpoint()");
|
debug("getByPushEndpoint()");
|
||||||
|
|
||||||
@ -1627,6 +1640,13 @@ this.PushService = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_clearAll: function _clearAll() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this._db.clearAll(() => resolve(),
|
||||||
|
() => reject("Database error"));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on message from the child process
|
* Called on message from the child process
|
||||||
*/
|
*/
|
||||||
|
47
dom/push/test/xpcshell/test_clearAll_successful.js
Normal file
47
dom/push/test/xpcshell/test_clearAll_successful.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const {PushDB, PushService} = serviceExports;
|
||||||
|
|
||||||
|
const channelID = 'db0a7021-ec2d-4bd3-8802-7a6966f10ed8';
|
||||||
|
|
||||||
|
function run_test() {
|
||||||
|
do_get_profile();
|
||||||
|
setPrefs();
|
||||||
|
run_next_test();
|
||||||
|
}
|
||||||
|
|
||||||
|
add_task(function* test_unregister_success() {
|
||||||
|
let db = new PushDB();
|
||||||
|
let promiseDB = promisifyDatabase(db);
|
||||||
|
do_register_cleanup(() => cleanupDatabase(db));
|
||||||
|
yield promiseDB.put({
|
||||||
|
channelID,
|
||||||
|
pushEndpoint: 'https://example.org/update/unregister-success',
|
||||||
|
scope: 'https://example.com/page/unregister-success',
|
||||||
|
version: 1
|
||||||
|
});
|
||||||
|
|
||||||
|
let unregisterDefer = Promise.defer();
|
||||||
|
PushService.init({
|
||||||
|
networkInfo: new MockDesktopNetworkInfo(),
|
||||||
|
db,
|
||||||
|
makeWebSocket(uri) {
|
||||||
|
return new MockWebSocket(uri, {
|
||||||
|
onHello(request) {
|
||||||
|
this.serverSendMsg(JSON.stringify({
|
||||||
|
messageType: 'hello',
|
||||||
|
status: 200,
|
||||||
|
uaid: 'fbe865a6-aeb8-446f-873c-aeebdb8d493c'
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
yield PushNotificationService.clearAll();
|
||||||
|
let record = yield promiseDB.getByChannelID(channelID);
|
||||||
|
ok(!record, 'Unregister did not remove record');
|
||||||
|
});
|
@ -4,6 +4,8 @@ tail =
|
|||||||
# Push notifications and alarms are currently disabled on Android.
|
# Push notifications and alarms are currently disabled on Android.
|
||||||
skip-if = toolkit == 'android'
|
skip-if = toolkit == 'android'
|
||||||
|
|
||||||
|
[test_clearAll_successful.js]
|
||||||
|
run-sequentially = This will delete all existing push subscritions.
|
||||||
[test_notification_ack.js]
|
[test_notification_ack.js]
|
||||||
[test_notification_duplicate.js]
|
[test_notification_duplicate.js]
|
||||||
[test_notification_error.js]
|
[test_notification_error.js]
|
||||||
|
Loading…
Reference in New Issue
Block a user