mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
backout f370e521f004 (bug 879658) for b-c bustage
--HG-- extra : rebase_source : faa6901a5da3f65feb7db0c12c8657d7704bbbc5
This commit is contained in:
parent
2884ae407d
commit
c009dcb6d8
@ -30,7 +30,7 @@ var _nextPortId = 1;
|
||||
// Retrieves a reference to a WorkerHandle associated with a FrameWorker and a
|
||||
// new ClientPort.
|
||||
this.getFrameWorkerHandle =
|
||||
function getFrameWorkerHandle(url, clientWindow, name, origin, exposeLocalStorage = false) {
|
||||
function getFrameWorkerHandle(url, clientWindow, name, origin) {
|
||||
// first create the client port we are going to use. Later we will
|
||||
// message the worker to create the worker port.
|
||||
let portid = _nextPortId++;
|
||||
@ -39,7 +39,7 @@ this.getFrameWorkerHandle =
|
||||
let existingWorker = workerCache[url];
|
||||
if (!existingWorker) {
|
||||
// setup the worker and add this connection to the pending queue
|
||||
let worker = new FrameWorker(url, name, origin, exposeLocalStorage);
|
||||
let worker = new FrameWorker(url, name, origin);
|
||||
worker.pendingPorts.push(clientPort);
|
||||
existingWorker = workerCache[url] = worker;
|
||||
} else {
|
||||
@ -69,7 +69,7 @@ this.getFrameWorkerHandle =
|
||||
* the script does not have a full DOM but is instead run in a sandbox
|
||||
* that has a select set of methods cloned from the URL's domain.
|
||||
*/
|
||||
function FrameWorker(url, name, origin, exposeLocalStorage) {
|
||||
function FrameWorker(url, name, origin) {
|
||||
this.url = url;
|
||||
this.name = name || url;
|
||||
this.ports = new Map();
|
||||
@ -78,7 +78,6 @@ function FrameWorker(url, name, origin, exposeLocalStorage) {
|
||||
this.reloading = false;
|
||||
this.origin = origin;
|
||||
this._injectController = null;
|
||||
this.exposeLocalStorage = exposeLocalStorage;
|
||||
|
||||
this.frame = makeHiddenFrame();
|
||||
this.load();
|
||||
@ -134,17 +133,11 @@ FrameWorker.prototype = {
|
||||
// copy the window apis onto the sandbox namespace only functions or
|
||||
// objects that are naturally a part of an iframe, I'm assuming they are
|
||||
// safe to import this way
|
||||
let workerAPI = ['WebSocket', 'atob', 'btoa',
|
||||
let workerAPI = ['WebSocket', 'localStorage', 'atob', 'btoa',
|
||||
'clearInterval', 'clearTimeout', 'dump',
|
||||
'setInterval', 'setTimeout', 'XMLHttpRequest',
|
||||
'FileReader', 'Blob', 'EventSource', 'indexedDB',
|
||||
'location'];
|
||||
|
||||
// Only expose localStorage if the caller opted-in
|
||||
if (this.exposeLocalStorage) {
|
||||
workerAPI.push('localStorage');
|
||||
}
|
||||
|
||||
// Bug 798660 - XHR and WebSocket have issues in a sandbox and need
|
||||
// to be unwrapped to work
|
||||
let needsWaive = ['XMLHttpRequest', 'WebSocket'];
|
||||
|
@ -137,42 +137,6 @@ let SocialServiceInternal = {
|
||||
}
|
||||
};
|
||||
|
||||
XPCOMUtils.defineLazyGetter(SocialServiceInternal, "providers", function () {
|
||||
initService();
|
||||
let providers = {};
|
||||
for (let manifest of this.manifests) {
|
||||
try {
|
||||
if (ActiveProviders.has(manifest.origin)) {
|
||||
let activationType = getOriginActivationType(manifest.origin);
|
||||
let blessed = activationType == "builtin" ||
|
||||
activationType == "whitelist";
|
||||
let provider = new SocialProvider(manifest, blessed);
|
||||
providers[provider.origin] = provider;
|
||||
}
|
||||
} catch (err) {
|
||||
Cu.reportError("SocialService: failed to load provider: " + manifest.origin +
|
||||
", exception: " + err);
|
||||
}
|
||||
}
|
||||
return providers;
|
||||
});
|
||||
|
||||
function getOriginActivationType(origin) {
|
||||
let prefname = SocialServiceInternal.getManifestPrefname(origin);
|
||||
if (Services.prefs.getDefaultBranch("social.manifest.").getPrefType(prefname) == Services.prefs.PREF_STRING)
|
||||
return 'builtin';
|
||||
|
||||
let whitelist = Services.prefs.getCharPref("social.whitelist").split(',');
|
||||
if (whitelist.indexOf(origin) >= 0)
|
||||
return 'whitelist';
|
||||
|
||||
let directories = Services.prefs.getCharPref("social.directories").split(',');
|
||||
if (directories.indexOf(origin) >= 0)
|
||||
return 'directory';
|
||||
|
||||
return 'foreign';
|
||||
}
|
||||
|
||||
let ActiveProviders = {
|
||||
get _providers() {
|
||||
delete this._providers;
|
||||
@ -340,6 +304,23 @@ function initService() {
|
||||
MozSocialAPI.enabled = true;
|
||||
}
|
||||
|
||||
XPCOMUtils.defineLazyGetter(SocialServiceInternal, "providers", function () {
|
||||
initService();
|
||||
let providers = {};
|
||||
for (let manifest of this.manifests) {
|
||||
try {
|
||||
if (ActiveProviders.has(manifest.origin)) {
|
||||
let provider = new SocialProvider(manifest);
|
||||
providers[provider.origin] = provider;
|
||||
}
|
||||
} catch (err) {
|
||||
Cu.reportError("SocialService: failed to load provider: " + manifest.origin +
|
||||
", exception: " + err);
|
||||
}
|
||||
}
|
||||
return providers;
|
||||
});
|
||||
|
||||
function schedule(callback) {
|
||||
Services.tm.mainThread.dispatch(callback, Ci.nsIThread.DISPATCH_NORMAL);
|
||||
}
|
||||
@ -463,6 +444,22 @@ this.SocialService = {
|
||||
SocialServiceInternal.orderedProviders(onDone);
|
||||
},
|
||||
|
||||
getOriginActivationType: function(origin) {
|
||||
let prefname = SocialServiceInternal.getManifestPrefname(origin);
|
||||
if (Services.prefs.getDefaultBranch("social.manifest.").getPrefType(prefname) == Services.prefs.PREF_STRING)
|
||||
return 'builtin';
|
||||
|
||||
let whitelist = Services.prefs.getCharPref("social.whitelist").split(',');
|
||||
if (whitelist.indexOf(origin) >= 0)
|
||||
return 'whitelist';
|
||||
|
||||
let directories = Services.prefs.getCharPref("social.directories").split(',');
|
||||
if (directories.indexOf(origin) >= 0)
|
||||
return 'directory';
|
||||
|
||||
return 'foreign';
|
||||
},
|
||||
|
||||
_providerListeners: new Map(),
|
||||
registerProviderListener: function registerProviderListener(listener) {
|
||||
this._providerListeners.set(listener, 1);
|
||||
@ -588,7 +585,7 @@ this.SocialService = {
|
||||
let sourceURI = aDOMDocument.location.href;
|
||||
let installOrigin = aDOMDocument.nodePrincipal.origin;
|
||||
|
||||
let installType = getOriginActivationType(installOrigin);
|
||||
let installType = this.getOriginActivationType(installOrigin);
|
||||
let manifest;
|
||||
if (data) {
|
||||
// if we get data, we MUST have a valid manifest generated from the data
|
||||
@ -652,9 +649,8 @@ this.SocialService = {
|
||||
*
|
||||
* @constructor
|
||||
* @param {jsobj} object representing the manifest file describing this provider
|
||||
* @param {bool} boolean indicating whether this provider is "built in"
|
||||
*/
|
||||
function SocialProvider(input, blessed = false) {
|
||||
function SocialProvider(input) {
|
||||
if (!input.name)
|
||||
throw new Error("SocialProvider must be passed a name");
|
||||
if (!input.origin)
|
||||
@ -678,7 +674,6 @@ function SocialProvider(input, blessed = false) {
|
||||
this.ambientNotificationIcons = {};
|
||||
this.errorState = null;
|
||||
this.frecency = 0;
|
||||
this.blessed = blessed;
|
||||
try {
|
||||
this.domain = etld.getBaseDomainFromHost(originUri.host);
|
||||
} catch(e) {
|
||||
@ -874,12 +869,8 @@ SocialProvider.prototype = {
|
||||
getWorkerPort: function getWorkerPort(window) {
|
||||
if (!this.workerURL || !this.enabled)
|
||||
return null;
|
||||
// Only allow localStorage in the frameworker for blessed providers
|
||||
let allowLocalStorage = this.blessed;
|
||||
let handle = getFrameWorkerHandle(this.workerURL, window,
|
||||
"SocialProvider:" + this.origin, this.origin,
|
||||
allowLocalStorage);
|
||||
return handle.port;
|
||||
return getFrameWorkerHandle(this.workerURL, window,
|
||||
"SocialProvider:" + this.origin, this.origin).port;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -241,7 +241,7 @@ let tests = {
|
||||
port.postMessage({topic: "done", result: "ok"});
|
||||
}
|
||||
}
|
||||
let worker = getFrameWorkerHandle(makeWorkerUrl(run), undefined, "testLocalStorage", null, true);
|
||||
let worker = getFrameWorkerHandle(makeWorkerUrl(run), undefined, "testLocalStorage");
|
||||
worker.port.onmessage = function(e) {
|
||||
if (e.data.topic == "done") {
|
||||
is(e.data.result, "ok", "check the localStorage test worked");
|
||||
@ -251,30 +251,6 @@ let tests = {
|
||||
}
|
||||
},
|
||||
|
||||
testNoLocalStorage: function(cbnext) {
|
||||
let run = function() {
|
||||
onconnect = function(e) {
|
||||
let port = e.ports[0];
|
||||
try {
|
||||
localStorage.setItem("foo", "1");
|
||||
} catch(e) {
|
||||
port.postMessage({topic: "done", result: "ok"});
|
||||
return;
|
||||
}
|
||||
|
||||
port.postMessage({topic: "done", result: "FAILED because localStorage was exposed" });
|
||||
}
|
||||
}
|
||||
let worker = getFrameWorkerHandle(makeWorkerUrl(run), undefined, "testNoLocalStorage");
|
||||
worker.port.onmessage = function(e) {
|
||||
if (e.data.topic == "done") {
|
||||
is(e.data.result, "ok", "check that retrieving localStorage fails by default");
|
||||
worker.terminate();
|
||||
cbnext();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
testBase64: function (cbnext) {
|
||||
let run = function() {
|
||||
onconnect = function(e) {
|
||||
|
Loading…
Reference in New Issue
Block a user