зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1731613 - Move GetProcessSwitchBehavior method to C++, r=nika
Differential Revision: https://phabricator.services.mozilla.com/D128898
This commit is contained in:
Родитель
9a9a4f2cf9
Коммит
252c246034
|
@ -129,28 +129,6 @@ interface nsIBrowser : nsISupports
|
|||
in uint64_t aRequestContextID,
|
||||
in AString aContentType);
|
||||
|
||||
/**
|
||||
* Determine what process switching behavior this browser element should have.
|
||||
*/
|
||||
cenum ProcessBehavior : 8 {
|
||||
// Gecko won't automatically change which process this frame, or it's
|
||||
// subframes, are loaded in.
|
||||
PROCESS_BEHAVIOR_DISABLED,
|
||||
|
||||
// If `useRemoteTabs` is enabled, Gecko will change which process this frame
|
||||
// is loaded in automatically, without calling `performProcessSwitch`.
|
||||
// When `useRemoteSubframes` is enabled, subframes will change processes.
|
||||
PROCESS_BEHAVIOR_STANDARD,
|
||||
|
||||
// Gecko won't automatically change which process this frame is loaded, but
|
||||
// when `useRemoteSubframes` is enabled, subframes will change processes.
|
||||
//
|
||||
// NOTE: This configuration is included only for backwards compatibility,
|
||||
// and will be removed, as it can easily lead to invalid behavior.
|
||||
PROCESS_BEHAVIOR_SUBFRAME_ONLY,
|
||||
};
|
||||
readonly attribute nsIBrowser_ProcessBehavior processSwitchBehavior;
|
||||
|
||||
/**
|
||||
* Called to perform any async tasks which must be completed before changing
|
||||
* remoteness. Gecko will wait for the returned promise to resolve before
|
||||
|
|
|
@ -1467,6 +1467,21 @@ void DocumentLoadListener::SerializeRedirectData(
|
|||
}
|
||||
}
|
||||
|
||||
DocumentLoadListener::ProcessBehavior GetProcessSwitchBehavior(
|
||||
Element* aBrowserElement) {
|
||||
if (aBrowserElement->HasAttribute(u"maychangeremoteness"_ns)) {
|
||||
return DocumentLoadListener::ProcessBehavior::PROCESS_BEHAVIOR_STANDARD;
|
||||
}
|
||||
nsCOMPtr<nsIBrowser> browser = aBrowserElement->AsBrowser();
|
||||
bool isRemoteBrowser = false;
|
||||
browser->GetIsRemoteBrowser(&isRemoteBrowser);
|
||||
if (isRemoteBrowser) {
|
||||
return DocumentLoadListener::ProcessBehavior::
|
||||
PROCESS_BEHAVIOR_SUBFRAME_ONLY;
|
||||
}
|
||||
return DocumentLoadListener::ProcessBehavior::PROCESS_BEHAVIOR_DISABLED;
|
||||
}
|
||||
|
||||
static bool ContextCanProcessSwitch(CanonicalBrowsingContext* aBrowsingContext,
|
||||
WindowGlobalParent* aParentWindow) {
|
||||
if (NS_WARN_IF(!aBrowsingContext)) {
|
||||
|
@ -1507,26 +1522,20 @@ static bool ContextCanProcessSwitch(CanonicalBrowsingContext* aBrowsingContext,
|
|||
return false;
|
||||
}
|
||||
|
||||
nsIBrowser::ProcessBehavior processBehavior =
|
||||
nsIBrowser::PROCESS_BEHAVIOR_DISABLED;
|
||||
nsresult rv = browser->GetProcessSwitchBehavior(&processBehavior);
|
||||
if (NS_FAILED(rv)) {
|
||||
MOZ_ASSERT_UNREACHABLE(
|
||||
"nsIBrowser::GetProcessSwitchBehavior shouldn't fail");
|
||||
MOZ_LOG(gProcessIsolationLog, LogLevel::Warning,
|
||||
("Process Switch Abort: failed to get process switch behavior"));
|
||||
return false;
|
||||
}
|
||||
DocumentLoadListener::ProcessBehavior processBehavior =
|
||||
GetProcessSwitchBehavior(browserElement);
|
||||
|
||||
// Check if the process switch we're considering is disabled by the
|
||||
// <browser>'s process behavior.
|
||||
if (processBehavior == nsIBrowser::PROCESS_BEHAVIOR_DISABLED) {
|
||||
if (processBehavior ==
|
||||
DocumentLoadListener::ProcessBehavior::PROCESS_BEHAVIOR_DISABLED) {
|
||||
MOZ_LOG(gProcessIsolationLog, LogLevel::Warning,
|
||||
("Process Switch Abort: switch disabled by <browser>"));
|
||||
return false;
|
||||
}
|
||||
if (!aParentWindow &&
|
||||
processBehavior == nsIBrowser::PROCESS_BEHAVIOR_SUBFRAME_ONLY) {
|
||||
if (!aParentWindow && processBehavior ==
|
||||
DocumentLoadListener::ProcessBehavior::
|
||||
PROCESS_BEHAVIOR_SUBFRAME_ONLY) {
|
||||
MOZ_LOG(gProcessIsolationLog, LogLevel::Warning,
|
||||
("Process Switch Abort: toplevel switch disabled by <browser>"));
|
||||
return false;
|
||||
|
|
|
@ -289,6 +289,25 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
|
|||
|
||||
bool IsDocumentLoad() const { return mIsDocumentLoad; }
|
||||
|
||||
// Determine what process switching behavior a browser element should have.
|
||||
enum ProcessBehavior : uint8_t {
|
||||
// Gecko won't automatically change which process this frame, or it's
|
||||
// subframes, are loaded in.
|
||||
PROCESS_BEHAVIOR_DISABLED,
|
||||
|
||||
// If `useRemoteTabs` is enabled, Gecko will change which process this frame
|
||||
// is loaded in automatically, without calling `performProcessSwitch`.
|
||||
// When `useRemoteSubframes` is enabled, subframes will change processes.
|
||||
PROCESS_BEHAVIOR_STANDARD,
|
||||
|
||||
// Gecko won't automatically change which process this frame is loaded, but
|
||||
// when `useRemoteSubframes` is enabled, subframes will change processes.
|
||||
//
|
||||
// NOTE: This configuration is included only for backwards compatibility,
|
||||
// and will be removed, as it can easily lead to invalid behavior.
|
||||
PROCESS_BEHAVIOR_SUBFRAME_ONLY,
|
||||
};
|
||||
|
||||
protected:
|
||||
virtual ~DocumentLoadListener();
|
||||
|
||||
|
|
|
@ -1803,25 +1803,6 @@
|
|||
return origins;
|
||||
}
|
||||
|
||||
get processSwitchBehavior() {
|
||||
// If a `remotenessChangeHandler` is attached to this browser, it supports
|
||||
// having its toplevel process switched dynamically in response to
|
||||
// navigations.
|
||||
if (this.hasAttribute("maychangeremoteness")) {
|
||||
return Ci.nsIBrowser.PROCESS_BEHAVIOR_STANDARD;
|
||||
}
|
||||
|
||||
// For backwards compatibility, we need to mark remote, but
|
||||
// non-`allowremote`, frames as `PROCESS_BEHAVIOR_SUBFRAME_ONLY`, as some
|
||||
// tests rely on it.
|
||||
// FIXME: Remove this?
|
||||
if (this.isRemoteBrowser) {
|
||||
return Ci.nsIBrowser.PROCESS_BEHAVIOR_SUBFRAME_ONLY;
|
||||
}
|
||||
// Otherwise, don't allow gecko-initiated toplevel process switches.
|
||||
return Ci.nsIBrowser.PROCESS_BEHAVIOR_DISABLED;
|
||||
}
|
||||
|
||||
// This method is replaced by frontend code in order to delay performing the
|
||||
// process switch until some async operatin is completed.
|
||||
//
|
||||
|
|
Загрузка…
Ссылка в новой задаче