Backed out 2 changesets (bug 1907269) for causing bc failures @ browser_ftp_protocol_handlers.js CLOSED TREE

Backed out changeset 3270496f12d8 (bug 1907269)
Backed out changeset 218c98804a83 (bug 1907269)
This commit is contained in:
Sandor Molnar 2024-07-30 02:16:42 +03:00
Родитель ecff5ce478
Коммит 5ce501ee48
9 изменённых файлов: 22 добавлений и 100 удалений

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

@ -12957,8 +12957,7 @@ nsresult nsDocShell::OnLinkClickSync(nsIContent* aContent,
/* aTriggeredExternally */
false,
/* aHasValidUserGestureActivation */
aContent->OwnerDoc()->HasValidTransientUserGestureActivation(),
/* aNewWindowTarget */ false);
aContent->OwnerDoc()->HasValidTransientUserGestureActivation());
}
}
}

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

@ -4588,8 +4588,7 @@ mozilla::ipc::IPCResult ContentParent::RecvLoadURIExternal(
nsIURI* uri, nsIPrincipal* aTriggeringPrincipal,
nsIPrincipal* aRedirectPrincipal,
const MaybeDiscarded<BrowsingContext>& aContext,
bool aWasExternallyTriggered, bool aHasValidUserGestureActivation,
bool aNewWindowTarget) {
bool aWasExternallyTriggered, bool aHasValidUserGestureActivation) {
if (aContext.IsDiscarded()) {
return IPC_OK();
}
@ -4607,7 +4606,7 @@ mozilla::ipc::IPCResult ContentParent::RecvLoadURIExternal(
BrowsingContext* bc = aContext.get();
extProtService->LoadURI(uri, aTriggeringPrincipal, aRedirectPrincipal, bc,
aWasExternallyTriggered,
aHasValidUserGestureActivation, aNewWindowTarget);
aHasValidUserGestureActivation);
return IPC_OK();
}

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

@ -1003,8 +1003,7 @@ class ContentParent final : public PContentParent,
nsIURI* uri, nsIPrincipal* triggeringPrincipal,
nsIPrincipal* redirectPrincipal,
const MaybeDiscarded<BrowsingContext>& aContext,
bool aWasExternallyTriggered, bool aHasValidUserGestureActivation,
bool aNewWindowTarget);
bool aWasExternallyTriggered, bool aHasValidUserGestureActivation);
mozilla::ipc::IPCResult RecvExtProtocolChannelConnectParent(
const uint64_t& registrarId);

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

@ -1135,8 +1135,7 @@ parent:
nullable nsIPrincipal redirectPrincipal,
MaybeDiscardedBrowsingContext browsingContext,
bool wasExternallyTriggered,
bool hasValidUserGestureActivation,
bool newWindowTarget);
bool hasValidUserGestureActivation);
async ExtProtocolChannelConnectParent(uint64_t registrarId);
sync SyncMessage(nsString aMessage, ClonedMessageData aData)

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

