mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1195930 - Part 1: Re-enable tests for clearing origin data; r=asuth
This commit is contained in:
parent
89a2736994
commit
64b62c9b07
@ -381,14 +381,14 @@ skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 931116
|
||||
[test_webapp_clearBrowserData_inproc_inproc.html]
|
||||
# The clearBrowserData tests are only supposed to run in the main process.
|
||||
# They currently time out on android.
|
||||
skip-if = buildapp != 'mulet'
|
||||
skip-if = buildapp == 'b2g' || e10s || toolkit == 'android'
|
||||
[test_webapp_clearBrowserData_inproc_oop.html]
|
||||
# The clearBrowserData tests are only supposed to run in the main process.
|
||||
# They currently time out on android.
|
||||
skip-if = buildapp != 'mulet'
|
||||
skip-if = buildapp == 'b2g' || e10s || toolkit == 'android'
|
||||
[test_webapp_clearBrowserData_oop_inproc.html]
|
||||
# The clearBrowserData tests are only supposed to run in the main process.
|
||||
# They currently time out on android.
|
||||
skip-if = buildapp != 'mulet'
|
||||
skip-if = buildapp == 'b2g' || e10s || toolkit == 'android'
|
||||
[test_serviceworker.html]
|
||||
skip-if = buildapp == 'b2g'
|
||||
|
@ -90,17 +90,13 @@
|
||||
info("blocking browserFrame");
|
||||
event.preventDefault();
|
||||
|
||||
let request = navigator.mozApps.getSelf();
|
||||
request.onsuccess = function() {
|
||||
let app = request.result;
|
||||
ok(app, "got app");
|
||||
let appId = SpecialPowers.wrap(document).nodePrincipal.appId;
|
||||
|
||||
info("clearing browser data");
|
||||
app.clearBrowserData();
|
||||
info("clearing browser data");
|
||||
SpecialPowers.clearAppPrivateData(appId, true);
|
||||
|
||||
info("unblocking browserFrame");
|
||||
event.detail.unblock();
|
||||
}
|
||||
info("unblocking browserFrame");
|
||||
event.detail.unblock();
|
||||
break;
|
||||
case "done":
|
||||
continueToNextStepSync();
|
||||
|
@ -89,6 +89,7 @@ SpecialPowersObserver.prototype._loadFrameScript = function()
|
||||
this._messageManager.addMessageListener("SPUnloadExtension", this);
|
||||
this._messageManager.addMessageListener("SPExtensionMessage", this);
|
||||
this._messageManager.addMessageListener("SPCleanUpSTSData", this);
|
||||
this._messageManager.addMessageListener("SPClearAppPrivateData", this);
|
||||
|
||||
this._messageManager.loadFrameScript(CHILD_LOGGER_SCRIPT, true);
|
||||
this._messageManager.loadFrameScript(CHILD_SCRIPT_API, true);
|
||||
@ -161,6 +162,7 @@ SpecialPowersObserver.prototype.uninit = function()
|
||||
this._messageManager.removeMessageListener("SPUnloadExtension", this);
|
||||
this._messageManager.removeMessageListener("SPExtensionMessage", this);
|
||||
this._messageManager.removeMessageListener("SPCleanUpSTSData", this);
|
||||
this._messageManager.removeMessageListener("SPClearAppPrivateData", this);
|
||||
|
||||
this._messageManager.removeDelayedFrameScript(CHILD_LOGGER_SCRIPT);
|
||||
this._messageManager.removeDelayedFrameScript(CHILD_SCRIPT_API);
|
||||
|
@ -236,6 +236,57 @@ SpecialPowersObserverAPI.prototype = {
|
||||
mm.sendAsyncMessage(aReplyName, aReplyMsg);
|
||||
},
|
||||
|
||||
_notifyCategoryAndObservers: function(subject, topic, data) {
|
||||
const serviceMarker = "service,";
|
||||
|
||||
// First create observers from the category manager.
|
||||
let cm =
|
||||
Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
|
||||
let enumerator = cm.enumerateCategory(topic);
|
||||
|
||||
let observers = [];
|
||||
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let entry =
|
||||
enumerator.getNext().QueryInterface(Ci.nsISupportsCString).data;
|
||||
let contractID = cm.getCategoryEntry(topic, entry);
|
||||
|
||||
let factoryFunction;
|
||||
if (contractID.substring(0, serviceMarker.length) == serviceMarker) {
|
||||
contractID = contractID.substring(serviceMarker.length);
|
||||
factoryFunction = "getService";
|
||||
}
|
||||
else {
|
||||
factoryFunction = "createInstance";
|
||||
}
|
||||
|
||||
try {
|
||||
let handler = Cc[contractID][factoryFunction]();
|
||||
if (handler) {
|
||||
let observer = handler.QueryInterface(Ci.nsIObserver);
|
||||
observers.push(observer);
|
||||
}
|
||||
} catch(e) { }
|
||||
}
|
||||
|
||||
// Next enumerate the registered observers.
|
||||
enumerator = Services.obs.enumerateObservers(topic);
|
||||
while (enumerator.hasMoreElements()) {
|
||||
try {
|
||||
let observer = enumerator.getNext().QueryInterface(Ci.nsIObserver);
|
||||
if (observers.indexOf(observer) == -1) {
|
||||
observers.push(observer);
|
||||
}
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
observers.forEach(function (observer) {
|
||||
try {
|
||||
observer.observe(subject, topic, data);
|
||||
} catch(e) { }
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* messageManager callback function
|
||||
* This will get requests from our API in the window and process them in chrome for it
|
||||
@ -597,6 +648,28 @@ SpecialPowersObserverAPI.prototype = {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
case "SPClearAppPrivateData": {
|
||||
let appId = aMessage.data.appId;
|
||||
let browserOnly = aMessage.data.browserOnly;
|
||||
|
||||
let attributes = { appId: appId };
|
||||
if (browserOnly) {
|
||||
attributes.inIsolatedMozBrowser = true;
|
||||
}
|
||||
this._notifyCategoryAndObservers(null,
|
||||
"clear-origin-data",
|
||||
JSON.stringify(attributes));
|
||||
|
||||
let subject = {
|
||||
appId: appId,
|
||||
browserOnly: browserOnly,
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.mozIApplicationClearPrivateDataParams])
|
||||
};
|
||||
this._notifyCategoryAndObservers(subject, "webapps-clear-data", null);
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new SpecialPowersError("Unrecognized Special Powers API");
|
||||
}
|
||||
|
@ -45,7 +45,8 @@ function SpecialPowers(window) {
|
||||
"SPLoadExtension",
|
||||
"SPStartupExtension",
|
||||
"SPUnloadExtension",
|
||||
"SPExtensionMessage"];
|
||||
"SPExtensionMessage",
|
||||
"SPClearAppPrivateData"];
|
||||
addMessageListener("SPPingService", this._messageListener);
|
||||
addMessageListener("SpecialPowers.FilesCreated", this._messageListener);
|
||||
addMessageListener("SpecialPowers.FilesError", this._messageListener);
|
||||
|
@ -2086,6 +2086,11 @@ SpecialPowersAPI.prototype = {
|
||||
unwrapIfWrapped(mo).observe(unwrapIfWrapped(node),
|
||||
{nativeAnonymousChildList, subtree});
|
||||
},
|
||||
|
||||
clearAppPrivateData: function(appId, browserOnly) {
|
||||
return this._sendAsyncMessage('SPClearAppPrivateData',
|
||||
{ appId: appId, browserOnly: browserOnly });
|
||||
},
|
||||
};
|
||||
|
||||
this.SpecialPowersAPI = SpecialPowersAPI;
|
||||
|
Loading…
Reference in New Issue
Block a user