From ef3c975bc9681724f137ac4c21d43389865105e9 Mon Sep 17 00:00:00 2001 From: Brindusan Cristian Date: Wed, 9 Oct 2019 11:50:37 +0300 Subject: [PATCH] Backed out 11 changesets (bug 1578624) for build bustages. CLOSED TREE Backed out changeset b22733eb880f (bug 1578624) Backed out changeset cb5e15489635 (bug 1578624) Backed out changeset f1746b2f9dec (bug 1578624) Backed out changeset d08a099a22ff (bug 1578624) Backed out changeset 8ebd563c72a8 (bug 1578624) Backed out changeset d8bfec2dc9b6 (bug 1578624) Backed out changeset 591664928bce (bug 1578624) Backed out changeset 63f5a619b9ef (bug 1578624) Backed out changeset ff67cc13cdf3 (bug 1578624) Backed out changeset 43556c937a09 (bug 1578624) Backed out changeset 49065a55694d (bug 1578624) --- browser/base/content/browser.js | 76 +++------ browser/base/content/tabbrowser.js | 11 +- .../netmonitor/test/browser_net_cause.js | 3 +- .../test/browser_net_websocket_stacks.js | 2 +- .../test/browser_net_worker_stacks.js | 2 +- .../responsive/browser/web-navigation.js | 26 ++- docshell/base/BrowsingContext.cpp | 58 +------ docshell/base/BrowsingContext.h | 9 +- docshell/base/nsDocShell.cpp | 159 ++++++++++++++---- docshell/base/nsDocShell.h | 8 +- docshell/base/nsDocShellLoadState.cpp | 141 ---------------- docshell/base/nsDocShellLoadState.h | 28 --- docshell/base/nsDocShellLoadTypes.h | 5 +- docshell/base/nsIDocShell.idl | 6 +- docshell/shistory/nsSHistory.cpp | 2 +- dom/base/nsFrameLoader.cpp | 2 +- dom/chrome-webidl/BrowsingContext.webidl | 17 -- dom/clients/manager/ClientNavigateOpChild.cpp | 2 +- dom/ipc/BrowserChild.cpp | 6 +- dom/ipc/ContentChild.cpp | 4 + dom/ipc/DOMTypes.ipdlh | 3 - dom/ipc/PWindowGlobal.ipdl | 6 +- dom/ipc/WindowGlobalChild.cpp | 37 +--- dom/ipc/WindowGlobalChild.h | 5 +- dom/ipc/WindowGlobalParent.cpp | 5 +- dom/ipc/WindowGlobalParent.h | 3 +- dom/webidl/LoadURIOptions.webidl | 6 - ipc/glue/URIParams.ipdlh | 1 - ipc/glue/URIUtils.cpp | 7 +- netwerk/base/nsStandardURL.cpp | 1 - .../res/SubstitutingProtocolHandler.cpp | 5 - netwerk/protocol/res/SubstitutingURL.h | 2 - toolkit/actors/WebNavigationChild.jsm | 99 +++++++++++ .../RemoteWebNavigation.jsm | 34 +++- .../windowwatcher/nsWindowWatcher.cpp | 8 + toolkit/modules/ActorManagerParent.jsm | 1 + 36 files changed, 338 insertions(+), 452 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index cf7c8975b4f4..0ef93f983e05 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1279,11 +1279,18 @@ XPCOMUtils.defineLazyPreferenceGetter( "privacy.popups.maxReported" ); -function doURIFixup(browser, fixupInfo) { +function gKeywordURIFixup({ target: browser, data: fixupInfo }) { + let deserializeURI = url => { + if (url instanceof Ci.nsIURI) { + return url; + } + return url ? makeURI(url) : null; + }; + // We get called irrespective of whether we did a keyword search, or // whether the original input would be vaguely interpretable as a URL, // so figure that out first. - let alternativeURI = fixupInfo.fixedURI; + let alternativeURI = deserializeURI(fixupInfo.fixedURI); if ( !fixupInfo.keywordProviderName || !alternativeURI || @@ -1303,7 +1310,7 @@ function doURIFixup(browser, fixupInfo) { // We keep track of the currentURI to detect case (1) in the DNS lookup // callback. let previousURI = browser.currentURI; - let preferredURI = fixupInfo.preferredURI; + let preferredURI = deserializeURI(fixupInfo.preferredURI); // now swap for a weak ref so we don't hang on to browser needlessly // even if the DNS query takes forever @@ -1429,35 +1436,6 @@ function doURIFixup(browser, fixupInfo) { } } -function gKeywordURIFixupObs(fixupInfo, topic, data) { - fixupInfo.QueryInterface(Ci.nsIURIFixupInfo); - - if (!fixupInfo.consumer || fixupInfo.consumer.ownerGlobal != window) { - return; - } - - doURIFixup(fixupInfo.consumer, { - fixedURI: fixupInfo.fixedURI, - keywordProviderName: fixupInfo.keywordProviderName, - preferredURI: fixupInfo.preferredURI, - }); -} - -function gKeywordURIFixup({ target: browser, data: fixupInfo }) { - let deserializeURI = url => { - if (url instanceof Ci.nsIURI) { - return url; - } - return url ? makeURI(url) : null; - }; - - doURIFixup(browser, { - fixedURI: deserializeURI(fixupInfo.fixedURI), - keywordProviderName: fixupInfo.keywordProviderName, - preferredURI: deserializeURI(fixupInfo.preferredURI), - }); -} - function serializeInputStream(aStream) { let data = { content: NetUtil.readInputStreamToString(aStream, aStream.available()), @@ -2076,7 +2054,6 @@ var gBrowserInit = { "Browser:URIFixup", gKeywordURIFixup ); - Services.obs.addObserver(gKeywordURIFixupObs, "keyword-uri-fixup"); BrowserOffline.init(); IndexedDBPromptHelper.init(); @@ -2612,7 +2589,6 @@ var gBrowserInit = { "Browser:URIFixup", gKeywordURIFixup ); - Services.obs.removeObserver(gKeywordURIFixupObs, "keyword-uri-fixup"); window.messageManager.removeMessageListener( "Browser:LoadURI", RedirectLoad @@ -6456,8 +6432,7 @@ nsBrowserAccess.prototype = { aTriggeringPrincipal = null, aNextRemoteTabId = 0, aName = "", - aCsp = null, - aSkipLoad = false + aCsp = null ) { let win, needToFocusWin; @@ -6496,7 +6471,6 @@ nsBrowserAccess.prototype = { nextRemoteTabId: aNextRemoteTabId, name: aName, csp: aCsp, - skipLoad: aSkipLoad, }); let browser = win.gBrowser.getBrowserForTab(tab); @@ -6521,8 +6495,7 @@ nsBrowserAccess.prototype = { aWhere, aFlags, aTriggeringPrincipal, - aCsp, - true + aCsp ); }, @@ -6537,8 +6510,7 @@ nsBrowserAccess.prototype = { aWhere, aFlags, aTriggeringPrincipal, - aCsp, - false + aCsp ); }, @@ -6548,8 +6520,7 @@ nsBrowserAccess.prototype = { aWhere, aFlags, aTriggeringPrincipal, - aCsp, - aSkipLoad + aCsp ) { // This function should only ever be called if we're opening a URI // from a non-remote browser window (via nsContentTreeOwner). @@ -6679,8 +6650,7 @@ nsBrowserAccess.prototype = { aTriggeringPrincipal, 0, "", - aCsp, - aSkipLoad + aCsp ); if (browser) { browsingContext = browser.browsingContext; @@ -6718,17 +6688,14 @@ nsBrowserAccess.prototype = { aNextRemoteTabId, aName ) { - // Passing a null-URI to only create the content window, - // and pass true for aSkipLoad to prevent loading of - // about:blank + // Passing a null-URI to only create the content window. return this.getContentWindowOrOpenURIInFrame( null, aParams, aWhere, aFlags, aNextRemoteTabId, - aName, - true + aName ); }, @@ -6746,8 +6713,7 @@ nsBrowserAccess.prototype = { aWhere, aFlags, aNextRemoteTabId, - aName, - false + aName ); }, @@ -6757,8 +6723,7 @@ nsBrowserAccess.prototype = { aWhere, aFlags, aNextRemoteTabId, - aName, - aSkipLoad + aName ) { if (aWhere != Ci.nsIBrowserDOMWindow.OPEN_NEWTAB) { dump("Error: openURIInFrame can only open in new tabs"); @@ -6785,8 +6750,7 @@ nsBrowserAccess.prototype = { aParams.triggeringPrincipal, aNextRemoteTabId, aName, - aParams.csp, - aSkipLoad + aParams.csp ); }, diff --git a/browser/base/content/tabbrowser.js b/browser/base/content/tabbrowser.js index 8c7b3f4cd50c..5b8e3e739178 100644 --- a/browser/base/content/tabbrowser.js +++ b/browser/base/content/tabbrowser.js @@ -1612,7 +1612,6 @@ var aFocusUrlBar; var aName; var aCsp; - var aSkipLoad; if ( arguments.length == 2 && typeof arguments[1] == "object" && @@ -1643,7 +1642,6 @@ aFocusUrlBar = params.focusUrlBar; aName = params.name; aCsp = params.csp; - aSkipLoad = params.skipLoad; } // all callers of loadOneTab need to pass a valid triggeringPrincipal. @@ -1684,7 +1682,6 @@ focusUrlBar: aFocusUrlBar, name: aName, csp: aCsp, - skipLoad: aSkipLoad, }); if (!bgLoad) { this.selectedTab = tab; @@ -2097,7 +2094,6 @@ sameProcessAsFrameLoader, uriIsAboutBlank, userContextId, - skipLoad, } = {}) { let b = document.createXULElement("browser"); // Use the JSM global to create the permanentKey, so that if the @@ -2214,7 +2210,7 @@ // Prevent the superfluous initial load of a blank document // if we're going to load something other than about:blank. - if (!uriIsAboutBlank || skipLoad) { + if (!uriIsAboutBlank) { b.setAttribute("nodefaultsrc", "true"); } @@ -2581,7 +2577,6 @@ recordExecution, replayExecution, csp, - skipLoad, } = {} ) { // all callers of addTab that pass a params object need to pass @@ -2815,7 +2810,6 @@ name, recordExecution, replayExecution, - skipLoad, }); } @@ -2909,8 +2903,7 @@ // then let's just continue loading the page normally. if ( !usingPreloadedContent && - (!uriIsAboutBlank || !allowInheritPrincipal) && - !skipLoad + (!uriIsAboutBlank || !allowInheritPrincipal) ) { // pretend the user typed this so it'll be available till // the document successfully loads diff --git a/devtools/client/netmonitor/test/browser_net_cause.js b/devtools/client/netmonitor/test/browser_net_cause.js index 113d9174489c..04ac146faf8c 100644 --- a/devtools/client/netmonitor/test/browser_net_cause.js +++ b/devtools/client/netmonitor/test/browser_net_cause.js @@ -16,7 +16,8 @@ const EXPECTED_REQUESTS = [ url: CAUSE_URL, causeType: "document", causeUri: null, - stack: false, + // The document load has internal privileged JS code on the stack + stack: true, }, { method: "GET", diff --git a/devtools/client/netmonitor/test/browser_net_websocket_stacks.js b/devtools/client/netmonitor/test/browser_net_websocket_stacks.js index a99a651ff58b..8ff58c3940af 100644 --- a/devtools/client/netmonitor/test/browser_net_websocket_stacks.js +++ b/devtools/client/netmonitor/test/browser_net_websocket_stacks.js @@ -16,7 +16,7 @@ const EXPECTED_REQUESTS = [ url: TOP_URL, causeType: "document", causeUri: null, - stack: false, + stack: true, }, { method: "GET", diff --git a/devtools/client/netmonitor/test/browser_net_worker_stacks.js b/devtools/client/netmonitor/test/browser_net_worker_stacks.js index d8dd0d8a6c24..8a4622e568ca 100644 --- a/devtools/client/netmonitor/test/browser_net_worker_stacks.js +++ b/devtools/client/netmonitor/test/browser_net_worker_stacks.js @@ -17,7 +17,7 @@ const EXPECTED_REQUESTS = [ url: TOP_URL, causeType: "document", causeUri: null, - stack: false, + stack: true, }, { method: "GET", diff --git a/devtools/client/responsive/browser/web-navigation.js b/devtools/client/responsive/browser/web-navigation.js index 051091b26494..4dc5a922e1b6 100644 --- a/devtools/client/responsive/browser/web-navigation.js +++ b/devtools/client/responsive/browser/web-navigation.js @@ -7,6 +7,12 @@ const { Cc, Ci, Cu, Cr } = require("chrome"); const ChromeUtils = require("ChromeUtils"); const Services = require("Services"); +const { NetUtil } = require("resource://gre/modules/NetUtil.jsm"); +const { E10SUtils } = require("resource://gre/modules/E10SUtils.jsm"); + +function readInputStreamToString(stream) { + return NetUtil.readInputStreamToString(stream, stream.available()); +} /** * This object aims to provide the nsIWebNavigation interface for mozbrowser elements. @@ -73,18 +79,22 @@ BrowserElementWebNavigation.prototype = { triggeringPrincipal ) { // No equivalent in the current BrowserElement API - const referrerInfo = Cc["@mozilla.org/referrer-info;1"].createInstance( + let referrerInfo = Cc["@mozilla.org/referrer-info;1"].createInstance( Ci.nsIReferrerInfo ); referrerInfo.init(referrerPolicy, true, referrer); - - this._browser.frameLoader.browsingContext.loadURI(uri, { - loadFlags: flags, + referrerInfo = E10SUtils.serializeReferrerInfo(referrerInfo); + this._sendMessage("WebNavigation:LoadURI", { + uri, + flags, referrerInfo, - postData, - headers, - baseURI, - triggeringPrincipal, + postData: postData ? readInputStreamToString(postData) : null, + headers: headers ? readInputStreamToString(headers) : null, + baseURI: baseURI ? baseURI.spec : null, + triggeringPrincipal: E10SUtils.serializePrincipal( + triggeringPrincipal || + Services.scriptSecurityManager.createNullPrincipal({}) + ), }); }, diff --git a/docshell/base/BrowsingContext.cpp b/docshell/base/BrowsingContext.cpp index cf87d87732b0..620d3afac8c1 100644 --- a/docshell/base/BrowsingContext.cpp +++ b/docshell/base/BrowsingContext.cpp @@ -24,11 +24,9 @@ #include "mozilla/dom/WindowProxyHolder.h" #include "mozilla/Assertions.h" #include "mozilla/ClearOnShutdown.h" -#include "mozilla/Components.h" #include "mozilla/HashTable.h" #include "mozilla/Logging.h" #include "mozilla/StaticPtr.h" -#include "nsIURIFixup.h" #include "nsDocShell.h" #include "nsGlobalWindowOuter.h" @@ -807,40 +805,8 @@ void BrowsingContext::Location(JSContext* aCx, } } -void BrowsingContext::LoadURI(const nsAString& aURI, - const LoadURIOptions& aOptions, - ErrorResult& aError) { - nsCOMPtr uriFixup = components::URIFixup::Service(); - - nsCOMPtr consumer = mDocShell.get(); - if (!consumer) { - consumer = mEmbedderElement; - } - if (!consumer) { - aError.Throw(NS_ERROR_UNEXPECTED); - return; - } - - RefPtr loadState; - nsresult rv = nsDocShellLoadState::CreateFromLoadURIOptions( - consumer, uriFixup, aURI, aOptions, getter_AddRefs(loadState)); - - if (rv == NS_ERROR_MALFORMED_URI) { - DisplayLoadError(aURI); - return; - } - - if (NS_FAILED(rv)) { - aError.Throw(rv); - return; - } - - LoadURI(nullptr, loadState, true); -} - nsresult BrowsingContext::LoadURI(BrowsingContext* aAccessor, - nsDocShellLoadState* aLoadState, - bool aSetNavigating) { + nsDocShellLoadState* aLoadState) { // Per spec, most load attempts are silently ignored when a BrowsingContext is // null (which in our code corresponds to discarded), so we simply fail // silently in those cases. Regardless, we cannot trigger loads in/from @@ -850,12 +816,12 @@ nsresult BrowsingContext::LoadURI(BrowsingContext* aAccessor, } if (mDocShell) { - return mDocShell->LoadURI(aLoadState, aSetNavigating); + return mDocShell->LoadURI(aLoadState); } if (!aAccessor && XRE_IsParentProcess()) { Unused << Canonical()->GetCurrentWindowGlobal()->SendLoadURIInChild( - aLoadState, aSetNavigating); + aLoadState); } else { MOZ_DIAGNOSTIC_ASSERT(aAccessor); MOZ_DIAGNOSTIC_ASSERT(aAccessor->Group() == Group()); @@ -864,28 +830,12 @@ nsresult BrowsingContext::LoadURI(BrowsingContext* aAccessor, MOZ_DIAGNOSTIC_ASSERT(win); if (WindowGlobalChild* wgc = win->GetCurrentInnerWindow()->GetWindowGlobalChild()) { - wgc->SendLoadURI(this, aLoadState, aSetNavigating); + wgc->SendLoadURI(this, aLoadState); } } return NS_OK; } -void BrowsingContext::DisplayLoadError(const nsAString& aURI) { - MOZ_LOG(GetLog(), LogLevel::Debug, ("DisplayLoadError")); - MOZ_DIAGNOSTIC_ASSERT(!IsDiscarded()); - MOZ_DIAGNOSTIC_ASSERT(mDocShell || XRE_IsParentProcess()); - - if (mDocShell) { - bool didDisplayLoadError = false; - mDocShell->DisplayLoadError(NS_ERROR_MALFORMED_URI, nullptr, - PromiseFlatString(aURI).get(), nullptr, - &didDisplayLoadError); - } else { - Unused << Canonical()->GetCurrentWindowGlobal()->SendDisplayLoadError( - PromiseFlatString(aURI)); - } -} - void BrowsingContext::Close(CallerType aCallerType, ErrorResult& aError) { // FIXME We need to set mClosed, but only once we're sending the // DOMWindowClose event (which happens in the process where the diff --git a/docshell/base/BrowsingContext.h b/docshell/base/BrowsingContext.h index 127dc3319b7e..f1516708943c 100644 --- a/docshell/base/BrowsingContext.h +++ b/docshell/base/BrowsingContext.h @@ -12,7 +12,6 @@ #include "mozilla/Tuple.h" #include "mozilla/WeakPtr.h" #include "mozilla/dom/BindingDeclarations.h" -#include "mozilla/dom/LoadURIOptionsBinding.h" #include "mozilla/dom/LocationBase.h" #include "mozilla/dom/UserActivation.h" #include "nsCOMPtr.h" @@ -186,13 +185,7 @@ class BrowsingContext : public nsWrapperCache, public BrowsingContextBase { // Triggers a load in the process which currently owns this BrowsingContext. // aAccessor is the context which initiated the load, and may be null only for // in-process BrowsingContexts. - nsresult LoadURI(BrowsingContext* aAccessor, nsDocShellLoadState* aLoadState, - bool aSetNavigating = false); - - void LoadURI(const nsAString& aURI, const LoadURIOptions& aOptions, - ErrorResult& aError); - - void DisplayLoadError(const nsAString& aURI); + nsresult LoadURI(BrowsingContext* aAccessor, nsDocShellLoadState* aLoadState); // Determine if the current BrowsingContext was 'cached' by the logic in // CacheChildren. diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 0ba173b11b69..ec15006eb5e6 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -689,7 +689,7 @@ nsDocShell::SetCancelContentJSEpoch(int32_t aEpoch) { } NS_IMETHODIMP -nsDocShell::LoadURI(nsDocShellLoadState* aLoadState, bool aSetNavigating) { +nsDocShell::LoadURI(nsDocShellLoadState* aLoadState) { MOZ_ASSERT(aLoadState, "Must have a valid load state!"); MOZ_ASSERT( (aLoadState->LoadFlags() & INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS) == 0, @@ -704,31 +704,6 @@ nsDocShell::LoadURI(nsDocShellLoadState* aLoadState, bool aSetNavigating) { } } - bool oldIsNavigating = mIsNavigating; - auto cleanupIsNavigating = - MakeScopeExit([&]() { mIsNavigating = oldIsNavigating; }); - if (aSetNavigating) { - mIsNavigating = true; - } - - PopupBlocker::PopupControlState popupState; - if (aLoadState->LoadFlags() & LOAD_FLAGS_ALLOW_POPUPS) { - popupState = PopupBlocker::openAllowed; - } else { - popupState = PopupBlocker::openOverridden; - } - AutoPopupStatePusher statePusher(popupState); - - if (aLoadState->GetOriginalURIString().isSome()) { - // Save URI string in case it's needed later when - // sending to search engine service in EndPageLoad() - mOriginalUriString = *aLoadState->GetOriginalURIString(); - } - - if (aLoadState->GetCancelContentJSEpoch().isSome()) { - SetCancelContentJSEpoch(*aLoadState->GetCancelContentJSEpoch()); - } - // Note: we allow loads to get through here even if mFiredUnloadEvent is // true; that case will get handled in LoadInternal or LoadHistoryEntry, // so we pass false as the second parameter to IsNavigationAllowed. @@ -3834,28 +3809,141 @@ nsDocShell::GotoIndex(int32_t aIndex) { nsresult nsDocShell::LoadURI(const nsAString& aURI, const LoadURIOptions& aLoadURIOptions) { + uint32_t loadFlags = aLoadURIOptions.mLoadFlags; + + NS_ASSERTION((loadFlags & INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS) == 0, + "Unexpected flags"); + if (!IsNavigationAllowed()) { return NS_OK; // JS may not handle returning of an error code } - RefPtr loadState; - nsresult rv = nsDocShellLoadState::CreateFromLoadURIOptions( - GetAsSupports(this), sURIFixup, aURI, aLoadURIOptions, - getter_AddRefs(loadState)); + auto cleanupIsNavigating = MakeScopeExit([&]() { mIsNavigating = false; }); + mIsNavigating = true; + + nsCOMPtr uri; + nsCOMPtr postData(aLoadURIOptions.mPostData); + nsresult rv = NS_OK; + + NS_ConvertUTF16toUTF8 uriString(aURI); + // Cleanup the empty spaces that might be on each end. + uriString.Trim(" "); + // Eliminate embedded newlines, which single-line text fields now allow: + uriString.StripCRLF(); + NS_ENSURE_TRUE(!uriString.IsEmpty(), NS_ERROR_FAILURE); + + if (mUseStrictSecurityChecks && !aLoadURIOptions.mTriggeringPrincipal) { + return NS_ERROR_FAILURE; + } + + nsCOMPtr fixupInfo; + if (sURIFixup) { + uint32_t fixupFlags; + rv = sURIFixup->WebNavigationFlagsToFixupFlags(uriString, loadFlags, + &fixupFlags); + NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); + + // If we don't allow keyword lookups for this URL string, make sure to + // update loadFlags to indicate this as well. + if (!(fixupFlags & nsIURIFixup::FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP)) { + loadFlags &= ~LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP; + } + + nsCOMPtr fixupStream; + rv = sURIFixup->GetFixupURIInfo(uriString, fixupFlags, + getter_AddRefs(fixupStream), + getter_AddRefs(fixupInfo)); + + if (NS_SUCCEEDED(rv)) { + fixupInfo->GetPreferredURI(getter_AddRefs(uri)); + fixupInfo->SetConsumer(GetAsSupports(this)); + } + + if (fixupStream) { + // GetFixupURIInfo only returns a post data stream if it succeeded + // and changed the URI, in which case we should override the + // passed-in post data. + postData = fixupStream; + } + + if (loadFlags & LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP) { + nsCOMPtr serv = services::GetObserverService(); + if (serv) { + serv->NotifyObservers(fixupInfo, "keyword-uri-fixup", + PromiseFlatString(aURI).get()); + } + } + } else { + // No fixup service so just create a URI and see what happens... + rv = NS_NewURI(getter_AddRefs(uri), uriString); + loadFlags &= ~LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP; + } - uint32_t loadFlags = aLoadURIOptions.mLoadFlags; if (NS_ERROR_MALFORMED_URI == rv) { - if (DisplayLoadError(rv, nullptr, PromiseFlatString(aURI).get(), nullptr) && + if (DisplayLoadError(rv, uri, PromiseFlatString(aURI).get(), nullptr) && (loadFlags & LOAD_FLAGS_ERROR_LOAD_CHANGES_RV) != 0) { return NS_ERROR_LOAD_SHOWED_ERRORPAGE; } } - if (NS_FAILED(rv) || !loadState) { + if (NS_FAILED(rv) || !uri) { return NS_ERROR_FAILURE; } - return LoadURI(loadState, true); + PopupBlocker::PopupControlState popupState; + if (loadFlags & LOAD_FLAGS_ALLOW_POPUPS) { + popupState = PopupBlocker::openAllowed; + loadFlags &= ~LOAD_FLAGS_ALLOW_POPUPS; + } else { + popupState = PopupBlocker::openOverridden; + } + AutoPopupStatePusher statePusher(popupState); + + bool forceAllowDataURI = loadFlags & LOAD_FLAGS_FORCE_ALLOW_DATA_URI; + + // Don't pass certain flags that aren't needed and end up confusing + // ConvertLoadTypeToDocShellInfoLoadType. We do need to ensure that they are + // passed to LoadURI though, since it uses them. + uint32_t extraFlags = (loadFlags & EXTRA_LOAD_FLAGS); + loadFlags &= ~EXTRA_LOAD_FLAGS; + + RefPtr loadState = new nsDocShellLoadState(uri); + loadState->SetReferrerInfo(aLoadURIOptions.mReferrerInfo); + + /* + * If the user "Disables Protection on This Page", we have to make sure to + * remember the users decision when opening links in child tabs [Bug 906190] + */ + if (loadFlags & LOAD_FLAGS_ALLOW_MIXED_CONTENT) { + loadState->SetLoadType( + MAKE_LOAD_TYPE(LOAD_NORMAL_ALLOW_MIXED_CONTENT, loadFlags)); + } else { + loadState->SetLoadType(MAKE_LOAD_TYPE(LOAD_NORMAL, loadFlags)); + } + + loadState->SetLoadFlags(extraFlags); + loadState->SetFirstParty(true); + loadState->SetPostDataStream(postData); + loadState->SetHeadersStream(aLoadURIOptions.mHeaders); + loadState->SetBaseURI(aLoadURIOptions.mBaseURI); + loadState->SetTriggeringPrincipal(aLoadURIOptions.mTriggeringPrincipal); + loadState->SetCsp(aLoadURIOptions.mCsp); + loadState->SetForceAllowDataURI(forceAllowDataURI); + + if (fixupInfo) { + nsAutoString searchProvider, keyword; + fixupInfo->GetKeywordProviderName(searchProvider); + fixupInfo->GetKeywordAsSent(keyword); + MaybeNotifyKeywordSearchLoading(searchProvider, keyword); + } + + rv = LoadURI(loadState); + + // Save URI string in case it's needed later when + // sending to search engine service in EndPageLoad() + mOriginalUriString = uriString; + + return rv; } NS_IMETHODIMP @@ -5746,7 +5834,7 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal, * LoadURI(...) will cancel all refresh timers... This causes the * Timer and its refreshData instance to be released... */ - LoadURI(loadState, false); + LoadURI(loadState); return NS_OK; } @@ -13407,7 +13495,6 @@ void nsDocShell::NotifyJSRunToCompletionStop() { } } -/* static */ void nsDocShell::MaybeNotifyKeywordSearchLoading(const nsString& aProvider, const nsString& aKeyword) { if (aProvider.IsEmpty()) { diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 6338967342ed..c3e9487e9e70 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -486,10 +486,6 @@ class nsDocShell final : public nsDocLoader, const nsString* aInitiatorType, uint32_t aLoadType, uint32_t aCacheKey); - // Notify consumers of a search being loaded through the observer service: - static void MaybeNotifyKeywordSearchLoading(const nsString& aProvider, - const nsString& aKeyword); - private: // member functions friend class nsDSURIContentListener; friend class FramingChecker; @@ -960,6 +956,10 @@ class nsDocShell final : public nsDocLoader, // OriginAttributes.mPrivateBrowsingId void AssertOriginAttributesMatchPrivateBrowsing(); + // Notify consumers of a search being loaded through the observer service: + void MaybeNotifyKeywordSearchLoading(const nsString& aProvider, + const nsString& aKeyword); + // Internal implementation of nsIDocShell::FirePageHideNotification. // If aSkipCheckingDynEntries is true, it will not try to remove dynamic // subframe entries. This is to avoid redundant RemoveDynEntries calls in all diff --git a/docshell/base/nsDocShellLoadState.cpp b/docshell/base/nsDocShellLoadState.cpp index d7f33033fbe4..5c5ffbd5dffd 100644 --- a/docshell/base/nsDocShellLoadState.cpp +++ b/docshell/base/nsDocShellLoadState.cpp @@ -11,7 +11,6 @@ #include "nsIWebNavigation.h" #include "nsIChildChannel.h" #include "ReferrerInfo.h" -#include "mozilla/dom/LoadURIOptionsBinding.h" #include "mozilla/OriginAttributes.h" #include "mozilla/NullPrincipal.h" @@ -67,8 +66,6 @@ nsDocShellLoadState::nsDocShellLoadState( mTriggeringPrincipal = aLoadState.TriggeringPrincipal(); mPrincipalToInherit = aLoadState.PrincipalToInherit(); mCsp = aLoadState.Csp(); - mOriginalURIString = aLoadState.OriginalURIString(); - mCancelContentJSEpoch = aLoadState.CancelContentJSEpoch(); mPostDataStream = aLoadState.PostDataStream(); mHeadersStream = aLoadState.HeadersStream(); } @@ -110,142 +107,6 @@ nsresult nsDocShellLoadState::CreateFromPendingChannel( return NS_OK; } -nsresult nsDocShellLoadState::CreateFromLoadURIOptions( - nsISupports* aConsumer, nsIURIFixup* aURIFixup, const nsAString& aURI, - const LoadURIOptions& aLoadURIOptions, nsDocShellLoadState** aResult) { - uint32_t loadFlags = aLoadURIOptions.mLoadFlags; - - NS_ASSERTION( - (loadFlags & nsDocShell::INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS) == 0, - "Unexpected flags"); - - nsCOMPtr uri; - nsCOMPtr postData(aLoadURIOptions.mPostData); - nsresult rv = NS_OK; - - NS_ConvertUTF16toUTF8 uriString(aURI); - // Cleanup the empty spaces that might be on each end. - uriString.Trim(" "); - // Eliminate embedded newlines, which single-line text fields now allow: - uriString.StripCRLF(); - NS_ENSURE_TRUE(!uriString.IsEmpty(), NS_ERROR_FAILURE); - - nsCOMPtr fixupInfo; - if (aURIFixup) { - uint32_t fixupFlags; - rv = aURIFixup->WebNavigationFlagsToFixupFlags(uriString, loadFlags, - &fixupFlags); - NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); - - // If we don't allow keyword lookups for this URL string, make sure to - // update loadFlags to indicate this as well. - if (!(fixupFlags & nsIURIFixup::FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP)) { - loadFlags &= ~nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP; - } - - nsCOMPtr fixupStream; - rv = aURIFixup->GetFixupURIInfo(uriString, fixupFlags, - getter_AddRefs(fixupStream), - getter_AddRefs(fixupInfo)); - - if (NS_SUCCEEDED(rv)) { - fixupInfo->GetPreferredURI(getter_AddRefs(uri)); - fixupInfo->SetConsumer(aConsumer); - } - - if (fixupStream) { - // GetFixupURIInfo only returns a post data stream if it succeeded - // and changed the URI, in which case we should override the - // passed-in post data. - postData = fixupStream; - } - - if (loadFlags & nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP) { - nsCOMPtr serv = services::GetObserverService(); - if (serv) { - serv->NotifyObservers(fixupInfo, "keyword-uri-fixup", - PromiseFlatString(aURI).get()); - } - } - } else { - // No fixup service so just create a URI and see what happens... - rv = NS_NewURI(getter_AddRefs(uri), uriString); - loadFlags &= ~nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP; - } - - if (rv == NS_ERROR_MALFORMED_URI) { - MOZ_ASSERT(!uri); - return rv; - } - - if (NS_FAILED(rv) || !uri) { - return NS_ERROR_FAILURE; - } - - uint64_t available; - if (postData) { - rv = postData->Available(&available); - NS_ENSURE_SUCCESS(rv, rv); - if (available == 0) { - return NS_ERROR_INVALID_ARG; - } - } - - if (aLoadURIOptions.mHeaders) { - rv = aLoadURIOptions.mHeaders->Available(&available); - NS_ENSURE_SUCCESS(rv, rv); - if (available == 0) { - return NS_ERROR_INVALID_ARG; - } - } - - bool forceAllowDataURI = - loadFlags & nsIWebNavigation::LOAD_FLAGS_FORCE_ALLOW_DATA_URI; - - // Don't pass certain flags that aren't needed and end up confusing - // ConvertLoadTypeToDocShellInfoLoadType. We do need to ensure that they are - // passed to LoadURI though, since it uses them. - uint32_t extraFlags = (loadFlags & EXTRA_LOAD_FLAGS); - loadFlags &= ~EXTRA_LOAD_FLAGS; - - RefPtr loadState = new nsDocShellLoadState(uri); - loadState->SetReferrerInfo(aLoadURIOptions.mReferrerInfo); - - /* - * If the user "Disables Protection on This Page", we have to make sure to - * remember the users decision when opening links in child tabs [Bug 906190] - */ - if (loadFlags & nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT) { - loadState->SetLoadType( - MAKE_LOAD_TYPE(LOAD_NORMAL_ALLOW_MIXED_CONTENT, loadFlags)); - } else { - loadState->SetLoadType(MAKE_LOAD_TYPE(LOAD_NORMAL, loadFlags)); - } - - loadState->SetLoadFlags(extraFlags); - loadState->SetFirstParty(true); - loadState->SetPostDataStream(postData); - loadState->SetHeadersStream(aLoadURIOptions.mHeaders); - loadState->SetBaseURI(aLoadURIOptions.mBaseURI); - loadState->SetTriggeringPrincipal(aLoadURIOptions.mTriggeringPrincipal); - loadState->SetCsp(aLoadURIOptions.mCsp); - loadState->SetForceAllowDataURI(forceAllowDataURI); - loadState->SetOriginalURIString(uriString); - if (aLoadURIOptions.mCancelContentJSEpoch) { - loadState->SetCancelContentJSEpoch(aLoadURIOptions.mCancelContentJSEpoch); - } - - if (fixupInfo) { - nsAutoString searchProvider, keyword; - fixupInfo->GetKeywordProviderName(searchProvider); - fixupInfo->GetKeywordAsSent(keyword); - nsDocShell::MaybeNotifyKeywordSearchLoading(searchProvider, keyword); - } - - loadState.forget(aResult); - return NS_OK; -} - nsIReferrerInfo* nsDocShellLoadState::GetReferrerInfo() const { return mReferrerInfo; } @@ -619,8 +480,6 @@ DocShellLoadStateInit nsDocShellLoadState::Serialize() { loadState.TriggeringPrincipal() = mTriggeringPrincipal; loadState.PrincipalToInherit() = mPrincipalToInherit; loadState.Csp() = mCsp; - loadState.OriginalURIString() = mOriginalURIString; - loadState.CancelContentJSEpoch() = mCancelContentJSEpoch; loadState.ReferrerInfo() = mReferrerInfo; loadState.PostDataStream() = mPostDataStream; loadState.HeadersStream() = mHeadersStream; diff --git a/docshell/base/nsDocShellLoadState.h b/docshell/base/nsDocShellLoadState.h index 66ce7503b89f..aa48f28f5806 100644 --- a/docshell/base/nsDocShellLoadState.h +++ b/docshell/base/nsDocShellLoadState.h @@ -41,11 +41,6 @@ class nsDocShellLoadState final { static nsresult CreateFromPendingChannel(nsIChildChannel* aPendingChannel, nsDocShellLoadState** aResult); - static nsresult CreateFromLoadURIOptions( - nsISupports* aConsumer, nsIURIFixup* aURIFixup, const nsAString& aURI, - const mozilla::dom::LoadURIOptions& aLoadURIOptions, - nsDocShellLoadState** aResult); - // Getters and Setters nsIReferrerInfo* GetReferrerInfo() const; @@ -197,20 +192,6 @@ class nsDocShellLoadState final { return mPendingRedirectedChannel; } - void SetOriginalURIString(const nsCString& aOriginalURI) { - mOriginalURIString.emplace(aOriginalURI); - } - const Maybe& GetOriginalURIString() const { - return mOriginalURIString; - } - - void SetCancelContentJSEpoch(int32_t aCancelEpoch) { - mCancelContentJSEpoch.emplace(aCancelEpoch); - } - const Maybe& GetCancelContentJSEpoch() const { - return mCancelContentJSEpoch; - } - // When loading a document through nsDocShell::LoadURI(), a special set of // flags needs to be set based on other values in nsDocShellLoadState. This // function calculates those flags, before the LoadState is passed to @@ -357,15 +338,6 @@ class nsDocShellLoadState final { // If set, a pending cross-process redirected channel should be used to // perform the load. The channel will be stored in this value. nsCOMPtr mPendingRedirectedChannel; - - // An optional string representation of mURI, before any - // fixups were applied, so that we can send it to a search - // engine service if needed. - Maybe mOriginalURIString; - - // An optional value to pass to nsIDocShell::setCancelJSEpoch - // when initiating the load. - Maybe mCancelContentJSEpoch; }; #endif /* nsDocShellLoadState_h__ */ diff --git a/docshell/base/nsDocShellLoadTypes.h b/docshell/base/nsDocShellLoadTypes.h index e694843b2daf..2c22e6f0204a 100644 --- a/docshell/base/nsDocShellLoadTypes.h +++ b/docshell/base/nsDocShellLoadTypes.h @@ -28,9 +28,8 @@ * above 0xffff (e.g. LOAD_FLAGS_BYPASS_CLASSIFIER), since MAKE_LOAD_TYPE would * just shift them out anyway. */ -# define EXTRA_LOAD_FLAGS \ - (nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD | \ - nsIWebNavigation::LOAD_FLAGS_ALLOW_POPUPS | 0xffff0000) +# define EXTRA_LOAD_FLAGS \ + (LOAD_FLAGS_FIRST_LOAD | LOAD_FLAGS_ALLOW_POPUPS | 0xffff0000) /* load types are legal combinations of load commands and flags * diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl index 6251da852c0f..7dd8692e3427 100644 --- a/docshell/base/nsIDocShell.idl +++ b/docshell/base/nsIDocShell.idl @@ -84,11 +84,9 @@ interface nsIDocShell : nsIDocShellTreeItem * however, the URL dispatcher will go through its normal process of content * loading. * - * @param aLoadState This is the extended load info for this load. - * @param aSetNavigating If we should set isNavigating to true while initiating - * the load. + * @param loadState - This is the extended load info for this load. */ - [noscript]void loadURI(in nsDocShellLoadStatePtr aLoadState, in boolean aSetNavigating); + [noscript]void loadURI(in nsDocShellLoadStatePtr loadState); /** * Do either a history.pushState() or history.replaceState() operation, diff --git a/docshell/shistory/nsSHistory.cpp b/docshell/shistory/nsSHistory.cpp index 7f45f0b8146d..c42f27824969 100644 --- a/docshell/shistory/nsSHistory.cpp +++ b/docshell/shistory/nsSHistory.cpp @@ -1482,5 +1482,5 @@ nsresult nsSHistory::InitiateLoad(nsISHEntry* aFrameEntry, loadState->SetCsp(csp); // Time to initiate a document load - return aFrameDS->LoadURI(loadState, false); + return aFrameDS->LoadURI(loadState); } diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 3a54a033d665..53262c63f4d9 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -667,7 +667,7 @@ nsresult nsFrameLoader::ReallyStartLoadingInternal() { mNeedsAsyncDestroy = true; loadState->SetLoadFlags(flags); loadState->SetFirstParty(false); - rv = GetDocShell()->LoadURI(loadState, false); + rv = GetDocShell()->LoadURI(loadState); mNeedsAsyncDestroy = tmpState; mURIToLoad = nullptr; NS_ENSURE_SUCCESS(rv, rv); diff --git a/dom/chrome-webidl/BrowsingContext.webidl b/dom/chrome-webidl/BrowsingContext.webidl index eb06eede10d4..273978a7bbb4 100644 --- a/dom/chrome-webidl/BrowsingContext.webidl +++ b/dom/chrome-webidl/BrowsingContext.webidl @@ -33,23 +33,6 @@ interface BrowsingContext { readonly attribute BrowsingContextGroup group; readonly attribute WindowProxy? window; - - /** - * Loads a given URI. This will give priority to loading the requested URI - * in the object implementing this interface. If it can't be loaded here - * however, the URI dispatcher will go through its normal process of content - * loading. - * - * @param aURI - * The URI string to load. For HTTP and FTP URLs and possibly others, - * characters above U+007F will be converted to UTF-8 and then URL- - * escaped per the rules of RFC 2396. - * @param aLoadURIOptions - * A JSObject defined in LoadURIOptions.webidl holding info like e.g. - * the triggeringPrincipal, the referrer info. - */ - [Throws] - void loadURI(DOMString aURI, optional LoadURIOptions aOptions = {}); }; [Exposed=Window, ChromeOnly] diff --git a/dom/clients/manager/ClientNavigateOpChild.cpp b/dom/clients/manager/ClientNavigateOpChild.cpp index 294afa3bb04b..797c784df81e 100644 --- a/dom/clients/manager/ClientNavigateOpChild.cpp +++ b/dom/clients/manager/ClientNavigateOpChild.cpp @@ -238,7 +238,7 @@ RefPtr ClientNavigateOpChild::DoNavigate( loadState->SetSourceDocShell(docShell); loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_NONE); loadState->SetFirstParty(true); - rv = docShell->LoadURI(loadState, false); + rv = docShell->LoadURI(loadState); if (NS_FAILED(rv)) { return ClientOpPromise::CreateAndReject(rv, __func__); } diff --git a/dom/ipc/BrowserChild.cpp b/dom/ipc/BrowserChild.cpp index 55be4cb8e9c3..949b7052b19c 100644 --- a/dom/ipc/BrowserChild.cpp +++ b/dom/ipc/BrowserChild.cpp @@ -1445,12 +1445,10 @@ mozilla::ipc::IPCResult BrowserChild::RecvActivate() { // is definitely not going to work. GetPresShell should // create a PresShell if one doesn't exist yet. RefPtr presShell = GetTopLevelPresShell(); - NS_ASSERTION(presShell, "Need a PresShell to activate!"); + MOZ_ASSERT(presShell); Unused << presShell; - if (presShell) { - mWebBrowser->FocusActivate(); - } + mWebBrowser->FocusActivate(); return IPC_OK(); } diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index c34b47cf1bf4..138ca841da68 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -1134,6 +1134,10 @@ nsresult ContentChild::ProvideWindowCommon( } } + if (!urlToLoad.IsEmpty()) { + newChild->RecvLoadURL(urlToLoad, showInfo); + } + if (xpc::IsInAutomation()) { if (nsCOMPtr outer = do_GetInterface(newChild->WebNavigation())) { diff --git a/dom/ipc/DOMTypes.ipdlh b/dom/ipc/DOMTypes.ipdlh index d48758b3f0c7..8e17ded2d54c 100644 --- a/dom/ipc/DOMTypes.ipdlh +++ b/dom/ipc/DOMTypes.ipdlh @@ -232,9 +232,6 @@ struct DocShellLoadStateInit // encounters a server side redirect. nsIContentSecurityPolicy Csp; - nsCString? OriginalURIString; - int32_t? CancelContentJSEpoch; - nsIInputStream PostDataStream; nsIInputStream HeadersStream; diff --git a/dom/ipc/PWindowGlobal.ipdl b/dom/ipc/PWindowGlobal.ipdl index 16a5a17272ae..5ff8bcf6ed2e 100644 --- a/dom/ipc/PWindowGlobal.ipdl +++ b/dom/ipc/PWindowGlobal.ipdl @@ -53,9 +53,7 @@ child: */ async GetSecurityInfo() returns(nsCString? serializedSecInfo); - async LoadURIInChild(nsDocShellLoadState aLoadState, bool aSetNavigating); - - async DisplayLoadError(nsString aURI); + async LoadURIInChild(nsDocShellLoadState aLoadState); both: async RawMessage(JSWindowActorMessageMeta aMetadata, ClonedMessageData aData); @@ -64,7 +62,7 @@ parent: // Load the given URI load state into the current owner process of the given // BrowsingContext. aTargetBC must be in the same BrowsingContextGroup as this // window global. - async LoadURI(BrowsingContext aTargetBC, nsDocShellLoadState aLoadState, bool aSetNavigating); + async LoadURI(BrowsingContext aTargetBC, nsDocShellLoadState aLoadState); /// Update the URI of the document in this WindowGlobal. async UpdateDocumentURI(nsIURI aUri); diff --git a/dom/ipc/WindowGlobalChild.cpp b/dom/ipc/WindowGlobalChild.cpp index 6ae342220222..94aa12183483 100644 --- a/dom/ipc/WindowGlobalChild.cpp +++ b/dom/ipc/WindowGlobalChild.cpp @@ -31,7 +31,6 @@ #include "mozilla/dom/JSWindowActorChild.h" #include "mozilla/dom/JSWindowActorService.h" #include "nsIHttpChannelInternal.h" -#include "nsIURIMutator.h" using namespace mozilla::ipc; using namespace mozilla::dom::ipc; @@ -235,30 +234,8 @@ void WindowGlobalChild::Destroy() { } mozilla::ipc::IPCResult WindowGlobalChild::RecvLoadURIInChild( - nsDocShellLoadState* aLoadState, bool aSetNavigating) { - mWindowGlobal->GetDocShell()->LoadURI(aLoadState, aSetNavigating); - if (aSetNavigating) { - mWindowGlobal->GetBrowserChild()->NotifyNavigationFinished(); - } - -#ifdef MOZ_CRASHREPORTER - if (CrashReporter::GetEnabled()) { - nsCOMPtr annotationURI; - - nsresult rv = NS_MutateURI(aLoadState->URI()) - .SetUserPass(EmptyCString()) - .Finalize(annotationURI); - - if (NS_FAILED(rv)) { - // Ignore failures on about: URIs. - annotationURI = aLoadState->URI(); - } - - CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::URL, - annotationURI->GetSpecOrDefault()); - } -#endif - + nsDocShellLoadState* aLoadState) { + mWindowGlobal->GetDocShell()->LoadURI(aLoadState); return IPC_OK(); } @@ -330,16 +307,6 @@ static nsresult ChangeFrameRemoteness(WindowGlobalChild* aWgc, return NS_OK; } -mozilla::ipc::IPCResult WindowGlobalChild::RecvDisplayLoadError( - const nsAString& aURI) { - bool didDisplayLoadError = false; - mWindowGlobal->GetDocShell()->DisplayLoadError( - NS_ERROR_MALFORMED_URI, nullptr, PromiseFlatString(aURI).get(), nullptr, - &didDisplayLoadError); - mWindowGlobal->GetBrowserChild()->NotifyNavigationFinished(); - return IPC_OK(); -} - IPCResult WindowGlobalChild::RecvChangeFrameRemoteness( dom::BrowsingContext* aBc, const nsString& aRemoteType, uint64_t aPendingSwitchId, ChangeFrameRemotenessResolver&& aResolver) { diff --git a/dom/ipc/WindowGlobalChild.h b/dom/ipc/WindowGlobalChild.h index b669bbd5fc75..a046f8a3d392 100644 --- a/dom/ipc/WindowGlobalChild.h +++ b/dom/ipc/WindowGlobalChild.h @@ -114,10 +114,7 @@ class WindowGlobalChild final : public WindowGlobalActor, mozilla::ipc::IPCResult RecvRawMessage(const JSWindowActorMessageMeta& aMeta, const ClonedMessageData& aData); - mozilla::ipc::IPCResult RecvLoadURIInChild(nsDocShellLoadState* aLoadState, - bool aSetNavigating); - - mozilla::ipc::IPCResult RecvDisplayLoadError(const nsAString& aURI); + mozilla::ipc::IPCResult RecvLoadURIInChild(nsDocShellLoadState* aLoadState); mozilla::ipc::IPCResult RecvChangeFrameRemoteness( dom::BrowsingContext* aBc, const nsString& aRemoteType, diff --git a/dom/ipc/WindowGlobalParent.cpp b/dom/ipc/WindowGlobalParent.cpp index 6546e4b1fdc3..bd174e13388a 100644 --- a/dom/ipc/WindowGlobalParent.cpp +++ b/dom/ipc/WindowGlobalParent.cpp @@ -175,8 +175,7 @@ bool WindowGlobalParent::IsProcessRoot() { } mozilla::ipc::IPCResult WindowGlobalParent::RecvLoadURI( - dom::BrowsingContext* aTargetBC, nsDocShellLoadState* aLoadState, - bool aSetNavigating) { + dom::BrowsingContext* aTargetBC, nsDocShellLoadState* aLoadState) { if (!aTargetBC || aTargetBC->IsDiscarded()) { MOZ_LOG( BrowsingContext::GetLog(), LogLevel::Debug, @@ -201,7 +200,7 @@ mozilla::ipc::IPCResult WindowGlobalParent::RecvLoadURI( return IPC_OK(); } - Unused << wgp->SendLoadURIInChild(aLoadState, aSetNavigating); + Unused << wgp->SendLoadURIInChild(aLoadState); return IPC_OK(); } diff --git a/dom/ipc/WindowGlobalParent.h b/dom/ipc/WindowGlobalParent.h index a7e5c088ac03..785521cc2545 100644 --- a/dom/ipc/WindowGlobalParent.h +++ b/dom/ipc/WindowGlobalParent.h @@ -140,8 +140,7 @@ class WindowGlobalParent final : public WindowGlobalActor, // IPC messages mozilla::ipc::IPCResult RecvLoadURI(dom::BrowsingContext* aTargetBC, - nsDocShellLoadState* aLoadState, - bool aSetNavigating); + nsDocShellLoadState* aLoadState); mozilla::ipc::IPCResult RecvUpdateDocumentURI(nsIURI* aURI); mozilla::ipc::IPCResult RecvSetIsInitialDocument(bool aIsInitialDocument) { mIsInitialDocument = aIsInitialDocument; diff --git a/dom/webidl/LoadURIOptions.webidl b/dom/webidl/LoadURIOptions.webidl index 8ab71b5bd356..d80513244411 100644 --- a/dom/webidl/LoadURIOptions.webidl +++ b/dom/webidl/LoadURIOptions.webidl @@ -61,10 +61,4 @@ dictionary LoadURIOptions { * and cannot be used to resolve aURI. */ URI? baseURI = null; - - /** - * If non-0, a value to pass to nsIDocShell::setCancelContentJSEpoch - * when initiating the load. - */ - long cancelContentJSEpoch = 0; }; diff --git a/ipc/glue/URIParams.ipdlh b/ipc/glue/URIParams.ipdlh index d04de96a43e6..fd27459669f4 100644 --- a/ipc/glue/URIParams.ipdlh +++ b/ipc/glue/URIParams.ipdlh @@ -43,7 +43,6 @@ struct StandardURLParams StandardURLSegment query; StandardURLSegment ref; bool supportsFileURL; - bool isSubstituting; }; struct JARURIParams diff --git a/ipc/glue/URIUtils.cpp b/ipc/glue/URIUtils.cpp index cb8bf769ed2f..e5755be0db18 100644 --- a/ipc/glue/URIUtils.cpp +++ b/ipc/glue/URIUtils.cpp @@ -9,7 +9,6 @@ #include "mozilla/ArrayUtils.h" #include "mozilla/Assertions.h" #include "mozilla/dom/BlobURL.h" -#include "mozilla/net/SubstitutingURL.h" #include "mozilla/NullPrincipalURI.h" #include "nsComponentManagerUtils.h" #include "nsDebug.h" @@ -70,11 +69,7 @@ already_AddRefed DeserializeURI(const URIParams& aParams) { break; case URIParams::TStandardURLParams: - if (aParams.get_StandardURLParams().isSubstituting()) { - mutator = new net::SubstitutingURL::Mutator(); - } else { - mutator = do_CreateInstance(kStandardURLMutatorCID); - } + mutator = do_CreateInstance(kStandardURLMutatorCID); break; case URIParams::TJARURIParams: diff --git a/netwerk/base/nsStandardURL.cpp b/netwerk/base/nsStandardURL.cpp index 2d6caaf70c18..b90b3ffcec3c 100644 --- a/netwerk/base/nsStandardURL.cpp +++ b/netwerk/base/nsStandardURL.cpp @@ -3373,7 +3373,6 @@ void nsStandardURL::Serialize(URIParams& aParams) { params.query() = ToIPCSegment(mQuery); params.ref() = ToIPCSegment(mRef); params.supportsFileURL() = !!mSupportsFileURL; - params.isSubstituting() = false; // mDisplayHost is just a cache that can be recovered as needed. aParams = params; diff --git a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp index 91ded7dea99f..a6db58791cee 100644 --- a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp +++ b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp @@ -94,11 +94,6 @@ SubstitutingURL::GetClassIDNoAlloc(nsCID* aClassIDNoAlloc) { return NS_OK; } -void SubstitutingURL::Serialize(ipc::URIParams& aParams) { - nsStandardURL::Serialize(aParams); - aParams.get_StandardURLParams().isSubstituting() = true; -} - // SubstitutingJARURI SubstitutingJARURI::SubstitutingJARURI(nsIURL* source, nsIJARURI* resolved) diff --git a/netwerk/protocol/res/SubstitutingURL.h b/netwerk/protocol/res/SubstitutingURL.h index 68a749241ced..6212121331c9 100644 --- a/netwerk/protocol/res/SubstitutingURL.h +++ b/netwerk/protocol/res/SubstitutingURL.h @@ -53,8 +53,6 @@ class SubstitutingURL : public nsStandardURL { return NS_OK; } - void Serialize(ipc::URIParams& aParams) override; - friend BaseURIMutator; friend TemplatedMutator; }; diff --git a/toolkit/actors/WebNavigationChild.jsm b/toolkit/actors/WebNavigationChild.jsm index 03ad8ba079c6..ea121475ab71 100644 --- a/toolkit/actors/WebNavigationChild.jsm +++ b/toolkit/actors/WebNavigationChild.jsm @@ -9,6 +9,28 @@ var EXPORTED_SYMBOLS = ["WebNavigationChild"]; const { ActorChild } = ChromeUtils.import( "resource://gre/modules/ActorChild.jsm" ); +const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const { XPCOMUtils } = ChromeUtils.import( + "resource://gre/modules/XPCOMUtils.jsm" +); + +ChromeUtils.defineModuleGetter( + this, + "AppConstants", + "resource://gre/modules/AppConstants.jsm" +); +ChromeUtils.defineModuleGetter( + this, + "E10SUtils", + "resource://gre/modules/E10SUtils.jsm" +); + +XPCOMUtils.defineLazyServiceGetter( + this, + "CrashReporter", + "@mozilla.org/xre/app-info;1", + "nsICrashReporter" +); class WebNavigationChild extends ActorChild { get webNavigation() { @@ -26,6 +48,9 @@ class WebNavigationChild extends ActorChild { case "WebNavigation:GotoIndex": this.gotoIndex(message.data); break; + case "WebNavigation:LoadURI": + this.loadURI(message.data); + break; case "WebNavigation:SetOriginAttributes": this.setOriginAttributes(message.data.originAttributes); break; @@ -69,6 +94,80 @@ class WebNavigationChild extends ActorChild { this._wrapURIChangeCall(() => this.webNavigation.gotoIndex(index)); } + loadURI(params) { + let { + uri, + loadFlags, + referrerInfo, + postData, + headers, + baseURI, + triggeringPrincipal, + csp, + cancelContentJSEpoch, + } = params || {}; + + if (AppConstants.MOZ_CRASHREPORTER && CrashReporter.enabled) { + let annotation = uri; + try { + let url = Services.io.newURI(uri); + // If the current URI contains a username/password, remove it. + url = url + .mutate() + .setUserPass("") + .finalize(); + annotation = url.spec; + } catch (ex) { + /* Ignore failures to parse and failures + on about: URIs. */ + } + CrashReporter.annotateCrashReport("URL", annotation); + } + if (postData) { + postData = E10SUtils.makeInputStream(postData); + } + if (headers) { + headers = E10SUtils.makeInputStream(headers); + } + if (baseURI) { + baseURI = Services.io.newURI(baseURI); + } + this._assert( + triggeringPrincipal, + "We need a triggering principal to continue loading", + new Error().lineNumber + ); + + triggeringPrincipal = E10SUtils.deserializePrincipal( + triggeringPrincipal, + () => { + this._assert( + false, + "Unable to deserialize passed triggering principal", + new Error().lineNumber + ); + return Services.scriptSecurityManager.getSystemPrincipal({}); + } + ); + if (csp) { + csp = E10SUtils.deserializeCSP(csp); + } + + let loadURIOptions = { + triggeringPrincipal, + csp, + loadFlags, + referrerInfo: E10SUtils.deserializeReferrerInfo(referrerInfo), + postData, + headers, + baseURI, + }; + this.mm.docShell.setCancelContentJSEpoch(cancelContentJSEpoch); + this._wrapURIChangeCall(() => { + return this.webNavigation.loadURI(uri, loadURIOptions); + }); + } + _assert(condition, msg, line = 0) { let debug = Cc["@mozilla.org/xpcom/debug;1"].getService(Ci.nsIDebug2); if (!condition && debug.isDebugBuild) { diff --git a/toolkit/components/remotebrowserutils/RemoteWebNavigation.jsm b/toolkit/components/remotebrowserutils/RemoteWebNavigation.jsm index 54ec3a303ae9..f7cc002116ca 100644 --- a/toolkit/components/remotebrowserutils/RemoteWebNavigation.jsm +++ b/toolkit/components/remotebrowserutils/RemoteWebNavigation.jsm @@ -8,11 +8,21 @@ ChromeUtils.defineModuleGetter( "Services", "resource://gre/modules/Services.jsm" ); +ChromeUtils.defineModuleGetter( + this, + "Utils", + "resource://gre/modules/sessionstore/Utils.jsm" +); ChromeUtils.defineModuleGetter( this, "PrivateBrowsingUtils", "resource://gre/modules/PrivateBrowsingUtils.jsm" ); +ChromeUtils.defineModuleGetter( + this, + "E10SUtils", + "resource://gre/modules/E10SUtils.jsm" +); function RemoteWebNavigation() { this.wrappedJSObject = this; @@ -126,8 +136,28 @@ RemoteWebNavigation.prototype = { Ci.nsIRemoteTab.NAVIGATE_URL, { uri, epoch: cancelContentJSEpoch } ); - aLoadURIOptions.cancelContentJSEpoch = cancelContentJSEpoch; - this._browser.frameLoader.browsingContext.loadURI(aURI, aLoadURIOptions); + this._sendMessage("WebNavigation:LoadURI", { + uri: aURI, + loadFlags: aLoadURIOptions.loadFlags, + referrerInfo: E10SUtils.serializeReferrerInfo( + aLoadURIOptions.referrerInfo + ), + postData: aLoadURIOptions.postData + ? Utils.serializeInputStream(aLoadURIOptions.postData) + : null, + headers: aLoadURIOptions.headers + ? Utils.serializeInputStream(aLoadURIOptions.headers) + : null, + baseURI: aLoadURIOptions.baseURI ? aLoadURIOptions.baseURI.spec : null, + triggeringPrincipal: E10SUtils.serializePrincipal( + aLoadURIOptions.triggeringPrincipal || + Services.scriptSecurityManager.createNullPrincipal({}) + ), + csp: aLoadURIOptions.csp + ? E10SUtils.serializeCSP(aLoadURIOptions.csp) + : null, + cancelContentJSEpoch, + }); }, setOriginAttributesBeforeLoading(aOriginAttributes) { this._sendMessage("WebNavigation:SetOriginAttributes", { diff --git a/toolkit/components/windowwatcher/nsWindowWatcher.cpp b/toolkit/components/windowwatcher/nsWindowWatcher.cpp index 6053016b29b3..b4878c2381cf 100644 --- a/toolkit/components/windowwatcher/nsWindowWatcher.cpp +++ b/toolkit/components/windowwatcher/nsWindowWatcher.cpp @@ -812,6 +812,14 @@ nsresult nsWindowWatcher::OpenWindowInternal( if (NS_SUCCEEDED(rv) && newBC) { nsCOMPtr newDocShell = newBC->GetDocShell(); + if (windowIsNew && newDocShell) { + // Make sure to stop any loads happening in this window that the + // window provider might have started. Otherwise if our caller + // manipulates the window it just opened and then the load + // completes their stuff will get blown away. + nsCOMPtr webNav = do_QueryInterface(newDocShell); + webNav->Stop(nsIWebNavigation::STOP_NETWORK); + } // If this is a new window, but it's incompatible with the current // userContextId, we ignore it and we pretend that nothing has been diff --git a/toolkit/modules/ActorManagerParent.jsm b/toolkit/modules/ActorManagerParent.jsm index 5d6b8d1e63b0..aedb8f40722d 100644 --- a/toolkit/modules/ActorManagerParent.jsm +++ b/toolkit/modules/ActorManagerParent.jsm @@ -422,6 +422,7 @@ let LEGACY_ACTORS = { "WebNavigation:GoBack", "WebNavigation:GoForward", "WebNavigation:GotoIndex", + "WebNavigation:LoadURI", "WebNavigation:Reload", "WebNavigation:SetOriginAttributes", "WebNavigation:Stop",