mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1287007 - Set parent cloneScope to child cloneScope r=billm
This is only to help with migration. This change allows all APIs to behave identical regardless of whether the API is proxied. Change cloneScope to be a getter because cloneScope is `this.contentWindow`, which may be nulled when the context navigates away (but stays in the bfcache). Any API that is not proxied must have an identical clone scope to make sure that properties such as toJSON (in the native messaging stringifier) and ArrayBuffer (in webRequest as requestBody) are visible to the caller. MozReview-Commit-ID: 9aT3SUBieHK --HG-- extra : rebase_source : f5e4eef52100e42b6fcdc3a43fa7676e7fc3dabc
This commit is contained in:
parent
03c9fa02f3
commit
095763db5a
@ -327,11 +327,6 @@ class ExtensionChildProxyContext extends ProxyContext {
|
||||
// WARNING: The xulBrowser may change when docShells are swapped, e.g. when
|
||||
// the tab moves to a different window.
|
||||
this.xulBrowser = xulBrowser;
|
||||
|
||||
// TODO(robwu): Remove this once all APIs can run in a separate process.
|
||||
if (params.cloneScopeInProcess) {
|
||||
this.sandbox = params.cloneScopeInProcess;
|
||||
}
|
||||
}
|
||||
|
||||
// The window that contains this context. This may change due to moving tabs.
|
||||
|
@ -83,7 +83,6 @@ class WannabeChildAPIManager extends ChildAPIManager {
|
||||
delete data.principal;
|
||||
data = Cu.cloneInto(data, {});
|
||||
data.principal = principal;
|
||||
data.cloneScopeInProcess = this.context.cloneScope;
|
||||
let name = "API:CreateProxyContext";
|
||||
// The <browser> that receives messages from `this.messageManager`.
|
||||
let target = this.context.contentWindow
|
||||
@ -93,6 +92,17 @@ class WannabeChildAPIManager extends ChildAPIManager {
|
||||
ParentAPIManager.receiveMessage({name, data, target});
|
||||
|
||||
let proxyContext = ParentAPIManager.proxyContexts.get(this.id);
|
||||
|
||||
// Use an identical cloneScope in the parent as the child to have identical
|
||||
// behavior for proxied vs direct calls. If all APIs are proxied, then the
|
||||
// parent cloneScope does not really matter (because when the message
|
||||
// arrives locally, the object is cloned into the local clone scope).
|
||||
// If all calls are direct, then the parent cloneScope does matter, because
|
||||
// the objects are not cloned again.
|
||||
Object.defineProperty(proxyContext, "cloneScope", {
|
||||
get: () => this.cloneScope,
|
||||
});
|
||||
|
||||
// Many APIs rely on this, so temporarily add it to keep the commit small.
|
||||
proxyContext.setContentWindow(this.context.contentWindow);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user