Bug 1602318 - Disable parent-initiated loads when using devtools. r=nika,ochameau

Differential Revision: https://phabricator.services.mozilla.com/D71136
This commit is contained in:
Matt Woodrow 2020-04-24 07:01:02 +00:00
Родитель fc342b8877
Коммит b3c5f89904
4 изменённых файлов: 20 добавлений и 0 удалений

Просмотреть файл

@ -201,6 +201,7 @@ already_AddRefed<BrowsingContext> BrowsingContext::CreateDetached(
nsILoadInfo::EMBEDDER_POLICY_NULL);
context->mFields.SetWithoutSyncing<IDX_OpenerPolicy>(
nsILoadInfo::OPENER_POLICY_UNSAFE_NONE);
context->mFields.SetWithoutSyncing<IDX_WatchedByDevtools>(false);
if (aOpener && aOpener->SameOriginWithTop()) {
// We inherit the opener policy if there is a creator and if the creator's
@ -1895,6 +1896,12 @@ bool BrowsingContext::CanSet(FieldIndex<IDX_AllowPlugins>,
return CheckOnlyOwningProcessCanSet(aSource);
}
bool BrowsingContext::CanSet(FieldIndex<IDX_WatchedByDevtools>,
const bool& aWatchedByDevtools,
ContentParent* aSource) {
return CheckOnlyOwningProcessCanSet(aSource);
}
bool BrowsingContext::CanSet(FieldIndex<IDX_UserAgentOverride>,
const nsString& aUserAgent,
ContentParent* aSource) {

Просмотреть файл

@ -123,6 +123,7 @@ class WindowProxyHolder;
FIELD(MessageManagerGroup, nsString) \
FIELD(MaxTouchPointsOverride, uint8_t) \
FIELD(FullZoom, float) \
FIELD(WatchedByDevtools, bool) \
FIELD(TextZoom, float)
// BrowsingContext, in this context, is the cross process replicated
@ -701,6 +702,8 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
ContentParent* aSource);
bool CanSet(FieldIndex<IDX_AllowPlugins>, const bool& aAllowPlugins,
ContentParent* aSource);
bool CanSet(FieldIndex<IDX_WatchedByDevtools>, const bool& aWatchedByDevtools,
ContentParent* aSource);
template <size_t I, typename T>
bool CanSet(FieldIndex<I>, const T&, ContentParent*) {

Просмотреть файл

@ -536,6 +536,15 @@ bool CanonicalBrowsingContext::AttemptLoadURIInParent(
return false;
}
// We currently don't support initiating loads in the parent when they are
// watched by devtools. This is because devtools tracks loads using content
// process notifications, which happens after the load is initiated in this
// case. Devtools clears all prior requests when it detects a new navigation,
// so it drops the main document load that happened here.
if (GetWatchedByDevtools()) {
return false;
}
// DocumentChannel currently only supports connecting channels into the
// content process, so we can only support schemes that will always be loaded
// there for now. Restrict to just http(s) for simplicity.

Просмотреть файл

@ -12845,5 +12845,6 @@ nsDocShell::GetWatchedByDevtools(bool* aWatched) {
NS_IMETHODIMP
nsDocShell::SetWatchedByDevtools(bool aWatched) {
mWatchedByDevtools = aWatched;
mBrowsingContext->SetWatchedByDevtools(aWatched);
return NS_OK;
}