@ -1017,14 +1017,13 @@ nsExternalHelperAppService::LoadURI(nsIURI* aURI,
nsIPrincipal* aRedirectPrincipal,
BrowsingContext* aBrowsingContext,
bool aTriggeredExternally,
bool aHasValidUserGestureActivation,
bool aNewWindowTarget) {
bool aHasValidUserGestureActivation) {
NS_ENSURE_ARG_POINTER(aURI);
if (XRE_IsContentProcess()) {
mozilla::dom::ContentChild::GetSingleton()->SendLoadURIExternal(
aURI, aTriggeringPrincipal, aRedirectPrincipal, aBrowsingContext,
aTriggeredExternally, aHasValidUserGestureActivation, aNewWindowTarget);
aTriggeredExternally, aHasValidUserGestureActivation);
return NS_OK;
}
@ -1101,11 +1100,12 @@ nsExternalHelperAppService::LoadURI(nsIURI* aURI,
WindowGlobalParent* wgp = bc->Canonical()->GetCurrentWindowGlobal();
bool foundAccessibleFrame = false;
// Don't block the load if it is the first load in a new window (e.g. due to
// a call to window.open, or a target=_blank link click).
if (aNewWindowTarget) {
MOZ_ASSERT(bc->IsTop());
foundAccessibleFrame = true;
// Also allow this load if the target is a toplevel BC and contains a
// non-web-controlled about:blank document
if (bc->IsTop() && !bc->GetTopLevelCreatedByWebContent() && wgp) {
RefPtr<nsIURI> uri = wgp->GetDocumentURI();
foundAccessibleFrame =
uri && uri->GetSpecOrDefault().EqualsLiteral("about:blank");
}
while (!foundAccessibleFrame) {

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

@ -88,8 +88,7 @@ class nsExternalHelperAppService : public nsIExternalHelperAppService,
nsIPrincipal* aRedirectPrincipal,
mozilla::dom::BrowsingContext* aBrowsingContext,
bool aWasTriggeredExternally,
bool aHasValidUserGestureActivation,
bool aNewWindowTarget) override;
bool aHasValidUserGestureActivation) override;
NS_IMETHOD SetProtocolHandlerDefaults(nsIHandlerInfo* aHandlerInfo,
bool aOSHandlerExists) override;

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

@ -21,7 +21,6 @@
#include "nsNetUtil.h"
#include "nsContentSecurityManager.h"
#include "nsExternalHelperAppService.h"
#include "nsHashPropertyBag.h"
// used to dispatch urls to default protocol handlers
#include "nsCExternalHandlerService.h"
@ -36,12 +35,11 @@ class nsILoadInfo;
// OpenInputStream to calls in the OS for loading the url.
////////////////////////////////////////////////////////////////////////
class nsExtProtocolChannel : public nsHashPropertyBag,
public nsIChannel,
class nsExtProtocolChannel : public nsIChannel,
public nsIChildChannel,
public nsIParentChannel {
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSICHANNEL
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
@ -75,17 +73,18 @@ class nsExtProtocolChannel : public nsHashPropertyBag,
nsCOMPtr<nsIStreamListener> mListener;
};
NS_IMPL_ADDREF_INHERITED(nsExtProtocolChannel, nsHashPropertyBag)
NS_IMPL_RELEASE_INHERITED(nsExtProtocolChannel, nsHashPropertyBag)
NS_IMPL_ADDREF(nsExtProtocolChannel)
NS_IMPL_RELEASE(nsExtProtocolChannel)
NS_INTERFACE_MAP_BEGIN(nsExtProtocolChannel)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIChannel)
NS_INTERFACE_MAP_ENTRY(nsIChannel)
NS_INTERFACE_MAP_ENTRY(nsIRequest)
NS_INTERFACE_MAP_ENTRY(nsIChildChannel)
NS_INTERFACE_MAP_ENTRY(nsIParentChannel)
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
NS_INTERFACE_MAP_END_INHERITING(nsHashPropertyBag)
NS_INTERFACE_MAP_END
nsExtProtocolChannel::nsExtProtocolChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo)
: mUrl(aURI),
@ -177,13 +176,9 @@ nsresult nsExtProtocolChannel::OpenURL() {
mLoadInfo->RedirectChain().LastElement()->GetPrincipal(
getter_AddRefs(redirectPrincipal));
}
bool newWindowTarget = false;
GetPropertyAsBool(u"docshell.newWindowTarget"_ns, &newWindowTarget);
rv = extProtService->LoadURI(mUrl, triggeringPrincipal, redirectPrincipal,
ctx, mLoadInfo->GetLoadTriggeredFromExternal(),
mLoadInfo->GetHasValidUserGestureActivation(),
newWindowTarget);
mLoadInfo->GetHasValidUserGestureActivation());
if (NS_SUCCEEDED(rv) && mListener) {
mStatus = NS_ERROR_NO_CONTENT;

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

@ -121,10 +121,6 @@ interface nsIExternalProtocolService : nsISupports
* Whether the document that triggered the load had user activation.
* Used for sandbox checks.
*
* @param aNewWindowTarget
* Whether the load is the first load being triggered in a new window
* (e.g. due to a call to window.open or a target=_blank link click).
*
* @note Embedders that do not expose the http protocol should not currently
* use web-based protocol handlers, as handoff won't work correctly
* (bug 394479).
@ -134,8 +130,7 @@ interface nsIExternalProtocolService : nsISupports
[optional] in nsIPrincipal aRedirectPrincipal,
[optional] in BrowsingContext aBrowsingContext,
[optional] in boolean aWasTriggeredExternally,
[optional] in boolean aHasValidUserGestureActivation,
[optional] in boolean aNewWindowTarget);
[optional] in boolean aHasValidUserGestureActivation);
/**
* Gets a human-readable description for the application responsible for

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

@ -465,66 +465,3 @@ add_task(async function iframe_background_tab() {
gBrowser.removeTab(tab);
gBrowser.removeTab(newTab);
});
/**
* Check that when navigating to an external protocol in a noopener pop-up
* window, we show the dialog in the correct tab.
*/
add_task(async function iframe_popup_tab() {
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"https://example.com/"
);
// Wait for the chooser dialog to open in the background tab. It should not
// open in the foreground tab which is unrelated to the external protocol
// navigation.
let dialogWindowPromise = waitForProtocolAppChooserDialog(gBrowser, true);
// Wait for the new tab to appear. The URI in this tab will never change from
// `about:blank` as we're going to just end up opening a dialog, so we can't
// use `waitForNewTab`, as that will wait for the tab to actually load
// something.
let newTabPromise = new Promise(resolve => {
gBrowser.tabContainer.addEventListener(
"TabOpen",
openEvent => resolve(openEvent.target),
{ once: true }
);
});
info("Navigating to external proto in pop-up");
await SpecialPowers.spawn(tab.linkedBrowser, [], async function () {
content.eval(
"window.open('mailto:example@example.com', '_blank', 'noopener');"
);
});
// Wait for the new tab to be opened.
info("Waiting for new tab to appear");
let newTab = await newTabPromise;
// Wait for dialog to open in one of the tabs.
info("Waiting for dialog to appear");
let dialog = await dialogWindowPromise;
is(
gBrowser.getTabDialogBox(newTab.linkedBrowser)._tabDialogManager._topDialog,
dialog,
"Dialog opened in the background tab"
);
is(
dialog._frame.contentDocument.location.href,
CONTENT_HANDLING_URL,
"Opened dialog is appChooser dialog."
);
// Close the dialog:
let dialogClosedPromise = waitForProtocolAppChooserDialog(gBrowser, false);
dialog.close();
await dialogClosedPromise;
gBrowser.removeTab(tab);
gBrowser.removeTab(newTab);
});