Bug 1616353 - Part 6.2: Remove setOriginAttributesBeforeLoading API, r=smaug

This API is no longer possible to implement, as it will always try to set the
OriginAttributes on a content BrowsingContext after it has been attached, and JS
can never observe a detached BrowsingContext.

Users of this API are instead changed to perform assertions that
originAttributes have already been set correctly.

Differential Revision: https://phabricator.services.mozilla.com/D67046
This commit is contained in:
Nika Layzell
2020-04-06 14:29:50 +00:00
parent 458cd6db6a
commit c9e96c7477
9 changed files with 4 additions and 74 deletions

View File

@@ -1489,6 +1489,10 @@ function _loadURI(browser, uri, params = {}) {
throw new Error("Must load with a triggering Principal"); throw new Error("Must load with a triggering Principal");
} }
if (userContextId && userContextId != browser.getAttribute("usercontextid")) {
throw new Error("Cannot load with mismatched userContextId");
}
let { let {
uriObject, uriObject,
requiredRemoteType, requiredRemoteType,
@@ -1524,14 +1528,6 @@ function _loadURI(browser, uri, params = {}) {
}; };
try { try {
if (!mustChangeProcess) { if (!mustChangeProcess) {
if (userContextId) {
browser.webNavigation.setOriginAttributesBeforeLoading({
userContextId,
privateBrowsingId: PrivateBrowsingUtils.isBrowserPrivate(browser)
? 1
: 0,
});
}
browser.webNavigation.loadURI(uri, loadURIOptions); browser.webNavigation.loadURI(uri, loadURIOptions);
} else { } else {
// Check if the current browser is allowed to unload. // Check if the current browser is allowed to unload.
@@ -1580,14 +1576,6 @@ function _loadURI(browser, uri, params = {}) {
Cu.reportError(e); Cu.reportError(e);
gBrowser.updateBrowserRemotenessByURL(browser, uri); gBrowser.updateBrowserRemotenessByURL(browser, uri);
if (userContextId) {
browser.webNavigation.setOriginAttributesBeforeLoading({
userContextId,
privateBrowsingId: PrivateBrowsingUtils.isBrowserPrivate(browser)
? 1
: 0,
});
}
browser.webNavigation.loadURI(uri, loadURIOptions); browser.webNavigation.loadURI(uri, loadURIOptions);
} else { } else {
throw e; throw e;

View File

@@ -292,11 +292,6 @@ ContentRestoreInternal.prototype = {
? E10SUtils.deserializeCSP(loadArguments.csp) ? E10SUtils.deserializeCSP(loadArguments.csp)
: null; : null;
if (loadArguments.userContextId) {
webNavigation.setOriginAttributesBeforeLoading({
userContextId: loadArguments.userContextId,
});
}
let loadURIOptions = { let loadURIOptions = {
triggeringPrincipal, triggeringPrincipal,
loadFlags: loadArguments.flags, loadFlags: loadArguments.flags,

View File

@@ -5058,9 +5058,6 @@ var SessionStoreInternal = {
let uri = activePageData ? activePageData.url || null : null; let uri = activePageData ? activePageData.url || null : null;
if (loadArguments) { if (loadArguments) {
uri = loadArguments.uri; uri = loadArguments.uri;
if (loadArguments.userContextId) {
browser.setAttribute("usercontextid", loadArguments.userContextId);
}
} }
this.markTabAsRestoring(aTab); this.markTabAsRestoring(aTab);

View File

@@ -84,13 +84,6 @@ BrowserElementWebNavigation.prototype = {
}); });
}, },
setOriginAttributesBeforeLoading(originAttributes) {
// No equivalent in the current BrowserElement API
this._sendMessage("WebNavigation:SetOriginAttributes", {
originAttributes,
});
},
reload(flags) { reload(flags) {
let hardReload = false; let hardReload = false;
if ( if (

View File

@@ -12546,21 +12546,6 @@ nsresult nsDocShell::SetOriginAttributes(const OriginAttributes& aAttrs) {
return mBrowsingContext->SetOriginAttributes(aAttrs); return mBrowsingContext->SetOriginAttributes(aAttrs);
} }
NS_IMETHODIMP
nsDocShell::SetOriginAttributesBeforeLoading(
JS::Handle<JS::Value> aOriginAttributes, JSContext* aCx) {
if (!aOriginAttributes.isObject()) {
return NS_ERROR_INVALID_ARG;
}
OriginAttributes attrs;
if (!attrs.Init(aCx, aOriginAttributes)) {
return NS_ERROR_INVALID_ARG;
}
return SetOriginAttributes(attrs);
}
NS_IMETHODIMP NS_IMETHODIMP
nsDocShell::ResumeRedirectedLoad(uint64_t aIdentifier, int32_t aHistoryIndex) { nsDocShell::ResumeRedirectedLoad(uint64_t aIdentifier, int32_t aHistoryIndex) {
RefPtr<nsDocShell> self = this; RefPtr<nsDocShell> self = this;

View File

@@ -344,13 +344,6 @@ interface nsIWebNavigation : nsISupports
} }
%} %}
/**
* Set an OriginAttributes dictionary in the docShell. This can be done only
* before loading any content.
*/
[implicit_jscontext]
void setOriginAttributesBeforeLoading(in jsval originAttributes);
/** /**
* Resume a load which has been redirected from another process. * Resume a load which has been redirected from another process.
* *

View File

@@ -22,9 +22,6 @@ class WebNavigationChild extends JSWindowActorChild {
case "WebNavigation:GotoIndex": case "WebNavigation:GotoIndex":
this.gotoIndex(message.data); this.gotoIndex(message.data);
break; break;
case "WebNavigation:SetOriginAttributes":
this.setOriginAttributes(message.data.originAttributes);
break;
case "WebNavigation:Reload": case "WebNavigation:Reload":
this.reload(message.data.loadFlags); this.reload(message.data.loadFlags);
break; break;
@@ -79,12 +76,6 @@ class WebNavigationChild extends JSWindowActorChild {
} }
} }
setOriginAttributes(originAttributes) {
if (originAttributes) {
this.webNavigation.setOriginAttributesBeforeLoading(originAttributes);
}
}
reload(loadFlags) { reload(loadFlags) {
this.webNavigation.reload(loadFlags); this.webNavigation.reload(loadFlags);
} }

View File

@@ -527,13 +527,6 @@ nsWebBrowser::LoadURIFromScript(const nsAString& aURI,
return LoadURI(aURI, loadURIOptions); return LoadURI(aURI, loadURIOptions);
} }
NS_IMETHODIMP
nsWebBrowser::SetOriginAttributesBeforeLoading(
JS::Handle<JS::Value> aOriginAttributes, JSContext* aCx) {
return mDocShellAsNav->SetOriginAttributesBeforeLoading(aOriginAttributes,
aCx);
}
NS_IMETHODIMP NS_IMETHODIMP
nsWebBrowser::ResumeRedirectedLoad(uint64_t aIdentifier, nsWebBrowser::ResumeRedirectedLoad(uint64_t aIdentifier,
int32_t aHistoryIndex) { int32_t aHistoryIndex) {

View File

@@ -111,11 +111,6 @@ class RemoteWebNavigation {
cancelContentJSEpoch, cancelContentJSEpoch,
}); });
} }
setOriginAttributesBeforeLoading(aOriginAttributes) {
this._sendMessage("WebNavigation:SetOriginAttributes", {
originAttributes: aOriginAttributes,
});
}
reload(aReloadFlags) { reload(aReloadFlags) {
this._sendMessage("WebNavigation:Reload", { loadFlags: aReloadFlags }); this._sendMessage("WebNavigation:Reload", { loadFlags: aReloadFlags });
} }