diff --git a/accessible/generic/ImageAccessible.cpp b/accessible/generic/ImageAccessible.cpp index 0adf5905e891..2a7a62933d4c 100644 --- a/accessible/generic/ImageAccessible.cpp +++ b/accessible/generic/ImageAccessible.cpp @@ -138,6 +138,7 @@ ImageAccessible::DoAction(uint8_t aIndex) nsCOMPtr tmp; return NS_SUCCEEDED(piWindow->Open(spec, EmptyString(), EmptyString(), + /* aLoadInfo = */ nullptr, getter_AddRefs(tmp))); } diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 863e6a2d8d40..79929706434b 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -8139,9 +8139,10 @@ nsGlobalWindow::Open(const nsAString& aUrl, const nsAString& aName, nsresult nsGlobalWindow::Open(const nsAString& aUrl, const nsAString& aName, - const nsAString& aOptions, nsPIDOMWindowOuter **_retval) + const nsAString& aOptions, nsIDocShellLoadInfo* aLoadInfo, + nsPIDOMWindowOuter **_retval) { - FORWARD_TO_OUTER(Open, (aUrl, aName, aOptions, _retval), + FORWARD_TO_OUTER(Open, (aUrl, aName, aOptions, aLoadInfo, _retval), NS_ERROR_NOT_INITIALIZED); return OpenInternal(aUrl, aName, aOptions, false, // aDialog @@ -8150,6 +8151,7 @@ nsGlobalWindow::Open(const nsAString& aUrl, const nsAString& aName, false, // aDoJSFixups true, // aNavigate nullptr, nullptr, // No args + aLoadInfo, _retval); } @@ -8165,6 +8167,7 @@ nsGlobalWindow::OpenJS(const nsAString& aUrl, const nsAString& aName, true, // aDoJSFixups true, // aNavigate nullptr, nullptr, // No args + nullptr, // aLoadInfo _retval); } @@ -8183,7 +8186,8 @@ nsGlobalWindow::OpenDialog(const nsAString& aUrl, const nsAString& aName, true, // aCalledNoScript false, // aDoJSFixups true, // aNavigate - nullptr, aExtraArgument, // Arguments + nullptr, aExtraArgument, // Arguments + nullptr, // aLoadInfo _retval); } @@ -8202,6 +8206,7 @@ nsGlobalWindow::OpenNoNavigate(const nsAString& aUrl, false, // aDoJSFixups false, // aNavigate nullptr, nullptr, // No args + nullptr, // aLoadInfo _retval); } @@ -8230,6 +8235,7 @@ nsGlobalWindow::OpenDialogOuter(JSContext* aCx, const nsAString& aUrl, false, // aDoJSFixups true, // aNavigate argvArray, nullptr, // Arguments + nullptr, // aLoadInfo getter_AddRefs(dialog)); return dialog.forget(); } @@ -9314,6 +9320,7 @@ nsGlobalWindow::ShowModalDialogOuter(const nsAString& aUrl, true, // aDoJSFixups true, // aNavigate nullptr, argHolder, // args + nullptr, // aLoadInfo getter_AddRefs(dlgWin)); nsContentUtils::SetMicroTaskLevel(oldMicroTaskLevel); LeaveModalState(); @@ -11793,6 +11800,7 @@ nsGlobalWindow::OpenInternal(const nsAString& aUrl, const nsAString& aName, bool aDoJSFixups, bool aNavigate, nsIArray *argv, nsISupports *aExtraArgument, + nsIDocShellLoadInfo* aLoadInfo, nsPIDOMWindowOuter **aReturn) { MOZ_ASSERT(IsOuterWindow()); @@ -11936,6 +11944,7 @@ nsGlobalWindow::OpenInternal(const nsAString& aUrl, const nsAString& aName, aDialog, aNavigate, argv, isPopupSpamWindow, forceNoOpener, + aLoadInfo, getter_AddRefs(domReturn)); } else { // Force a system caller here so that the window watcher won't screw us @@ -11957,6 +11966,7 @@ nsGlobalWindow::OpenInternal(const nsAString& aUrl, const nsAString& aName, aDialog, aNavigate, aExtraArgument, isPopupSpamWindow, forceNoOpener, + aLoadInfo, getter_AddRefs(domReturn)); } diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 20da6df0ebb7..f812d69c9d7e 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -953,6 +953,7 @@ public: mozilla::ErrorResult& aError); nsresult Open(const nsAString& aUrl, const nsAString& aName, const nsAString& aOptions, + nsIDocShellLoadInfo* aLoadInfo, nsPIDOMWindowOuter **_retval) override; mozilla::dom::Navigator* GetNavigator(mozilla::ErrorResult& aError); nsIDOMNavigator* GetNavigator() override; @@ -1466,10 +1467,10 @@ private: * three args, if present, will be aUrl, aName, and aOptions. So this * param only matters if there are more than 3 arguments. * - * @param argc The number of arguments in argv. - * * @param aExtraArgument Another way to pass arguments in. This is mutually - * exclusive with the argv/argc approach. + * exclusive with the argv approach. + * + * @param aLoadInfo to be passed on along to the windowwatcher. * * @param aReturn [out] The window that was opened, if any. * @@ -1485,6 +1486,7 @@ private: bool aNavigate, nsIArray *argv, nsISupports *aExtraArgument, + nsIDocShellLoadInfo* aLoadInfo, nsPIDOMWindowOuter **aReturn); public: diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h index 5f7e2c039448..5850005838f4 100644 --- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -26,6 +26,7 @@ class nsIArray; class nsIContent; class nsICSSDeclaration; class nsIDocShell; +class nsIDocShellLoadInfo; class nsIDocument; class nsIIdleObserver; class nsIPrincipal; @@ -549,8 +550,10 @@ public: virtual already_AddRefed GetSelection() = 0; virtual already_AddRefed GetOpener() = 0; virtual already_AddRefed GetFrames() = 0; + // aLoadInfo will be passed on through to the windowwatcher. virtual nsresult Open(const nsAString& aUrl, const nsAString& aName, const nsAString& aOptions, + nsIDocShellLoadInfo* aLoadInfo, nsPIDOMWindowOuter **_retval) = 0; virtual nsresult OpenDialog(const nsAString& aUrl, const nsAString& aName, const nsAString& aOptions, diff --git a/dom/workers/ServiceWorkerClients.cpp b/dom/workers/ServiceWorkerClients.cpp index 8c493ac81611..a30f15235676 100644 --- a/dom/workers/ServiceWorkerClients.cpp +++ b/dom/workers/ServiceWorkerClients.cpp @@ -613,6 +613,7 @@ private: // opener anyway, and we _do_ want the returned // window. /* aForceNoOpener = */ false, + /* aLoadInfp = */ nullptr, getter_AddRefs(newWindow)); nsCOMPtr pwindow = nsPIDOMWindowOuter::From(newWindow); pwindow.forget(aWindow); diff --git a/embedding/components/windowwatcher/nsPIWindowWatcher.idl b/embedding/components/windowwatcher/nsPIWindowWatcher.idl index 495559f02271..8ea5cf77e0ac 100644 --- a/embedding/components/windowwatcher/nsPIWindowWatcher.idl +++ b/embedding/components/windowwatcher/nsPIWindowWatcher.idl @@ -17,6 +17,7 @@ interface nsIWebBrowserChrome; interface nsIDocShellTreeItem; interface nsIArray; interface nsITabParent; +interface nsIDocShellLoadInfo; [uuid(d162f9c4-19d5-4723-931f-f1e51bfa9f68)] @@ -61,6 +62,11 @@ interface nsPIWindowWatcher : nsISupports looking for existing windows with the given name, not setting an opener on the newly opened window, and returning null from this method. + @param aLoadInfo if aNavigate is true, this allows the caller to pass in + an nsIDocShellLoadInfo to use for the navigation. + Callers can pass in null if they want the windowwatcher + to just construct a loadinfo itself. If aNavigate is + false, this argument is ignored. @return the new window @@ -79,7 +85,8 @@ interface nsPIWindowWatcher : nsISupports in boolean aNavigate, in nsISupports aArgs, in boolean aIsPopupSpam, - in boolean aForceNoOpener); + in boolean aForceNoOpener, + in nsIDocShellLoadInfo aLoadInfo); /** * Opens a new window using the most recent non-private browser diff --git a/embedding/components/windowwatcher/nsWindowWatcher.cpp b/embedding/components/windowwatcher/nsWindowWatcher.cpp index aeac76adc7a2..e28645bd6cdb 100644 --- a/embedding/components/windowwatcher/nsWindowWatcher.cpp +++ b/embedding/components/windowwatcher/nsWindowWatcher.cpp @@ -375,6 +375,7 @@ nsWindowWatcher::OpenWindow(mozIDOMWindowProxy* aParent, /* navigate = */ true, argv, /* aIsPopupSpam = */ false, /* aForceNoOpener = */ false, + /* aLoadInfo = */ nullptr, aResult); } @@ -440,6 +441,7 @@ nsWindowWatcher::OpenWindow2(mozIDOMWindowProxy* aParent, nsISupports* aArguments, bool aIsPopupSpam, bool aForceNoOpener, + nsIDocShellLoadInfo* aLoadInfo, mozIDOMWindowProxy** aResult) { nsCOMPtr argv = ConvertArgsToArray(aArguments); @@ -460,7 +462,7 @@ nsWindowWatcher::OpenWindow2(mozIDOMWindowProxy* aParent, return OpenWindowInternal(aParent, aUrl, aName, aFeatures, aCalledFromScript, dialog, aNavigate, argv, aIsPopupSpam, - aForceNoOpener, aResult); + aForceNoOpener, aLoadInfo, aResult); } // This static function checks if the aDocShell uses an UserContextId equal to @@ -698,6 +700,7 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent, nsIArray* aArgv, bool aIsPopupSpam, bool aForceNoOpener, + nsIDocShellLoadInfo* aLoadInfo, mozIDOMWindowProxy** aResult) { nsresult rv = NS_OK; @@ -1197,8 +1200,8 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent, } } - nsCOMPtr loadInfo; - if (uriToLoad && aNavigate) { + nsCOMPtr loadInfo = aLoadInfo; + if (uriToLoad && aNavigate && !loadInfo) { newDocShell->CreateLoadInfo(getter_AddRefs(loadInfo)); NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE); diff --git a/embedding/components/windowwatcher/nsWindowWatcher.h b/embedding/components/windowwatcher/nsWindowWatcher.h index 3bcca5ca9fae..de79f2c09485 100644 --- a/embedding/components/windowwatcher/nsWindowWatcher.h +++ b/embedding/components/windowwatcher/nsWindowWatcher.h @@ -88,6 +88,7 @@ protected: nsIArray* aArgv, bool aIsPopupSpam, bool aForceNoOpener, + nsIDocShellLoadInfo* aLoadInfo, mozIDOMWindowProxy** aResult); static nsresult URIfromURL(const char* aURL,