Backed out 19 changesets (bug 1602318) for causing multiple failures

Backed out changeset 4b3345b2e33b (bug 1602318)
Backed out changeset 7240b27afe28 (bug 1602318)
Backed out changeset a7091729d8c9 (bug 1602318)
Backed out changeset e496ab6c0857 (bug 1602318)
Backed out changeset 184da6309f0c (bug 1602318)
Backed out changeset 79b540f8619d (bug 1602318)
Backed out changeset b298015ee960 (bug 1602318)
Backed out changeset 6d0783cd5e01 (bug 1602318)
Backed out changeset cbc308486b17 (bug 1602318)
Backed out changeset 94142944fb54 (bug 1602318)
Backed out changeset 7c1eeb299b78 (bug 1602318)
Backed out changeset 0fc27502503a (bug 1602318)
Backed out changeset 0fc27c2e09d9 (bug 1602318)
Backed out changeset b5e2aa4741b2 (bug 1602318)
Backed out changeset 57d568114c5a (bug 1602318)
Backed out changeset 8f7360d827dc (bug 1602318)
Backed out changeset 78930a97c2df (bug 1602318)
Backed out changeset 8015780587cd (bug 1602318)
Backed out changeset bc9da03cb3a3 (bug 1602318)
This commit is contained in:
Noemi Erli 2020-04-21 03:46:41 +03:00
Родитель 592046ecf0
Коммит c0bd1834c8
54 изменённых файлов: 341 добавлений и 888 удалений

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

@ -15,7 +15,7 @@ add_task(async function() {
let tab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.loadURI(tab.linkedBrowser, uri);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, uri);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
await TabStateFlusher.flush(tab.linkedBrowser);
let key = tab.linkedBrowser.permanentKey;

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

@ -198,7 +198,7 @@ add_task(async function navigate_around() {
// This is accessed in debug only.
},
"toolkit.cosmeticAnimations.enabled": {
min: 39,
min: 45,
max: 55,
},
};

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

@ -71,7 +71,7 @@ var waitForLoad = async function(uri) {
};
gBrowser.selectedBrowser.webNavigation.loadURI(uri, loadURIOptions);
await BrowserTestUtils.browserStopped(gBrowser, uri);
await BrowserTestUtils.browserStopped(gBrowser);
// Some of the documents we're using in this test use Fluent,
// and they may finish localization later.
@ -101,7 +101,7 @@ var waitForLoadWithFlags = async function(
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});
await BrowserTestUtils.browserStopped(gBrowser, uri);
await BrowserTestUtils.browserStopped(gBrowser);
if (!(flags & Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY)) {
if (flags & Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY) {
gExpectedHistory.entries.pop();

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

@ -215,15 +215,11 @@ add_task(async function test_without_tabs_permission() {
await do_test_update(async function background() {
const url =
"http://mochi.test:8888/browser/browser/components/extensions/test/browser/context_tabs_onUpdated_page.html";
let tab = null;
const tab = await browser.tabs.create({ url });
let count = 0;
browser.tabs.onUpdated.addListener(function onUpdated(tabId, changeInfo) {
// An attention change can happen during tabs.create, so
// we can't compare against tab yet.
if (!("attention" in changeInfo)) {
browser.test.assertEq(tabId, tab.id, "Check tab id");
}
browser.test.log(`onUpdated: ${JSON.stringify(changeInfo)}`);
browser.test.assertFalse(
@ -241,9 +237,7 @@ add_task(async function test_without_tabs_permission() {
if (changeInfo.status == "complete") {
count++;
if (count === 1) {
browser.tabs.reload(tabId);
} else {
if (count === 2) {
browser.test.log("Reload complete");
browser.tabs.onUpdated.removeListener(onUpdated);
browser.tabs.remove(tabId);
@ -252,7 +246,7 @@ add_task(async function test_without_tabs_permission() {
}
});
tab = await browser.tabs.create({ url });
browser.tabs.reload(tab.id);
}, false /* withPermissions */);
});

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

@ -185,17 +185,15 @@ async function testSearchEngine(engineDetails) {
await test.preTest(tab);
}
let promises = [
BrowserTestUtils.waitForDocLoadAndStopIt(
"https://www.google.com/search?client=" + test.code + "&q=foo",
tab
),
BrowserTestUtils.browserStopped(tab.linkedBrowser, null, true),
];
let stateChangePromise = promiseStateChangeURI();
await test.run(tab);
await Promise.all(promises);
let receivedURI = await stateChangePromise;
let receivedURLParams = new URLSearchParams(receivedURI.split("?")[1]);
Assert.equal(receivedURLParams.get("client"), test.code);
if (test.postTest) {
await test.postTest(tab);

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

@ -189,14 +189,13 @@ async function testSearchEngine(engineDetails) {
await test.preTest(tab);
}
let promises = [
BrowserTestUtils.waitForDocLoadAndStopIt(test.searchURL, tab),
BrowserTestUtils.browserStopped(tab.linkedBrowser, null, true),
];
let stateChangePromise = promiseStateChangeURI();
await test.run(tab);
await Promise.all(promises);
let receivedURI = await stateChangePromise;
Assert.equal(receivedURI, test.searchURL);
}
engine.alias = undefined;

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

@ -109,6 +109,73 @@ async function promiseNewEngine(basename, options = {}) {
return engine;
}
let promiseStateChangeFrameScript =
"data:," +
encodeURIComponent(
`(${() => {
/* globals docShell, sendAsyncMessage */
const global = this;
const LISTENER = Symbol("listener");
let listener = {
QueryInterface: ChromeUtils.generateQI([
"nsISupportsWeakReference",
"nsIWebProgressListener",
]),
onStateChange: function onStateChange(webProgress, req, flags, status) {
// Only care about top-level document starts
if (
!webProgress.isTopLevel ||
!(flags & Ci.nsIWebProgressListener.STATE_START)
) {
return;
}
req.QueryInterface(Ci.nsIChannel);
let spec = req.originalURI.spec;
if (spec == "about:blank") {
return;
}
delete global[LISTENER];
docShell.removeProgressListener(listener);
req.cancel(Cr.NS_ERROR_FAILURE);
sendAsyncMessage("PromiseStateChange::StateChanged", spec);
},
};
// Make sure the weak reference stays alive.
global[LISTENER] = listener;
docShell.QueryInterface(Ci.nsIWebProgress);
docShell.addProgressListener(
listener,
Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT
);
}})()`
);
function promiseStateChangeURI() {
const MSG = "PromiseStateChange::StateChanged";
return new Promise(resolve => {
let mm = window.getGroupMessageManager("browsers");
mm.loadFrameScript(promiseStateChangeFrameScript, true);
let listener = msg => {
mm.removeMessageListener(MSG, listener);
mm.removeDelayedFrameScript(promiseStateChangeFrameScript);
resolve(msg.data);
};
mm.addMessageListener(MSG, listener);
});
}
// Get an array of the one-off buttons.
function getOneOffs() {
let oneOffs = [];

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

@ -84,6 +84,7 @@ skip-if = fission || debug # bug 1211084
[browser_backup_recovery.js]
skip-if = (verify && debug && (os == 'linux'))
[browser_broadcast.js]
skip-if = fission || (os == 'mac') || (os == 'linux' && !debug && bits == 64) # Bug 1533895; Fission: SecurityError: The operation is insecure.
[browser_capabilities.js]
[browser_cleaner.js]
[browser_crashedTabs.js]

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

@ -10,7 +10,7 @@ const INITIAL_VALUE = "browser_broadcast.js-initial-value-" + Date.now();
* closing a tab.
*/
add_task(async function flush_on_tabclose() {
let tab = await createTabWithStorageData(["http://example.com/"]);
let tab = await createTabWithStorageData(["http://example.com"]);
let browser = tab.linkedBrowser;
await modifySessionStorage(browser, { test: "on-tab-close" });
@ -33,7 +33,7 @@ add_task(async function flush_on_tabclose() {
* duplicating a tab.
*/
add_task(async function flush_on_duplicate() {
let tab = await createTabWithStorageData(["http://example.com/"]);
let tab = await createTabWithStorageData(["http://example.com"]);
let browser = tab.linkedBrowser;
await modifySessionStorage(browser, { test: "on-duplicate" });
@ -61,7 +61,7 @@ add_task(async function flush_on_duplicate() {
*/
add_task(async function flush_on_windowclose() {
let win = await promiseNewWindow();
let tab = await createTabWithStorageData(["http://example.com/"], win);
let tab = await createTabWithStorageData(["http://example.com"], win);
let browser = tab.linkedBrowser;
await modifySessionStorage(browser, { test: "on-window-close" });
@ -84,7 +84,7 @@ add_task(async function flush_on_windowclose() {
* (via e.g. setTabState) and does not overwrite the new data.
*/
add_task(async function flush_on_settabstate() {
let tab = await createTabWithStorageData(["http://example.com/"]);
let tab = await createTabWithStorageData(["http://example.com"]);
let browser = tab.linkedBrowser;
// Flush to make sure our tab state is up-to-date.
@ -115,7 +115,7 @@ add_task(async function flush_on_settabstate() {
* that hasn't been received by chrome, yet.
*/
add_task(async function flush_on_tabclose_racy() {
let tab = await createTabWithStorageData(["http://example.com/"]);
let tab = await createTabWithStorageData(["http://example.com"]);
let browser = tab.linkedBrowser;
// Flush to make sure we start with an empty queue.
@ -152,8 +152,7 @@ async function createTabWithStorageData(urls, win = window) {
for (let url of urls) {
BrowserTestUtils.loadURI(browser, url);
await promiseBrowserLoaded(browser, true, url);
dump("Loaded url: " + url + "\n");
await promiseBrowserLoaded(browser);
await modifySessionStorage(browser, { test: INITIAL_VALUE });
}

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

@ -55,16 +55,11 @@ add_task(async function checkCtrlWorks() {
expectedURL,
gBrowser.selectedBrowser
);
let promiseStopped = BrowserTestUtils.browserStopped(
gBrowser.selectedBrowser,
undefined,
true
);
gURLBar.focus();
gURLBar.inputField.value = inputValue.slice(0, -1);
EventUtils.sendString(inputValue.slice(-1));
EventUtils.synthesizeKey("KEY_Enter", options);
await Promise.all([promiseLoad, promiseStopped]);
await promiseLoad;
}
});

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

@ -96,7 +96,8 @@ BrowserElementWebNavigation.prototype = {
},
stop(flags) {
this._browser.browsingContext.stop(flags);
// No equivalent in the current BrowserElement API
this._sendMessage("WebNavigation:Stop", { flags });
},
get document() {

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

@ -200,7 +200,6 @@ 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
@ -1103,47 +1102,6 @@ bool BrowsingContext::CanSetOriginAttributes() {
return true;
}
Nullable<WindowProxyHolder> BrowsingContext::GetAssociatedWindow() {
// nsILoadContext usually only returns same-process windows,
// so we intentionally return nullptr if this BC is out of
// process.
if (IsInProcess()) {
return WindowProxyHolder(this);
}
return nullptr;
}
Nullable<WindowProxyHolder> BrowsingContext::GetTopWindow() {
return Top()->GetAssociatedWindow();
}
Element* BrowsingContext::GetTopFrameElement() {
return Top()->GetEmbedderElement();
}
void BrowsingContext::SetUsePrivateBrowsing(bool aUsePrivateBrowsing,
ErrorResult& aError) {
nsresult rv = SetUsePrivateBrowsing(aUsePrivateBrowsing);
if (NS_FAILED(rv)) {
aError.Throw(rv);
}
}
void BrowsingContext::SetUseTrackingProtectionWebIDL(
bool aUseTrackingProtection) {
SetForceEnableTrackingProtection(aUseTrackingProtection);
}
void BrowsingContext::GetOriginAttributes(JSContext* aCx,
JS::MutableHandle<JS::Value> aVal,
ErrorResult& aError) {
AssertOriginAttributesMatchPrivateBrowsing();
if (!ToJSValue(aCx, mOriginAttributes, aVal)) {
aError.NoteJSContextException(aCx);
}
}
NS_IMETHODIMP BrowsingContext::GetAssociatedWindow(
mozIDOMWindowProxy** aAssociatedWindow) {
nsCOMPtr<mozIDOMWindowProxy> win = GetDOMWindow();
@ -1156,11 +1114,17 @@ NS_IMETHODIMP BrowsingContext::GetTopWindow(mozIDOMWindowProxy** aTopWindow) {
}
NS_IMETHODIMP BrowsingContext::GetTopFrameElement(Element** aTopFrameElement) {
RefPtr<Element> topFrameElement = GetTopFrameElement();
RefPtr<Element> topFrameElement = Top()->GetEmbedderElement();
topFrameElement.forget(aTopFrameElement);
return NS_OK;
}
NS_IMETHODIMP BrowsingContext::GetNestedFrameId(uint64_t* aNestedFrameId) {
// FIXME: nestedFrameId should be removed, as it was only used by B2G.
*aNestedFrameId = 0;
return NS_OK;
}
NS_IMETHODIMP BrowsingContext::GetIsContent(bool* aIsContent) {
*aIsContent = IsContent();
return NS_OK;
@ -1336,7 +1300,6 @@ void BrowsingContext::AssertOriginAttributesMatchPrivateBrowsing() {
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(BrowsingContext)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsILoadContext)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
@ -1459,10 +1422,6 @@ nsresult BrowsingContext::LoadURI(nsDocShellLoadState* aLoadState,
return NS_ERROR_UNEXPECTED;
}
if (Canonical()->AttemptLoadURIInParent(aLoadState, aSetNavigating)) {
return NS_OK;
}
if (ContentParent* cp = Canonical()->GetContentParent()) {
Unused << cp->SendLoadURI(this, aLoadState, aSetNavigating);
}
@ -1871,12 +1830,6 @@ 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) {

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

@ -121,8 +121,7 @@ class WindowProxyHolder;
FIELD(UserAgentOverride, nsString) \
FIELD(EmbedderElementType, Maybe<nsString>) \
FIELD(MessageManagerGroup, nsString) \
FIELD(MaxTouchPointsOverride, uint8_t) \
FIELD(WatchedByDevtools, bool)
FIELD(MaxTouchPointsOverride, uint8_t)
// BrowsingContext, in this context, is the cross process replicated
// environment in which information about documents is stored. In
@ -259,8 +258,7 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
void RestoreChildren(Children&& aChildren, bool aFromIPC = false);
// Triggers a load in the process which currently owns this BrowsingContext.
nsresult LoadURI(nsDocShellLoadState* aLoadState,
bool aSetNavigating = false);
nsresult LoadURI(nsDocShellLoadState* aLoadState, bool aSetNavigating = false);
nsresult InternalLoad(nsDocShellLoadState* aLoadState,
nsIDocShell** aDocShell, nsIRequest** aRequest);
@ -353,19 +351,6 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
BrowsingContextGroup* Group() { return mGroup; }
// WebIDL bindings for nsILoadContext
Nullable<WindowProxyHolder> GetAssociatedWindow();
Nullable<WindowProxyHolder> GetTopWindow();
Element* GetTopFrameElement();
bool GetIsContent() { return IsContent(); }
void SetUsePrivateBrowsing(bool aUsePrivateBrowsing, ErrorResult& aError);
// Needs a different name to disambiguate from the xpidl method with
// the same signature but different return value.
void SetUseTrackingProtectionWebIDL(bool aUseTrackingProtection);
bool UseTrackingProtectionWebIDL() { return UseTrackingProtection(); }
void GetOriginAttributes(JSContext* aCx, JS::MutableHandle<JS::Value> aVal,
ErrorResult& aError);
bool InRDMPane() const { return GetInRDMPane(); }
bool IsLoading();
@ -697,8 +682,6 @@ 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*) {

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

@ -13,12 +13,8 @@
#include "mozilla/dom/MediaController.h"
#include "mozilla/dom/MediaControlService.h"
#include "mozilla/dom/PlaybackController.h"
#include "mozilla/net/DocumentLoadListener.h"
#include "mozilla/net/BrowsingContextDocumentChannel.h"
#include "mozilla/ipc/ProtocolUtils.h"
#include "mozilla/NullPrincipal.h"
#include "mozilla/net/DocumentLoadListener.h"
#include "nsIWebNavigation.h"
#include "nsGlobalWindowOuter.h"
@ -285,25 +281,6 @@ void CanonicalBrowsingContext::LoadURI(const nsAString& aURI,
LoadURI(loadState, true);
}
void CanonicalBrowsingContext::Stop(uint32_t aStopFlags) {
if (IsDiscarded()) {
return;
}
// Stop any known network loads if necessary.
if (mCurrentLoad && (aStopFlags & nsIWebNavigation::STOP_NETWORK)) {
mCurrentLoad->Cancel(NS_BINDING_ABORTED);
}
// Ask the docshell to stop to handle loads that haven't
// yet reached here, as well as non-network activity.
if (GetDocShell()) {
nsDocShell::Cast(GetDocShell())->Stop(aStopFlags);
} else if (ContentParent* cp = GetContentParent()) {
Unused << cp->SendStopLoad(this, aStopFlags);
}
}
void CanonicalBrowsingContext::PendingRemotenessChange::Complete(
ContentParent* aContentParent) {
if (!mPromise) {
@ -566,87 +543,6 @@ MediaController* CanonicalBrowsingContext::GetMediaController() {
return mTabMediaController;
}
bool CanonicalBrowsingContext::AttemptLoadURIInParent(
nsDocShellLoadState* aLoadState, bool aSetNavigating) {
// We currently only support starting loads directly from the
// CanonicalBrowsingContext for top-level BCs.
if (!IsTopContent() || !StaticPrefs::browser_tabs_documentchannel() ||
!StaticPrefs::browser_tabs_documentchannel_parent_initiated()) {
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.
if (!aLoadState->URI()->SchemeIs("http") &&
!aLoadState->URI()->SchemeIs("https")) {
return false;
}
uint64_t outerWindowId = 0;
if (WindowGlobalParent* global = GetCurrentWindowGlobal()) {
nsCOMPtr<nsIURI> currentURI = global->GetDocumentURI();
if (currentURI) {
bool newURIHasRef = false;
aLoadState->URI()->GetHasRef(&newURIHasRef);
bool equalsExceptRef = false;
aLoadState->URI()->EqualsExceptRef(currentURI, &equalsExceptRef);
if (equalsExceptRef && newURIHasRef) {
// This navigation is same-doc WRT the current one, we should pass it
// down to the docshell to be handled.
return false;
}
}
// If the current document has a beforeunload listener, then we need to
// start the load in that process after we fire the event.
if (global->HasBeforeUnload()) {
return false;
}
outerWindowId = global->OuterWindowId();
}
RefPtr<net::BrowsingContextDocumentChannel> docChannel =
new net::BrowsingContextDocumentChannel(this);
// If we successfully open the DocumentChannel, then it'll register
// itself in mCurrentLoad and be kept alive until it completes
// loading.
return docChannel->Open(aLoadState, outerWindowId, aSetNavigating);
}
bool CanonicalBrowsingContext::StartDocumentLoad(
net::DocumentLoadListener* aLoad) {
if (mCurrentLoad) {
// If the new load is originates from a content process,
// and the current load is from the parent, then we consider
// the existing load higher precendence, and reject the new
// one.
if (aLoad->OtherPid() && !mCurrentLoad->OtherPid()) {
return false;
}
mCurrentLoad->Cancel(NS_BINDING_ABORTED);
}
mCurrentLoad = aLoad;
return true;
}
void CanonicalBrowsingContext::EndDocumentLoad(
net::DocumentLoadListener* aLoad) {
if (mCurrentLoad == aLoad) {
mCurrentLoad = nullptr;
}
}
NS_IMPL_CYCLE_COLLECTION_INHERITED(CanonicalBrowsingContext, BrowsingContext,
mSessionHistory)

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

@ -19,10 +19,6 @@
#include "nsISHEntry.h"
namespace mozilla {
namespace net {
class DocumentLoadListener;
}
namespace dom {
class WindowGlobalParent;
@ -104,7 +100,6 @@ class CanonicalBrowsingContext final : public BrowsingContext {
using BrowsingContext::LoadURI;
void LoadURI(const nsAString& aURI, const LoadURIOptions& aOptions,
ErrorResult& aError);
void Stop(uint32_t aStopFlags);
using RemotenessPromise = MozPromise<RefPtr<BrowserParent>, nsresult, false>;
RefPtr<RemotenessPromise> ChangeFrameRemoteness(const nsAString& aRemoteType,
@ -121,9 +116,6 @@ class CanonicalBrowsingContext final : public BrowsingContext {
// if the top-level browsing context has been discarded.
MediaController* GetMediaController();
bool AttemptLoadURIInParent(nsDocShellLoadState* aLoadState,
bool aSetNavigating);
bool HasHistoryEntry(nsISHEntry* aEntry) const {
return aEntry && (aEntry == mOSHE || aEntry == mLSHE);
}
@ -184,16 +176,6 @@ class CanonicalBrowsingContext final : public BrowsingContext {
uint64_t mPendingSwitchId;
};
friend class net::DocumentLoadListener;
// Called when a DocumentLoadListener is created to start a load for
// this browsing context. Returns false if a higher priority load is
// already in-progress and the new one has been rejected.
bool StartDocumentLoad(net::DocumentLoadListener* aLoad);
// Called once DocumentLoadListener completes handling a load, and it
// is either complete, or handed off to the final channel to deliver
// data to the destination docshell.
void EndDocumentLoad(net::DocumentLoadListener* aLoad);
// XXX(farre): Store a ContentParent pointer here rather than mProcessId?
// Indicates which process owns the docshell.
uint64_t mProcessId;
@ -215,8 +197,6 @@ class CanonicalBrowsingContext final : public BrowsingContext {
// context.
RefPtr<MediaController> mTabMediaController;
RefPtr<net::DocumentLoadListener> mCurrentLoad;
// These are being mirrored from docshell
nsCOMPtr<nsISHEntry> mOSHE;
nsCOMPtr<nsISHEntry> mLSHE;

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

@ -20,6 +20,7 @@ NS_IMPL_ISUPPORTS(LoadContext, nsILoadContext, nsIInterfaceRequestor)
LoadContext::LoadContext(nsIPrincipal* aPrincipal,
nsILoadContext* aOptionalBase)
: mTopFrameElement(nullptr),
mNestedFrameId(0),
mIsContent(true),
mUseRemoteTabs(false),
mUseRemoteSubframes(false),
@ -67,6 +68,13 @@ LoadContext::GetTopFrameElement(dom::Element** aElement) {
return NS_OK;
}
NS_IMETHODIMP
LoadContext::GetNestedFrameId(uint64_t* aId) {
NS_ENSURE_ARG(aId);
*aId = mNestedFrameId;
return NS_OK;
}
NS_IMETHODIMP
LoadContext::GetIsContent(bool* aIsContent) {
MOZ_ASSERT(mIsNotNull);

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

@ -36,6 +36,21 @@ class LoadContext final : public nsILoadContext, public nsIInterfaceRequestor {
LoadContext(const IPC::SerializedLoadContext& aToCopy,
dom::Element* aTopFrameElement, OriginAttributes& aAttrs)
: mTopFrameElement(do_GetWeakReference(aTopFrameElement)),
mNestedFrameId(0),
mIsContent(aToCopy.mIsContent),
mUseRemoteTabs(aToCopy.mUseRemoteTabs),
mUseRemoteSubframes(aToCopy.mUseRemoteSubframes),
mUseTrackingProtection(aToCopy.mUseTrackingProtection),
#ifdef DEBUG
mIsNotNull(aToCopy.mIsNotNull),
#endif
mOriginAttributes(aAttrs) {
}
LoadContext(const IPC::SerializedLoadContext& aToCopy,
uint64_t aNestedFrameId, OriginAttributes& aAttrs)
: mTopFrameElement(nullptr),
mNestedFrameId(aNestedFrameId),
mIsContent(aToCopy.mIsContent),
mUseRemoteTabs(aToCopy.mUseRemoteTabs),
mUseRemoteSubframes(aToCopy.mUseRemoteSubframes),
@ -51,6 +66,7 @@ class LoadContext final : public nsILoadContext, public nsIInterfaceRequestor {
bool aUseRemoteSubframes, bool aUseTrackingProtection,
const OriginAttributes& aAttrs)
: mTopFrameElement(do_GetWeakReference(aTopFrameElement)),
mNestedFrameId(0),
mIsContent(aIsContent),
mUseRemoteTabs(aUseRemoteTabs),
mUseRemoteSubframes(aUseRemoteSubframes),
@ -66,6 +82,7 @@ class LoadContext final : public nsILoadContext, public nsIInterfaceRequestor {
// Constructor taking reserved origin attributes.
explicit LoadContext(OriginAttributes& aAttrs)
: mTopFrameElement(nullptr),
mNestedFrameId(0),
mIsContent(false),
mUseRemoteTabs(false),
mUseRemoteSubframes(false),
@ -84,6 +101,7 @@ class LoadContext final : public nsILoadContext, public nsIInterfaceRequestor {
~LoadContext() {}
nsWeakPtr mTopFrameElement;
uint64_t mNestedFrameId;
bool mIsContent;
bool mUseRemoteTabs;
bool mUseRemoteSubframes;

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

@ -9792,6 +9792,26 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
mContentTypeHint.Truncate();
}
if (mLoadType == LOAD_NORMAL_ALLOW_MIXED_CONTENT ||
mLoadType == LOAD_RELOAD_ALLOW_MIXED_CONTENT) {
rv = SetMixedContentChannel(channel);
NS_ENSURE_SUCCESS(rv, rv);
} else if (mMixedContentChannel) {
/*
* If the user "Disables Protection on This Page", we call
* SetMixedContentChannel for the first time, otherwise
* mMixedContentChannel is still null.
* Later, if the new channel passes a same orign check, we remember the
* users decision by calling SetMixedContentChannel using the new channel.
* This way, the user does not have to click the disable protection button
* over and over for browsing the same site.
*/
rv = nsContentUtils::CheckSameOrigin(mMixedContentChannel, channel);
if (NS_FAILED(rv) || NS_FAILED(SetMixedContentChannel(channel))) {
SetMixedContentChannel(nullptr);
}
}
rv = DoChannelLoad(
channel, uriLoader,
aLoadState->HasLoadFlags(INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER));
@ -9999,26 +10019,6 @@ nsresult nsDocShell::OpenInitializedChannel(nsIChannel* aChannel,
uint32_t aOpenFlags) {
nsresult rv = NS_OK;
if (mLoadType == LOAD_NORMAL_ALLOW_MIXED_CONTENT ||
mLoadType == LOAD_RELOAD_ALLOW_MIXED_CONTENT) {
rv = SetMixedContentChannel(aChannel);
NS_ENSURE_SUCCESS(rv, rv);
} else if (mMixedContentChannel) {
/*
* If the user "Disables Protection on This Page", we call
* SetMixedContentChannel for the first time, otherwise
* mMixedContentChannel is still null.
* Later, if the new channel passes a same orign check, we remember the
* users decision by calling SetMixedContentChannel using the new channel.
* This way, the user does not have to click the disable protection button
* over and over for browsing the same site.
*/
rv = nsContentUtils::CheckSameOrigin(mMixedContentChannel, aChannel);
if (NS_FAILED(rv) || NS_FAILED(SetMixedContentChannel(aChannel))) {
SetMixedContentChannel(nullptr);
}
}
// If anything fails here, make sure to clear our initial ClientSource.
auto cleanupInitialClient =
MakeScopeExit([&] { mInitialClientSource.reset(); });
@ -10070,7 +10070,6 @@ nsresult nsDocShell::OpenInitializedChannel(nsIChannel* aChannel,
// ClientInfo, so we just need to allocate a corresponding ClientSource.
CreateReservedSourceIfNeeded(aChannel,
win->EventTargetFor(TaskCategory::Other));
rv = NS_OK;
} else {
rv = AddClientChannelHelper(aChannel, std::move(noReservedClient),
GetInitialClientInfo(),
@ -11765,6 +11764,11 @@ nsDocShell::GetTopFrameElement(Element** aElement) {
return mBrowsingContext->GetTopFrameElement(aElement);
}
NS_IMETHODIMP
nsDocShell::GetNestedFrameId(uint64_t* aId) {
return mBrowsingContext->GetNestedFrameId(aId);
}
NS_IMETHODIMP
nsDocShell::GetUseTrackingProtection(bool* aUseTrackingProtection) {
return mBrowsingContext->GetUseTrackingProtection(aUseTrackingProtection);
@ -12436,6 +12440,10 @@ nsDocShell::ResumeRedirectedLoad(uint64_t aIdentifier, int32_t aHistoryIndex) {
aLoadState->GetPendingRedirectedChannel(), previousURI,
previousFlags, aRedirects);
MOZ_ASSERT(
(self->mCurrentURI && NS_IsAboutBlank(self->mCurrentURI)) ||
!self->mTiming,
"timing object can't already exists in non-about:blank loads");
self->mTiming = new nsDOMNavigationTiming(self, aTiming);
// If we're performing a history load, locate the correct history entry,
@ -12845,6 +12853,5 @@ nsDocShell::GetWatchedByDevtools(bool* aWatched) {
NS_IMETHODIMP
nsDocShell::SetWatchedByDevtools(bool aWatched) {
mWatchedByDevtools = aWatched;
mBrowsingContext->SetWatchedByDevtools(aWatched);
return NS_OK;
}

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

@ -305,6 +305,7 @@ class nsDocShell final : public nsDocLoader,
NS_IMETHOD GetAssociatedWindow(mozIDOMWindowProxy**) override;
NS_IMETHOD GetTopWindow(mozIDOMWindowProxy**) override;
NS_IMETHOD GetTopFrameElement(mozilla::dom::Element**) override;
NS_IMETHOD GetNestedFrameId(uint64_t*) override;
NS_IMETHOD GetIsContent(bool*) override;
NS_IMETHOD GetUsePrivateBrowsing(bool*) override;
NS_IMETHOD SetUsePrivateBrowsing(bool) override;

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

@ -55,6 +55,14 @@ interface nsILoadContext : nsISupports
*/
readonly attribute Element topFrameElement;
/**
* If this LoadContext corresponds to a nested remote iframe, we don't have
* access to the topFrameElement. Instead, we must use this id to send
* messages. A return value of 0 signifies that this load context is not for
* a nested frame.
*/
readonly attribute unsigned long long nestedFrameId;
/**
* True if the load context is content (as opposed to chrome). This is
* determined based on the type of window the load is performed in, NOT based

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

@ -523,7 +523,8 @@ AuthPromptWrapper.prototype = {
);
let frame = context.topFrameElement;
if (!frame) {
return false;
// This function returns a boolean value
return !!context.nestedFrameId;
}
if (!BrowserElementPromptService.getBrowserElementParentForFrame(frame)) {

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

@ -5,29 +5,6 @@
interface nsIDocShell;
interface mixin LoadContextMixin {
readonly attribute WindowProxy? associatedWindow;
readonly attribute WindowProxy? topWindow;
readonly attribute Element? topFrameElement;
readonly attribute boolean isContent;
[SetterThrows]
attribute boolean usePrivateBrowsing;
readonly attribute boolean useRemoteTabs;
readonly attribute boolean useRemoteSubframes;
[BinaryName="useTrackingProtectionWebIDL"]
attribute boolean useTrackingProtection;
[NewObject, Throws]
readonly attribute any originAttributes;
};
[Exposed=Window, ChromeOnly]
interface BrowsingContext {
static BrowsingContext? get(unsigned long long aId);
@ -89,8 +66,6 @@ interface BrowsingContext {
void setRDMPaneMaxTouchPoints(octet maxTouchPoints);
};
BrowsingContext includes LoadContextMixin;
[Exposed=Window, ChromeOnly]
interface CanonicalBrowsingContext : BrowsingContext {
sequence<WindowGlobalParent> getWindowGlobals();
@ -127,8 +102,6 @@ interface CanonicalBrowsingContext : BrowsingContext {
[Throws]
void loadURI(DOMString aURI, optional LoadURIOptions aOptions = {});
void stop(unsigned long aStopFlags);
[Throws]
Promise<unsigned long long> changeFrameRemoteness(
DOMString remoteType, unsigned long long pendingSwitchId);

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

@ -3796,6 +3796,7 @@ class FakeChannel final : public nsIChannel,
elem.forget(aElement);
return NS_OK;
}
NS_IMETHOD GetNestedFrameId(uint64_t*) NO_IMPL;
NS_IMETHOD GetIsContent(bool*) NO_IMPL;
NS_IMETHOD GetUsePrivateBrowsing(bool*) NO_IMPL;
NS_IMETHOD SetUsePrivateBrowsing(bool) NO_IMPL;

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

@ -4167,21 +4167,6 @@ mozilla::ipc::IPCResult ContentChild::RecvDisplayLoadError(
return IPC_OK();
}
mozilla::ipc::IPCResult ContentChild::RecvStopLoad(
const MaybeDiscarded<BrowsingContext>& aContext,
const uint32_t aStopFlags) {
if (aContext.IsNullOrDiscarded()) {
return IPC_OK();
}
BrowsingContext* context = aContext.get();
if (nsIDocShell* docShell = context->GetDocShell()) {
nsDocShell::Cast(docShell)->Stop(aStopFlags);
}
return IPC_OK();
}
#if defined(MOZ_SANDBOX) && defined(MOZ_DEBUG) && defined(ENABLE_TESTS)
mozilla::ipc::IPCResult ContentChild::RecvInitSandboxTesting(
Endpoint<PSandboxTestingChild>&& aEndpoint) {

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

@ -797,10 +797,6 @@ class ContentChild final
mozilla::ipc::IPCResult RecvDisplayLoadError(
const MaybeDiscarded<BrowsingContext>& aContext, const nsAString& aURI);
mozilla::ipc::IPCResult RecvStopLoad(
const MaybeDiscarded<BrowsingContext>& aContext,
const uint32_t aStopFlags);
#ifdef NIGHTLY_BUILD
virtual PContentChild::Result OnMessageReceived(const Message& aMsg) override;
#else

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

@ -844,8 +844,6 @@ child:
async DisplayLoadError(MaybeDiscardedBrowsingContext aContext, nsString aURI);
async StopLoad(MaybeDiscardedBrowsingContext aContext, uint32_t aStopFlags);
// Tell aContext's docshell to update its mOSHE and mLSHE entries
async UpdateSHEntriesInDocShell(CrossProcessSHEntry aOldEntry,
CrossProcessSHEntry aNewEntry,

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

@ -87,7 +87,7 @@ var waitForLoad = async function(uri) {
};
gBrowser.selectedBrowser.webNavigation.loadURI(uri, loadURIOptions);
await BrowserTestUtils.browserStopped(gBrowser, uri);
await BrowserTestUtils.browserStopped(gBrowser);
};
// Tests referrerInfo when navigating from a page in the remote process to main

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

@ -32,11 +32,8 @@ function test() {
}
function doTest(aIsPrivateMode, aWindow, aCallback) {
BrowserTestUtils.browserLoaded(
aWindow.gBrowser.selectedBrowser,
false,
testURI
).then(() => {
BrowserTestUtils.browserLoaded(aWindow.gBrowser.selectedBrowser).then(
() => {
consoleObserver = {
observe(aSubject, aTopic, aData) {
if (aTopic == "console-api-log-event") {
@ -65,7 +62,8 @@ function test() {
aWindow.nativeConsole.log(
"foo bar baz (private: " + aIsPrivateMode + ")"
);
});
}
);
// We expect that console API messages are always stored.
storageShouldOccur = true;

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

@ -962,13 +962,6 @@
value: true
mirror: always
# If set, use DocumentChannel to directly initiate loads from
# parent-process BrowsingContexts
- name: browser.tabs.documentchannel.parent-initiated
type: bool
value: true
mirror: always
- name: browser.tabs.remote.desktopbehavior
type: bool
value: false

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

@ -32,18 +32,12 @@ class ADocumentChannelBridge {
// RemoveRequest).
// We do this so we can remove using NS_BINDING_RETARGETED, but still have
// the channel not be in an error state.
//
// aSwitchingToNewProcess is true if the load is successful, but we're
// disconnecting the bridge to switch the load to a new process.
virtual void DisconnectChildListeners(nsresult aStatus,
nsresult aLoadGroupStatus,
bool aSwitchingToNewProcess) = 0;
nsresult aLoadGroupStatus) = 0;
// Delete the bridge, and drop any refs to the DocumentLoadListener
virtual void Delete() = 0;
virtual bool SupportsRedirectToRealChannel() { return true; }
// Initate a switch from the DocumentChannel to the protocol-specific
// real channel.
virtual RefPtr<PDocumentChannelParent::RedirectToRealChannelPromise>

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

@ -1,177 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 : */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "BrowsingContextDocumentChannel.h"
#include "DocumentLoadListener.h"
#include "nsIBrowser.h"
#include "mozilla/dom/BrowserParent.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/RemoteWebProgress.h"
#include "mozilla/dom/RemoteWebProgressRequest.h"
#include "mozilla/dom/WindowGlobalParent.h"
using namespace mozilla::dom;
extern mozilla::LazyLogModule gDocumentChannelLog;
#define LOG(fmt) MOZ_LOG(gDocumentChannelLog, mozilla::LogLevel::Verbose, fmt)
namespace mozilla {
namespace net {
already_AddRefed<nsIBrowser> BrowsingContextDocumentChannel::GetBrowser() {
CanonicalBrowsingContext* bc = mParent->GetBrowsingContext();
if (!bc || !bc->IsTopContent()) {
NS_ASSERTION(false, "No BC, or subframe?");
return nullptr;
}
nsCOMPtr<nsIBrowser> browser;
RefPtr<Element> currentElement = bc->GetEmbedderElement();
// In Responsive Design Mode, mFrameElement will be the <iframe mozbrowser>,
// but we want the <xul:browser> that it is embedded in.
while (currentElement) {
browser = currentElement->AsBrowser();
if (browser) {
break;
}
BrowsingContext* browsingContext =
currentElement->OwnerDoc()->GetBrowsingContext();
currentElement =
browsingContext ? browsingContext->GetEmbedderElement() : nullptr;
}
return browser.forget();
}
void BrowsingContextDocumentChannel::FireStateChange(uint32_t aStateFlags,
nsresult aStatus) {
nsCOMPtr<nsIBrowser> browser = GetBrowser();
if (!browser) {
NS_ASSERTION(false, "Failed to find browser element!");
return;
}
nsCOMPtr<nsIWebProgress> manager;
nsresult rv = browser->GetRemoteWebProgressManager(getter_AddRefs(manager));
if (NS_FAILED(rv)) {
NS_ASSERTION(false, "Failed to get remote web progress manager?");
return;
}
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(manager);
if (!listener) {
NS_ASSERTION(false, "Failed to get remote web progress listener");
// We are no longer remote so we cannot forward this event.
return;
}
nsCOMPtr<nsILoadInfo> loadInfo = mParent->GetChannel()->LoadInfo();
nsCOMPtr<nsIWebProgress> webProgress = new RemoteWebProgress(
manager, loadInfo->GetOuterWindowID(),
/* aInnerDOMWindowID = */ 0, mParent->GetLoadType(), true, true);
nsCOMPtr<nsIURI> uri, originalUri;
mParent->GetChannel()->GetURI(getter_AddRefs(uri));
mParent->GetChannel()->GetOriginalURI(getter_AddRefs(originalUri));
nsCString matchedList;
nsCOMPtr<nsIRequest> request = MakeAndAddRef<RemoteWebProgressRequest>(
uri, originalUri, matchedList, Nothing());
NS_DispatchToMainThread(
NS_NewRunnableFunction("DocumentLoadListener::FireStateChange", [=]() {
Unused << listener->OnStateChange(webProgress, request, aStateFlags,
aStatus);
}));
}
void BrowsingContextDocumentChannel::SetNavigating(bool aNavigating) {
nsCOMPtr<nsIBrowser> browser = GetBrowser();
if (!browser) {
NS_ASSERTION(false, "Failed to find browser element!");
return;
}
NS_DispatchToMainThread(
NS_NewRunnableFunction("DocumentLoadListener::SetNavigating",
[=]() { browser->SetIsNavigating(aNavigating); }));
}
BrowsingContextDocumentChannel::BrowsingContextDocumentChannel(
dom::CanonicalBrowsingContext* aBrowsingContext) {
mParent = new DocumentLoadListener(aBrowsingContext, this);
}
// Creates the channel, and then calls AsyncOpen on it.
bool BrowsingContextDocumentChannel::Open(nsDocShellLoadState* aLoadState,
uint64_t aOuterWindowId,
bool aSetNavigating) {
MOZ_LOG(gDocumentChannelLog, mozilla::LogLevel::Debug,
("BrowsingContextDocumentChannel::Open [this=%p]", this));
SetNavigating(aSetNavigating);
if (mParent->OpenFromParent(aLoadState, aOuterWindowId)) {
FireStateChange(nsIWebProgressListener::STATE_START |
nsIWebProgressListener::STATE_IS_DOCUMENT |
nsIWebProgressListener::STATE_IS_REQUEST |
nsIWebProgressListener::STATE_IS_WINDOW |
nsIWebProgressListener::STATE_IS_NETWORK,
NS_OK);
SetNavigating(false);
return true;
}
SetNavigating(false);
mParent = nullptr;
return false;
}
void BrowsingContextDocumentChannel::DisconnectChildListeners(
nsresult aStatus, nsresult aLoadGroupStatus, bool aSwitchingToNewProcess) {
// If we're not switching the load to a new process, then it is
// finished, and we should fire a state change to notify observers.
// Normally the docshell would fire this, and it would get filtered
// out by BrowserParent if needed.
if (!aSwitchingToNewProcess) {
FireStateChange(nsIWebProgressListener::STATE_STOP |
nsIWebProgressListener::STATE_IS_WINDOW |
nsIWebProgressListener::STATE_IS_NETWORK,
aStatus);
}
mParent = nullptr;
}
void BrowsingContextDocumentChannel::Delete() {
if (mParent) {
RefPtr<DocumentLoadListener> parent = std::move(mParent);
parent->DocumentChannelBridgeDisconnected();
}
}
RefPtr<PDocumentChannelParent::RedirectToRealChannelPromise>
BrowsingContextDocumentChannel::RedirectToRealChannel(
nsTArray<ipc::Endpoint<extensions::PStreamFilterParent>>&&
aStreamFilterEndpoints,
uint32_t aRedirectFlags, uint32_t aLoadFlags) {
MOZ_ASSERT_UNREACHABLE("RedirectToRealChannel unsupported!");
return PDocumentChannelParent::RedirectToRealChannelPromise::CreateAndResolve(
NS_ERROR_UNEXPECTED, __func__);
}
base::ProcessId BrowsingContextDocumentChannel::OtherPid() const {
// We intentionally return 0 (rather than the OwnerProcessId of the browsing
// context, since this is used to determine the process from which the load
// originated.
return 0;
}
} // namespace net
} // namespace mozilla
#undef LOG

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

@ -1,67 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 : */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_net_BrowsingContextDocumentChannel_h
#define mozilla_net_BrowsingContextDocumentChannel_h
#include "mozilla/net/ADocumentChannelBridge.h"
class nsIBrowser;
namespace mozilla {
namespace dom {
class CanonicalBrowsingContext;
} // namespace dom
namespace net {
class DocumentLoadListener;
// An ADocumentChannelBridge implementation for loads initiated by
// a CanonicalBrowsingContext, and don't start from a docshell.
class BrowsingContextDocumentChannel : public ADocumentChannelBridge {
public:
NS_INLINE_DECL_REFCOUNTING(BrowsingContextDocumentChannel, override)
explicit BrowsingContextDocumentChannel(
dom::CanonicalBrowsingContext* aBrowsingContext);
// Creates the channel, and then calls AsyncOpen on it.
bool Open(nsDocShellLoadState* aLoadState, uint64_t aOuterWindowId,
bool aSetNavigating);
void DisconnectChildListeners(nsresult aStatus, nsresult aLoadGroupStatus,
bool aSwitchingToNewProcess) override;
void Delete() override;
// We're not connected to an originating docshell, so we can't
// support RedirectToRealChannel to issue a redirect on one.
bool SupportsRedirectToRealChannel() override { return false; }
RefPtr<PDocumentChannelParent::RedirectToRealChannelPromise>
RedirectToRealChannel(
nsTArray<ipc::Endpoint<extensions::PStreamFilterParent>>&&
aStreamFilterEndpoints,
uint32_t aRedirectFlags, uint32_t aLoadFlags) override;
base::ProcessId OtherPid() const override;
private:
virtual ~BrowsingContextDocumentChannel() = default;
void FireStateChange(uint32_t aStateFlags, nsresult aStatus);
void SetNavigating(bool aNavigating);
already_AddRefed<nsIBrowser> GetBrowser();
RefPtr<DocumentLoadListener> mParent;
};
} // namespace net
} // namespace mozilla
#endif // mozilla_net_BrowsingContextDocumentChannel_h

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

@ -97,13 +97,23 @@ DocumentChannelChild::AsyncOpen(nsIStreamListener* aListener) {
args.timing() = Some(mTiming);
}
nsCOMPtr<nsIBrowserChild> iBrowserChild;
NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup,
NS_GET_TEMPLATE_IID(nsIBrowserChild),
getter_AddRefs(iBrowserChild));
BrowserChild* browserChild = static_cast<BrowserChild*>(iBrowserChild.get());
if (MissingRequiredBrowserChild(browserChild, "documentchannel")) {
return NS_ERROR_ILLEGAL_VALUE;
}
args.hasValidTransientUserAction() =
GetDocShell()
->GetBrowsingContext()
->HasValidTransientUserGestureActivation();
gNeckoChild->SendPDocumentChannelConstructor(
this, GetDocShell()->GetBrowsingContext(), args);
this, browserChild, GetDocShell()->GetBrowsingContext(),
IPC::SerializedLoadContext(this), args);
mIsPending = true;
mWasOpened = true;

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

@ -18,13 +18,13 @@ using namespace mozilla::dom;
namespace mozilla {
namespace net {
DocumentChannelParent::DocumentChannelParent(
CanonicalBrowsingContext* aContext) {
DocumentChannelParent::DocumentChannelParent(CanonicalBrowsingContext* aContext,
nsILoadContext* aLoadContext) {
LOG(("DocumentChannelParent ctor [this=%p]", this));
// Sometime we can get this called without a BrowsingContext, so that we have
// an actor to call SendFailedAsyncOpen on.
if (aContext) {
mParent = new DocumentLoadListener(aContext, this);
mParent = new DocumentLoadListener(aContext, aLoadContext, this);
}
}
@ -46,7 +46,7 @@ bool DocumentChannelParent::Init(const DocumentChannelCreationArgs& aArgs) {
nsresult rv = NS_ERROR_UNEXPECTED;
if (!mParent->Open(loadState, aArgs.loadFlags(), aArgs.cacheKey(),
Some(aArgs.channelId()), aArgs.asyncOpenTime(),
aArgs.channelId(), aArgs.asyncOpenTime(),
aArgs.timing().refOr(nullptr), std::move(clientInfo),
aArgs.outerWindowId(), aArgs.hasValidTransientUserAction(),
&rv)) {

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

@ -26,7 +26,8 @@ class DocumentChannelParent final : public ADocumentChannelBridge,
public:
NS_INLINE_DECL_REFCOUNTING(DocumentChannelParent, override);
explicit DocumentChannelParent(dom::CanonicalBrowsingContext* aContext);
explicit DocumentChannelParent(dom::CanonicalBrowsingContext* aContext,
nsILoadContext* aLoadContext);
bool Init(const DocumentChannelCreationArgs& aArgs);
@ -46,8 +47,8 @@ class DocumentChannelParent final : public ADocumentChannelBridge,
private:
// DocumentChannelListener
void DisconnectChildListeners(nsresult aStatus, nsresult aLoadGroupStatus,
bool aSwitchingToNewProcess) override {
void DisconnectChildListeners(nsresult aStatus,
nsresult aLoadGroupStatus) override {
if (CanSend()) {
Unused << SendDisconnectChildListeners(aStatus, aLoadGroupStatus);
}

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

@ -15,7 +15,6 @@
#include "mozilla/dom/ClientChannelHelper.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/ContentProcessManager.h"
#include "mozilla/dom/nsCSPContext.h"
#include "mozilla/dom/ipc/IdType.h"
#include "mozilla/dom/ServiceWorkerManager.h"
#include "mozilla/net/CookieJarSettings.h"
@ -39,13 +38,9 @@
#include "nsMimeTypes.h"
#include "nsIViewSourceChannel.h"
#include "nsIOService.h"
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/dom/WindowGlobalParent.h"
#include "mozilla/StaticPrefs_security.h"
#include "nsICookieService.h"
#include "nsDocShellLoadTypes.h"
#include "nsDOMNavigationTiming.h"
#include "nsSandboxFlags.h"
#ifdef ANDROID
# include "mozilla/widget/nsWindow.h"
@ -249,11 +244,12 @@ NS_INTERFACE_MAP_BEGIN(DocumentLoadListener)
NS_INTERFACE_MAP_END
DocumentLoadListener::DocumentLoadListener(
CanonicalBrowsingContext* aBrowsingContext,
ADocumentChannelBridge* aBridge) {
CanonicalBrowsingContext* aBrowsingContext, nsILoadContext* aLoadContext,
ADocumentChannelBridge* aBridge)
: mLoadContext(aLoadContext) {
LOG(("DocumentLoadListener ctor [this=%p]", this));
mParentChannelListener = new ParentChannelListener(
this, aBrowsingContext, aBrowsingContext->UsePrivateBrowsing());
this, aBrowsingContext, aLoadContext->UsePrivateBrowsing());
mDocumentChannelBridge = aBridge;
}
@ -301,7 +297,7 @@ already_AddRefed<LoadInfo> DocumentLoadListener::CreateLoadInfo(
} else {
// Build LoadInfo for TYPE_DOCUMENT
OriginAttributes attrs;
aBrowsingContext->GetOriginAttributes(attrs);
mLoadContext->GetOriginAttributes(attrs);
loadInfo = new LoadInfo(aBrowsingContext, aLoadState->TriggeringPrincipal(),
attrs, aOuterWindowId, securityFlags, sandboxFlags);
}
@ -343,16 +339,9 @@ GetTopWindowExcludingExtensionAccessibleContentFrames(
return prev.forget();
}
CanonicalBrowsingContext* DocumentLoadListener::GetBrowsingContext() const {
if (!mParentChannelListener) {
return nullptr;
}
return mParentChannelListener->GetBrowsingContext();
}
bool DocumentLoadListener::Open(
nsDocShellLoadState* aLoadState, nsLoadFlags aLoadFlags, uint32_t aCacheKey,
const Maybe<uint64_t>& aChannelId, const TimeStamp& aAsyncOpenTime,
const uint64_t& aChannelId, const TimeStamp& aAsyncOpenTime,
nsDOMNavigationTiming* aTiming, Maybe<ClientInfo>&& aInfo,
uint64_t aOuterWindowId, bool aHasGesture, nsresult* aRv) {
LOG(("DocumentLoadListener Open [this=%p, uri=%s]", this,
@ -361,7 +350,7 @@ bool DocumentLoadListener::Open(
mParentChannelListener->GetBrowsingContext();
OriginAttributes attrs;
browsingContext->GetOriginAttributes(attrs);
mLoadContext->GetOriginAttributes(attrs);
RefPtr<WindowGlobalParent> embedderWGP =
browsingContext->GetParentWindowGlobal();
@ -383,8 +372,6 @@ bool DocumentLoadListener::Open(
browsingContext, aLoadState, loadInfo, mParentChannelListener,
nullptr, attrs, aLoadFlags, aCacheKey, *aRv,
getter_AddRefs(mChannel))) {
LOG(("DocumentLoadListener::Open failed to create channel [this=%p]",
this));
mParentChannelListener = nullptr;
return false;
}
@ -425,8 +412,8 @@ bool DocumentLoadListener::Open(
AntiTrackingUtils::HasStoragePermissionInParent(mChannel));
nsCOMPtr<nsIIdentChannel> identChannel = do_QueryInterface(mChannel);
if (identChannel && aChannelId) {
Unused << identChannel->SetChannelId(*aChannelId);
if (identChannel) {
Unused << identChannel->SetChannelId(aChannelId);
}
RefPtr<nsHttpChannel> httpChannelImpl = do_QueryObject(mChannel);
@ -452,15 +439,6 @@ bool DocumentLoadListener::Open(
// across any serviceworker related data between channels as needed.
AddClientChannelHelperInParent(mChannel, std::move(aInfo));
if (!GetBrowsingContext()->StartDocumentLoad(this)) {
LOG(("DocumentLoadListener::Open failed StartDocumentLoad [this=%p]",
this));
*aRv = NS_BINDING_ABORTED;
mParentChannelListener = nullptr;
mChannel = nullptr;
return false;
}
// Recalculate the openFlags, matching the logic in use in Content process.
// NOTE: The only case not handled here to mirror Content process is
// redirecting to re-use the channel.
@ -516,12 +494,7 @@ bool DocumentLoadListener::Open(
{
*aRv = mChannel->AsyncOpen(openInfo);
if (NS_FAILED(*aRv)) {
LOG(("DocumentLoadListener::Open failed AsyncOpen [this=%p rv=%" PRIx32
"]",
this, static_cast<uint32_t>(*aRv)));
GetBrowsingContext()->EndDocumentLoad(this);
mParentChannelListener = nullptr;
mChannel = nullptr;
return false;
}
}
@ -535,86 +508,6 @@ bool DocumentLoadListener::Open(
return true;
}
bool DocumentLoadListener::OpenFromParent(nsDocShellLoadState* aLoadState,
uint64_t aOuterWindowId) {
// We currently only support passing nullptr for aLoadInfo for
// top level browsing contexts.
if (!GetBrowsingContext()->IsTopContent()) {
LOG(
("DocumentLoadListener::OpenFromParent failed because of subdoc "
"[this=%p]",
this));
mParentChannelListener = nullptr;
return false;
}
if (nsCOMPtr<nsIContentSecurityPolicy> csp = aLoadState->Csp()) {
// Check CSP navigate-to
bool allowsNavigateTo = false;
nsresult rv = csp->GetAllowsNavigateTo(aLoadState->URI(),
aLoadState->IsFormSubmission(),
false, /* aWasRedirected */
false, /* aEnforceWhitelist */
&allowsNavigateTo);
if (NS_FAILED(rv) || !allowsNavigateTo) {
mParentChannelListener = nullptr;
return false;
}
}
aLoadState->CalculateLoadURIFlags();
// Any sort of reload/history load would need the cacheKey, and session
// history data for load flags. We don't have those available in the parent
// yet, so don't support these load types.
auto loadType = aLoadState->LoadType();
if (loadType == LOAD_HISTORY || loadType == LOAD_RELOAD_NORMAL ||
loadType == LOAD_RELOAD_CHARSET_CHANGE ||
loadType == LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE ||
loadType == LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE) {
LOG(
("DocumentLoadListener::OpenFromParent failed because of history "
"load [this=%p]",
this));
mParentChannelListener = nullptr;
return false;
}
nsLoadFlags loadFlags = aLoadState->LoadFlags() |
nsIChannel::LOAD_DOCUMENT_URI |
nsIChannel::LOAD_CALL_CONTENT_SNIFFERS;
uint32_t sandboxFlags = GetBrowsingContext()->GetSandboxFlags();
if ((sandboxFlags & (SANDBOXED_ORIGIN | SANDBOXED_SCRIPTS)) == 0) {
loadFlags |= nsIRequest::LOAD_DOCUMENT_NEEDS_COOKIE;
}
if (aLoadState->FirstParty()) {
// tag first party URL loads
loadFlags |= nsIChannel::LOAD_INITIAL_DOCUMENT_URI;
}
RefPtr<nsDOMNavigationTiming> timing = new nsDOMNavigationTiming(nullptr);
timing->NotifyNavigationStart(
GetBrowsingContext()->GetIsActive()
? nsDOMNavigationTiming::DocShellState::eActive
: nsDOMNavigationTiming::DocShellState::eInactive);
// We're not a history load or a reload, so we don't need this.
uint32_t cacheKey = 0;
// Loads start in the content process might have exposed a channel id to
// observers, so we need to preserve the value in the parent. That can't have
// happened here, so Nothing() is fine.
Maybe<uint64_t> channelId;
// Initial client info is only relevant for subdocument loads, which we're
// not supporting yet.
Maybe<dom::ClientInfo> initialClientInfo;
nsresult rv;
return Open(aLoadState, loadFlags, cacheKey, channelId, TimeStamp::Now(),
timing, std::move(initialClientInfo), aOuterWindowId, false, &rv);
}
void DocumentLoadListener::DocumentChannelBridgeDisconnected() {
LOG(("DocumentLoadListener DocumentChannelBridgeDisconnected [this=%p]",
this));
@ -625,10 +518,6 @@ void DocumentLoadListener::DocumentChannelBridgeDisconnected() {
httpChannelImpl->SetWarningReporter(nullptr);
}
mDocumentChannelBridge = nullptr;
if (auto* ctx = GetBrowsingContext()) {
ctx->EndDocumentLoad(this);
}
}
void DocumentLoadListener::Cancel(const nsresult& aStatusCode) {
@ -636,33 +525,20 @@ void DocumentLoadListener::Cancel(const nsresult& aStatusCode) {
("DocumentLoadListener Cancel [this=%p, "
"aStatusCode=%" PRIx32 " ]",
this, static_cast<uint32_t>(aStatusCode)));
if (mDoingProcessSwitch) {
// If we've already initiated process-switching
// then we can no longer be cancelled and we'll
// disconnect the old listeners when done.
return;
}
if (mChannel) {
if (mChannel && !mDoingProcessSwitch) {
mChannel->Cancel(aStatusCode);
}
DisconnectChildListeners(aStatusCode, aStatusCode);
}
void DocumentLoadListener::DisconnectChildListeners(
nsresult aStatus, nsresult aLoadGroupStatus, bool aSwitchingToNewProcess) {
void DocumentLoadListener::DisconnectChildListeners(nsresult aStatus,
nsresult aLoadGroupStatus) {
LOG(
("DocumentLoadListener DisconnectChildListener [this=%p, "
"aStatus=%" PRIx32 " aLoadGroupStatus=%" PRIx32 " ]",
this, static_cast<uint32_t>(aStatus),
static_cast<uint32_t>(aLoadGroupStatus)));
RefPtr<DocumentLoadListener> keepAlive(this);
if (mDocumentChannelBridge) {
// This will drop the bridge's reference to us, so we use keepAlive to
// make sure we don't get deleted until we exit the function.
mDocumentChannelBridge->DisconnectChildListeners(aStatus, aLoadGroupStatus,
aSwitchingToNewProcess);
mDocumentChannelBridge->DisconnectChildListeners(aStatus, aLoadGroupStatus);
}
DocumentChannelBridgeDisconnected();
@ -725,7 +601,7 @@ void DocumentLoadListener::FinishReplacementChannelSetup(bool aSucceeded) {
nsresult rv;
if (mDoingProcessSwitch) {
DisconnectChildListeners(NS_BINDING_ABORTED, NS_BINDING_ABORTED, true);
DisconnectChildListeners(NS_BINDING_ABORTED, NS_BINDING_ABORTED);
}
nsCOMPtr<nsIParentChannel> redirectChannel;
@ -747,8 +623,8 @@ void DocumentLoadListener::FinishReplacementChannelSetup(bool aSucceeded) {
newChannel->Cancel(NS_BINDING_ABORTED);
}
}
// Release all previously registered channels, they are no longer needed
// to be kept in the registrar from this moment.
// Release all previously registered channels, they are no longer needed to
// be kept in the registrar from this moment.
registrar->DeregisterChannels(mRedirectChannelId);
mRedirectChannelId = 0;
@ -763,7 +639,6 @@ void DocumentLoadListener::FinishReplacementChannelSetup(bool aSucceeded) {
redirectChannel->Delete();
}
mChannel->Resume();
DisconnectChildListeners(NS_ERROR_UNEXPECTED, NS_ERROR_UNEXPECTED);
return;
}
@ -777,8 +652,8 @@ void DocumentLoadListener::FinishReplacementChannelSetup(bool aSucceeded) {
redirectChannel->SetParentListener(mParentChannelListener);
// We stored the values from all nsIParentChannel functions called since we
// couldn't handle them. Copy them across to the real channel since it
// should know what to do.
// couldn't handle them. Copy them across to the real channel since it should
// know what to do.
for (auto& variant : mIParentChannelFunctions) {
variant.match(
[redirectChannel](const nsIHttpChannel::FlashPluginState& aState) {
@ -890,10 +765,6 @@ void DocumentLoadListener::ResumeSuspendedChannel(
"Should not have added new stream listener function!");
mChannel->Resume();
if (auto* ctx = GetBrowsingContext()) {
ctx->EndDocumentLoad(this);
}
}
void DocumentLoadListener::SerializeRedirectData(
@ -1051,7 +922,8 @@ DocumentLoadListener::RedirectToRealChannel(
}
RedirectToRealChannelArgs args;
SerializeRedirectData(args, true, aRedirectFlags, aLoadFlags);
SerializeRedirectData(args, !!aDestinationProcess, aRedirectFlags,
aLoadFlags);
if (mTiming) {
mTiming->Anonymize(args.uri());
args.timing() = Some(std::move(mTiming));
@ -1152,6 +1024,9 @@ DocumentLoadListener::OnStartRequest(nsIRequest* aRequest) {
MOZ_DIAGNOSTIC_ASSERT(mChannel);
RefPtr<nsHttpChannel> httpChannel = do_QueryObject(mChannel);
// If this is a download, then redirect entirely within the parent.
// TODO, see bug 1574372.
if (!mDocumentChannelBridge) {
return NS_ERROR_UNEXPECTED;
}
@ -1160,9 +1035,13 @@ DocumentLoadListener::OnStartRequest(nsIRequest* aRequest) {
// might cancel the channel.
nsContentSecurityUtils::PerformCSPFrameAncestorAndXFOCheck(mChannel);
if (!GetBrowsingContext() || GetBrowsingContext()->IsDiscarded()) {
DisconnectChildListeners(NS_ERROR_UNEXPECTED, NS_ERROR_UNEXPECTED);
return NS_ERROR_UNEXPECTED;
// Once we initiate a process switch, we ask the child to notify the
// listeners that we have completed. If the switch promise then gets
// rejected we also cancel the parent, which results in this being called.
// We don't need to forward it on though, since the child side is already
// completed.
if (mDoingProcessSwitch) {
return NS_OK;
}
// Generally we want to switch to a real channel even if the request failed,
@ -1174,7 +1053,7 @@ DocumentLoadListener::OnStartRequest(nsIRequest* aRequest) {
nsresult status = NS_OK;
aRequest->GetStatus(&status);
if (status == NS_ERROR_NO_CONTENT) {
DisconnectChildListeners(status, status);
mDocumentChannelBridge->DisconnectChildListeners(status, status);
return NS_OK;
}
@ -1215,44 +1094,12 @@ DocumentLoadListener::OnStartRequest(nsIRequest* aRequest) {
}
if (mRedirectContentProcessIdPromise) {
// If we got a promise, then wait on it to get the process ID, and
// then call TriggerRedirectToRealChannel.
TriggerCrossProcessSwitch();
} else if (!mDocumentChannelBridge->SupportsRedirectToRealChannel()) {
// If the existing process is right for this load, but the bridge doesn't
// support redirects, then we need to do it manually.
// Generate a unique identifier for the new channel in the content
// process. This is duplicating code from on-may-change-process and
// can be shared once that code is moved to c++.
static uint64_t sIdent = 0x10000;
uint64_t ident = ++sIdent;
mCrossProcessRedirectIdentifier = ident;
// If we're not going to process switch, then we must have an existing
// window global, right?
MOZ_ASSERT(GetBrowsingContext()->GetCurrentWindowGlobal());
RefPtr<BrowserParent> browserParent =
GetBrowsingContext()->GetCurrentWindowGlobal()->GetBrowserParent();
// This load has already started, so we want to suspend the start progress
// events from the docshell from reaching the parent.
browserParent->SuspendProgressEventsUntilAfterNextLoadStarts();
// Notify the docshell that it should load using the newly connected
// channel
browserParent->ResumeLoad(ident);
// Use the current process ID to run the 'process switch' path and connect
// the channel into the current process.
TriggerRedirectToRealChannel(Some(GetBrowsingContext()->OwnerProcessId()));
} else {
// The existing process is fine, and we can connect to it via the bridge.
// We don't need a process ID to redirect to the real channel.
TriggerRedirectToRealChannel(Nothing());
return NS_OK;
}
TriggerRedirectToRealChannel();
return NS_OK;
}
@ -1327,10 +1174,10 @@ DocumentLoadListener::SetParentListener(
NS_IMETHODIMP
DocumentLoadListener::GetInterface(const nsIID& aIID, void** result) {
RefPtr<CanonicalBrowsingContext> browsingContext =
mParentChannelListener->GetBrowsingContext();
if (aIID.Equals(NS_GET_IID(nsILoadContext)) && browsingContext) {
browsingContext.forget(result);
// Only support nsILoadContext if child channel's callbacks did too
if (aIID.Equals(NS_GET_IID(nsILoadContext)) && mLoadContext) {
nsCOMPtr<nsILoadContext> copy = mLoadContext;
copy.forget(result);
return NS_OK;
}
@ -1395,9 +1242,6 @@ NS_IMETHODIMP
DocumentLoadListener::AsyncOnChannelRedirect(
nsIChannel* aOldChannel, nsIChannel* aNewChannel, uint32_t aFlags,
nsIAsyncVerifyRedirectCallback* aCallback) {
LOG(("DocumentLoadListener::AsyncOnChannelRedirect [this=%p flags=%" PRIu32
"]",
this, aFlags));
// We generally don't want to notify the content process about redirects,
// so just update our channel and tell the callback that we're good to go.
mChannel = aNewChannel;
@ -1435,22 +1279,6 @@ DocumentLoadListener::AsyncOnChannelRedirect(
oldURI, aFlags, responseStatus, net::ChannelIsPost(aOldChannel)});
}
// If this is a cross-origin redirect, then we should no longer allow
// mixed content. The destination docshell checks this in its redirect
// handling, but if we deliver to a new docshell (with a process switch)
// then this doesn't happen.
// Manually remove the allow mixed content flags.
nsresult rv = nsContentUtils::CheckSameOrigin(aOldChannel, aNewChannel);
if (NS_FAILED(rv)) {
if (mLoadStateLoadType == LOAD_NORMAL_ALLOW_MIXED_CONTENT) {
mLoadStateLoadType = LOAD_NORMAL;
} else if (mLoadStateLoadType == LOAD_RELOAD_ALLOW_MIXED_CONTENT) {
mLoadStateLoadType = LOAD_RELOAD_NORMAL;
}
MOZ_ASSERT(!LOAD_TYPE_HAS_FLAGS(
mLoadStateLoadType, nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT));
}
if (!mDocumentChannelBridge) {
return NS_BINDING_ABORTED;
}
@ -1464,7 +1292,7 @@ DocumentLoadListener::AsyncOnChannelRedirect(
nsCOMPtr<nsILoadInfo> loadInfo = aOldChannel->LoadInfo();
nsCOMPtr<nsIURI> originalUri;
rv = aOldChannel->GetOriginalURI(getter_AddRefs(originalUri));
nsresult rv = aOldChannel->GetOriginalURI(getter_AddRefs(originalUri));
if (NS_FAILED(rv)) {
aOldChannel->Cancel(NS_ERROR_DOM_BAD_URI);
return rv;

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

@ -14,6 +14,7 @@
#include "mozilla/net/PDocumentChannelParent.h"
#include "mozilla/net/ParentChannelListener.h"
#include "mozilla/net/ADocumentChannelBridge.h"
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "nsDOMNavigationTiming.h"
#include "nsIInterfaceRequestor.h"
#include "nsIObserver.h"
@ -31,9 +32,6 @@
}
namespace mozilla {
namespace dom {
class CanonicalBrowsingContext;
}
namespace net {
using ChildEndpointPromise =
MozPromise<ipc::Endpoint<extensions::PStreamFilterChild>, bool, true>;
@ -94,15 +92,15 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
public nsIMultiPartChannelListener {
public:
explicit DocumentLoadListener(dom::CanonicalBrowsingContext* aBrowsingContext,
nsILoadContext* aLoadContext,
ADocumentChannelBridge* aBridge);
// Creates the channel, and then calls AsyncOpen on it.
bool Open(nsDocShellLoadState* aLoadState, nsLoadFlags aLoadFlags,
uint32_t aCacheKey, const Maybe<uint64_t>& aChannelId,
uint32_t aCacheKey, const uint64_t& aChannelId,
const TimeStamp& aAsyncOpenTime, nsDOMNavigationTiming* aTiming,
Maybe<dom::ClientInfo>&& aInfo, uint64_t aOuterWindowId,
bool aHasGesture, nsresult* aRv);
bool OpenFromParent(nsDocShellLoadState* aLoadState, uint64_t aOuterWindowId);
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER
@ -162,8 +160,7 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
// our reference to it.
void DocumentChannelBridgeDisconnected();
void DisconnectChildListeners(nsresult aStatus, nsresult aLoadGroupStatus,
bool aSwitchingToNewProcess = false);
void DisconnectChildListeners(nsresult aStatus, nsresult aLoadGroupStatus);
base::ProcessId OtherPid() const {
if (mDocumentChannelBridge) {
@ -183,19 +180,14 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
bool aIsCrossProcess, uint32_t aRedirectFlags,
uint32_t aLoadFlags);
dom::CanonicalBrowsingContext* GetBrowsingContext() const;
nsIChannel* GetChannel() const { return mChannel; }
uint32_t GetLoadType() const { return mLoadStateLoadType; }
protected:
virtual ~DocumentLoadListener();
// Initiates the switch from DocumentChannel to the real protocol-specific
// channel, and ensures that RedirectToRealChannelFinished is called when
// this is complete.
void TriggerRedirectToRealChannel(const Maybe<uint64_t>& aDestinationProcess);
void TriggerRedirectToRealChannel(
const Maybe<uint64_t>& aDestinationProcess = Nothing());
// Called once the content-process side on setting up a replacement
// channel is complete. May wait for the new parent channel to
@ -330,6 +322,8 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
// shuts down to break this.
RefPtr<ADocumentChannelBridge> mDocumentChannelBridge;
nsCOMPtr<nsILoadContext> mLoadContext;
// The original URI of the current channel. If there are redirects,
// then the value on the channel gets overwritten with the original
// URI of the first channel in the redirect chain, so we cache the

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

@ -254,7 +254,7 @@ const char* NeckoParent::CreateChannelLoadContext(
break;
}
case PBrowserOrId::TTabId: {
aResult = new LoadContext(aSerialized, nullptr, attrs);
aResult = new LoadContext(aSerialized, aBrowser.get_TabId(), attrs);
break;
}
default:
@ -409,7 +409,8 @@ mozilla::ipc::IPCResult NeckoParent::RecvPFTPChannelConstructor(
already_AddRefed<PDocumentChannelParent>
NeckoParent::AllocPDocumentChannelParent(
const MaybeDiscarded<BrowsingContext>& aContext,
PBrowserParent* aBrowser, const MaybeDiscarded<BrowsingContext>& aContext,
const SerializedLoadContext& aSerialized,
const DocumentChannelCreationArgs& args) {
// We still create the actor even if the BrowsingContext isn't available,
// so that we can send the reject message using it from
@ -419,13 +420,32 @@ NeckoParent::AllocPDocumentChannelParent(
context = aContext.get_canonical();
}
RefPtr<DocumentChannelParent> p = new DocumentChannelParent(context);
nsCOMPtr<nsIPrincipal> requestingPrincipal;
// We only have the requesting principal in case of TYPE_SUBDOCUMENT.
// If we don't have an embedder window global, then it is probably a race and
// we will deal with that later in the code path.
if (context && !aContext.IsDiscarded() && context->GetParent()) {
if (RefPtr<WindowGlobalParent> embedderWGP =
context->GetParentWindowGlobal()) {
requestingPrincipal = embedderWGP->DocumentPrincipal();
}
}
nsCOMPtr<nsILoadContext> loadContext;
const char* error = CreateChannelLoadContext(
aBrowser, Manager(), aSerialized, requestingPrincipal, loadContext);
if (error) {
return nullptr;
}
RefPtr<DocumentChannelParent> p =
new DocumentChannelParent(context, loadContext);
return p.forget();
}
mozilla::ipc::IPCResult NeckoParent::RecvPDocumentChannelConstructor(
PDocumentChannelParent* aActor,
PDocumentChannelParent* aActor, PBrowserParent* aBrowser,
const MaybeDiscarded<BrowsingContext>& aContext,
const SerializedLoadContext& aSerialized,
const DocumentChannelCreationArgs& aArgs) {
DocumentChannelParent* p = static_cast<DocumentChannelParent*>(aActor);

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

@ -126,11 +126,14 @@ class NeckoParent : public PNeckoParent {
const uint16_t& port);
already_AddRefed<PDocumentChannelParent> AllocPDocumentChannelParent(
PBrowserParent* aBrowser,
const dom::MaybeDiscarded<dom::BrowsingContext>& aContext,
const SerializedLoadContext& aSerialized,
const DocumentChannelCreationArgs& args);
virtual mozilla::ipc::IPCResult RecvPDocumentChannelConstructor(
PDocumentChannelParent* aActor,
PDocumentChannelParent* aActor, PBrowserParent* aBrowser,
const dom::MaybeDiscarded<dom::BrowsingContext>& aContext,
const SerializedLoadContext& aSerialized,
const DocumentChannelCreationArgs& aArgs) override;
bool DeallocPDocumentChannelParent(PDocumentChannelParent* channel);

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

@ -88,7 +88,9 @@ parent:
async PDNSRequest(nsCString hostName, nsCString trrServer, uint16_t type,
OriginAttributes originAttributes, uint32_t flags);
async PDocumentChannel(MaybeDiscardedBrowsingContext browsingContext,
async PDocumentChannel(PBrowser browser,
MaybeDiscardedBrowsingContext browsingContext,
SerializedLoadContext loadContext,
DocumentChannelCreationArgs args);
async PWebSocketEventListener(uint64_t aInnerWindowID);

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

@ -9,8 +9,6 @@
#include "nsIObserverService.h"
#include "nsIOService.h"
#include "SocketProcessParent.h"
#include "ProcessUtils.h"
#include "mozilla/ipc/FileDescriptor.h"
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
# include "mozilla/SandboxBroker.h"
@ -25,8 +23,6 @@
# include "mozilla/Sandbox.h"
#endif
using namespace mozilla::ipc;
namespace mozilla {
namespace net {

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

@ -11,7 +11,6 @@
#include "mozilla/ipc/IOThreadChild.h"
#include "mozilla/BackgroundHangMonitor.h"
#include "mozilla/Preferences.h"
#include "ProcessUtils.h"
#if defined(OS_WIN) && defined(MOZ_SANDBOX)
# include "mozilla/sandboxTarget.h"
@ -90,7 +89,7 @@ bool SocketProcessImpl::Init(int aArgc, char* aArgv[]) {
}
}
ipc::SharedPreferenceDeserializer deserializer;
SharedPreferenceDeserializer deserializer;
if (!deserializer.DeserializeFromSharedMemory(prefsHandle, prefMapHandle,
prefsLen, prefMapSize)) {
return false;

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

@ -6,7 +6,6 @@
EXPORTS.mozilla.net += [
'ADocumentChannelBridge.h',
'BrowsingContextDocumentChannel.h',
'ChannelEventQueue.h',
'DocumentChannel.h',
'DocumentChannelChild.h',
@ -28,7 +27,6 @@ EXPORTS.mozilla.net += [
]
UNIFIED_SOURCES += [
'BrowsingContextDocumentChannel.cpp',
'ChannelEventQueue.cpp',
'DocumentChannel.cpp',
'DocumentChannelChild.cpp',

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

@ -429,21 +429,15 @@ ParentChannelListener::OpenURI(nsIURI* aURI) {
nsCString spec;
aURI->GetSpec(spec);
RefPtr<dom::CanonicalBrowsingContext> bc = mBrowsingContext;
NS_DispatchToMainThread(
NS_NewRunnableFunction("ParentChannelListener::OpenURI", [spec, bc]() {
dom::LoadURIOptions loadURIOptions;
loadURIOptions.mTriggeringPrincipal =
nsContentUtils::GetSystemPrincipal();
loadURIOptions.mTriggeringPrincipal = nsContentUtils::GetSystemPrincipal();
loadURIOptions.mLoadFlags =
nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP |
nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL;
ErrorResult rv;
bc->LoadURI(NS_ConvertUTF8toUTF16(spec), loadURIOptions, rv);
}));
return NS_OK;
mBrowsingContext->LoadURI(NS_ConvertUTF8toUTF16(spec), loadURIOptions, rv);
return rv.StealNSResult();
}
NS_IMETHODIMP

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

@ -65,7 +65,7 @@ class ParentChannelListener final : public nsIInterfaceRequestor,
// Called to set a new listener which replaces the old one after a redirect.
void SetListenerAfterRedirect(nsIStreamListener* aListener);
dom::CanonicalBrowsingContext* GetBrowsingContext() const {
dom::CanonicalBrowsingContext* GetBrowsingContext() {
return mBrowsingContext;
}

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

@ -25,6 +25,9 @@ class WebNavigationChild extends JSWindowActorChild {
case "WebNavigation:Reload":
this.reload(message.data.loadFlags);
break;
case "WebNavigation:Stop":
this.stop(message.data.loadFlags);
break;
}
}
@ -76,4 +79,8 @@ class WebNavigationChild extends JSWindowActorChild {
reload(loadFlags) {
this.webNavigation.reload(loadFlags);
}
stop(loadFlags) {
this.webNavigation.stop(loadFlags);
}
}

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

@ -106,7 +106,7 @@ class RemoteWebNavigation {
Ci.nsIRemoteTab.NAVIGATE_URL,
{ uri }
);
this._browser.browsingContext.loadURI(aURI, {
this._browser.frameLoader.browsingContext.loadURI(aURI, {
...aLoadURIOptions,
cancelContentJSEpoch,
});
@ -115,7 +115,7 @@ class RemoteWebNavigation {
this._sendMessage("WebNavigation:Reload", { loadFlags: aReloadFlags });
}
stop(aStopFlags) {
this._browser.browsingContext.stop(aStopFlags);
this._sendMessage("WebNavigation:Stop", { loadFlags: aStopFlags });
}
get document() {

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

@ -55,8 +55,6 @@ add_task(async function test_unknownContentType_delayedbutton() {
{
gBrowser,
url: LOAD_URI,
waitForLoad: false,
waitForStateStop: true,
},
async function() {
let uctWindow = await UCTObserver.opened.promise;

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

@ -68,8 +68,6 @@ add_task(async function test_unknownContentType_dialog_layout() {
{
gBrowser,
url: test.url,
waitForLoad: false,
waitForStateStop: true,
},
async function() {
let uctWindow = await UCTObserver.opened.promise;

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

@ -46,10 +46,8 @@ function runTest() {
"amosigned.xpi'</script>",
});
gBrowser.selectedTab = BrowserTestUtils.addTab(
gBrowser,
TESTROOT + "redirect.sjs?mode=redirect"
);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.loadURI(gBrowser, TESTROOT + "redirect.sjs?mode=redirect");
}
function install_blocked(installInfo) {

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

@ -1,9 +1,11 @@
// ----------------------------------------------------------------------------
// Test whether an InstallTrigger.enabled is working
add_task(async function test() {
await BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT);
function test() {
waitForExplicitFinish();
let text = await ContentTask.spawn(
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, TESTROOT);
ContentTask.spawn(
gBrowser.selectedBrowser,
TESTROOT + "enabled.html",
function(url) {
@ -23,8 +25,9 @@ add_task(async function test() {
content.location.href = url;
});
}
);
).then(text => {
is(text, "true", "installTrigger should have been enabled");
gBrowser.removeCurrentTab();
finish();
});
}

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

@ -1,13 +1,11 @@
// ----------------------------------------------------------------------------
// Test whether an InstallTrigger.enabled is working
async function test() {
function test() {
waitForExplicitFinish();
Services.prefs.setBoolPref("xpinstall.enabled", false);
let tab = BrowserTestUtils.addTab(gBrowser, TESTROOT);
gBrowser.selectedTab = tab;
await BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, TESTROOT);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, TESTROOT);
ContentTask.spawn(
gBrowser.selectedBrowser,

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

@ -1,6 +1,6 @@
// ----------------------------------------------------------------------------
// Test whether an InstallTrigger.install call fails when xpinstall is disabled
async function test() {
function test() {
Harness.installDisabledCallback = install_disabled;
Harness.installBlockedCallback = allow_blocked;
Harness.installConfirmCallback = confirm_install;
@ -13,9 +13,7 @@ async function test() {
"Unsigned XPI": TESTROOT + "amosigned.xpi",
})
);
let tab = BrowserTestUtils.addTab(gBrowser, TESTROOT);
gBrowser.selectedTab = tab;
await BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, TESTROOT);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, TESTROOT);
ContentTask.spawn(
gBrowser.selectedBrowser,

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

@ -208,6 +208,11 @@ OfflineCacheUpdateParent::GetTopFrameElement(dom::Element** aElement) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
OfflineCacheUpdateParent::GetNestedFrameId(uint64_t* aId) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
OfflineCacheUpdateParent::GetIsContent(bool* aIsContent) {
return NS_ERROR_NOT_IMPLEMENTED;