Backed out changeset 428c9c1eabb8 (bug 1655866) for multiple failures. CLOSED TREE

This commit is contained in:
Razvan Maries
2020-10-09 22:28:00 +03:00
parent 1ca1ae6514
commit 04a59f4eee
7 changed files with 42 additions and 24 deletions

View File

@@ -14,8 +14,6 @@ webidl Node;
#include "nsTArray.h" #include "nsTArray.h"
#include "nsRect.h" #include "nsRect.h"
#include "mozilla/dom/WindowGlobalActorsBinding.h"
class nsIWidget; class nsIWidget;
class nsPresContext; class nsPresContext;
class nsView; class nsView;
@@ -37,7 +35,6 @@ class WindowGlobalChild;
[ptr] native Encoding(const mozilla::Encoding); [ptr] native Encoding(const mozilla::Encoding);
[ptr] native PresShellPtr(mozilla::PresShell); [ptr] native PresShellPtr(mozilla::PresShell);
[ptr] native WindowGlobalChildPtr(mozilla::dom::WindowGlobalChild); [ptr] native WindowGlobalChildPtr(mozilla::dom::WindowGlobalChild);
native PermitUnloadAction(mozilla::dom::PermitUnloadAction);
[scriptable, builtinclass, uuid(2da17016-7851-4a45-a7a8-00b360e01595)] [scriptable, builtinclass, uuid(2da17016-7851-4a45-a7a8-00b360e01595)]
interface nsIContentViewer : nsISupports interface nsIContentViewer : nsISupports
@@ -54,6 +51,23 @@ interface nsIContentViewer : nsISupports
[notxpcom,nostdcall] readonly attribute boolean isStopped; [notxpcom,nostdcall] readonly attribute boolean isStopped;
/**
* aAction is passed to PermitUnload to indicate what action to take
* if a beforeunload handler wants to prompt the user.
*
* ePrompt: Prompt and return the user's choice (default).
* eDontPromptAndDontUnload: Don't prompt and return false (unload not permitted)
* if the document (or its children) asks us to prompt.
* eDontPromptAndUnload: Don't prompt and return true (unload permitted) no matter what.
*
* NOTE: Keep this in sync with PermitUnloadAction in WindowGlobalActors.webidl.
*/
cenum PermitUnloadAction : 8 {
ePrompt = 0,
eDontPromptAndDontUnload = 1,
eDontPromptAndUnload = 2
};
/** /**
* The result of dispatching a "beforeunload" event. If `eAllowNavigation`, * The result of dispatching a "beforeunload" event. If `eAllowNavigation`,
* no "beforeunload" listener requested to prevent the navigation, or its * no "beforeunload" listener requested to prevent the navigation, or its
@@ -66,11 +80,12 @@ interface nsIContentViewer : nsISupports
}; };
/** /**
* Overload PermitUnload method for C++ consumers with no aAction argument. * Overload PermitUnload method for C++ consumers with no aPermitUnloadFlags
* argument.
*/ */
%{C++ %{C++
nsresult PermitUnload(bool* canUnload) { nsresult PermitUnload(bool* canUnload) {
return PermitUnload(mozilla::dom::PermitUnloadAction::Prompt, canUnload); return PermitUnload(ePrompt, canUnload);
} }
%} %}
@@ -79,7 +94,7 @@ interface nsIContentViewer : nsISupports
* the document. * the document.
* The result is returned. * The result is returned.
*/ */
boolean permitUnload([optional] in PermitUnloadAction aAction); boolean permitUnload([optional] in nsIContentViewer_PermitUnloadAction aAction);
/** /**
* Exposes whether we're blocked in a call to permitUnload. * Exposes whether we're blocked in a call to permitUnload.
@@ -325,6 +340,7 @@ interface nsIContentViewer : nsISupports
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
using XPCOMPermitUnloadAction = nsIContentViewer::PermitUnloadAction;
using PermitUnloadResult = nsIContentViewer::PermitUnloadResult; using PermitUnloadResult = nsIContentViewer::PermitUnloadResult;
} // namespace dom } // namespace dom

View File

@@ -24,6 +24,7 @@ interface WindowContext {
readonly attribute boolean hasBeforeUnload; readonly attribute boolean hasBeforeUnload;
}; };
// Keep this in sync with nsIContentViewer::PermitUnloadAction.
enum PermitUnloadAction { enum PermitUnloadAction {
"prompt", "prompt",
"dontUnload", "dontUnload",

View File

@@ -43,11 +43,11 @@ struct ParamTraits<mozilla::dom::PermitUnloadResult>
mozilla::dom::PermitUnloadResult::eRequestBlockNavigation> {}; mozilla::dom::PermitUnloadResult::eRequestBlockNavigation> {};
template <> template <>
struct ParamTraits<mozilla::dom::PermitUnloadAction> struct ParamTraits<mozilla::dom::XPCOMPermitUnloadAction>
: public ContiguousEnumSerializer< : public ContiguousEnumSerializerInclusive<
mozilla::dom::PermitUnloadAction, mozilla::dom::XPCOMPermitUnloadAction,
mozilla::dom::PermitUnloadAction(0), mozilla::dom::XPCOMPermitUnloadAction::ePrompt,
mozilla::dom::PermitUnloadAction::EndGuard_> {}; mozilla::dom::XPCOMPermitUnloadAction::eDontPromptAndUnload> {};
} // namespace IPC } // namespace IPC

View File

@@ -20,7 +20,7 @@ using mozilla::gfx::IntRect from "mozilla/gfx/Rect.h";
using moveonly mozilla::gfx::PaintFragment from "mozilla/gfx/CrossProcessPaint.h"; using moveonly mozilla::gfx::PaintFragment from "mozilla/gfx/CrossProcessPaint.h";
using nscolor from "nsColor.h"; using nscolor from "nsColor.h";
using refcounted class nsDocShellLoadState from "nsDocShellLoadState.h"; using refcounted class nsDocShellLoadState from "nsDocShellLoadState.h";
using mozilla::dom::PermitUnloadAction from "mozilla/dom/DocShellMessageUtils.h"; using mozilla::dom::XPCOMPermitUnloadAction from "mozilla/dom/DocShellMessageUtils.h";
using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h"; using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
using mozilla::layers::LayersId from "mozilla/layers/LayersTypes.h"; using mozilla::layers::LayersId from "mozilla/layers/LayersTypes.h";
using refcounted class nsITransportSecurityInfo from "nsITransportSecurityInfo.h"; using refcounted class nsITransportSecurityInfo from "nsITransportSecurityInfo.h";
@@ -165,7 +165,7 @@ parent:
// values). The sender is responsible for checking documents in its own // values). The sender is responsible for checking documents in its own
// process, and passing true for `aHasInProcessBlocker` if any exist. Windows // process, and passing true for `aHasInProcessBlocker` if any exist. Windows
// hosted outside of the caller process will be checked automatically. // hosted outside of the caller process will be checked automatically.
async CheckPermitUnload(bool aHasInProcessBlocker, PermitUnloadAction aAction) async CheckPermitUnload(bool aHasInProcessBlocker, XPCOMPermitUnloadAction aAction)
returns (bool permitUnload); returns (bool permitUnload);
async Destroy(); async Destroy();

View File

@@ -679,7 +679,7 @@ class CheckPermitUnloadRequest final : public PromiseNativeHandler,
public nsITimerCallback { public nsITimerCallback {
public: public:
CheckPermitUnloadRequest(WindowGlobalParent* aWGP, bool aHasInProcessBlocker, CheckPermitUnloadRequest(WindowGlobalParent* aWGP, bool aHasInProcessBlocker,
PermitUnloadAction aAction, nsIContentViewer::PermitUnloadAction aAction,
std::function<void(bool)>&& aResolver) std::function<void(bool)>&& aResolver)
: mResolver(std::move(aResolver)), : mResolver(std::move(aResolver)),
mWGP(aWGP), mWGP(aWGP),
@@ -765,10 +765,10 @@ class CheckPermitUnloadRequest final : public PromiseNativeHandler,
auto action = mAction; auto action = mAction;
if (StaticPrefs::dom_disable_beforeunload()) { if (StaticPrefs::dom_disable_beforeunload()) {
action = PermitUnloadAction::Unload; action = nsIContentViewer::eDontPromptAndUnload;
} }
if (action != PermitUnloadAction::Prompt) { if (action != nsIContentViewer::ePrompt) {
SendReply(action == PermitUnloadAction::Unload); SendReply(action == nsIContentViewer::eDontPromptAndUnload);
return; return;
} }
@@ -835,7 +835,7 @@ class CheckPermitUnloadRequest final : public PromiseNativeHandler,
uint32_t mPendingRequests = 0; uint32_t mPendingRequests = 0;
PermitUnloadAction mAction; nsIContentViewer::PermitUnloadAction mAction;
State mState = State::UNINITIALIZED; State mState = State::UNINITIALIZED;
@@ -847,7 +847,7 @@ NS_IMPL_ISUPPORTS(CheckPermitUnloadRequest, nsITimerCallback)
} // namespace } // namespace
mozilla::ipc::IPCResult WindowGlobalParent::RecvCheckPermitUnload( mozilla::ipc::IPCResult WindowGlobalParent::RecvCheckPermitUnload(
bool aHasInProcessBlocker, PermitUnloadAction aAction, bool aHasInProcessBlocker, XPCOMPermitUnloadAction aAction,
CheckPermitUnloadResolver&& aResolver) { CheckPermitUnloadResolver&& aResolver) {
if (!IsCurrentGlobal()) { if (!IsCurrentGlobal()) {
aResolver(false); aResolver(false);
@@ -870,7 +870,8 @@ already_AddRefed<Promise> WindowGlobalParent::PermitUnload(
} }
auto request = MakeRefPtr<CheckPermitUnloadRequest>( auto request = MakeRefPtr<CheckPermitUnloadRequest>(
this, /* aHasInProcessBlocker */ false, aAction, this, /* aHasInProcessBlocker */ false,
nsIContentViewer::PermitUnloadAction(aAction),
[promise](bool aAllow) { promise->MaybeResolve(aAllow); }); [promise](bool aAllow) { promise->MaybeResolve(aAllow); });
request->Run(/* aIgnoreProcess */ nullptr, aTimeout); request->Run(/* aIgnoreProcess */ nullptr, aTimeout);

View File

@@ -259,7 +259,7 @@ class WindowGlobalParent final : public WindowContext,
uint32_t aMillis); uint32_t aMillis);
mozilla::ipc::IPCResult RecvCheckPermitUnload( mozilla::ipc::IPCResult RecvCheckPermitUnload(
bool aHasInProcessBlocker, PermitUnloadAction aAction, bool aHasInProcessBlocker, XPCOMPermitUnloadAction aAction,
CheckPermitUnloadResolver&& aResolver); CheckPermitUnloadResolver&& aResolver);
private: private:

View File

@@ -1207,7 +1207,7 @@ nsDocumentViewer::PermitUnload(PermitUnloadAction aAction,
RefPtr<nsDocumentViewer> kungFuDeathGrip(this); RefPtr<nsDocumentViewer> kungFuDeathGrip(this);
if (StaticPrefs::dom_disable_beforeunload()) { if (StaticPrefs::dom_disable_beforeunload()) {
aAction = PermitUnloadAction::Unload; aAction = eDontPromptAndUnload;
} }
*aPermitUnload = true; *aPermitUnload = true;
@@ -1245,8 +1245,8 @@ nsDocumentViewer::PermitUnload(PermitUnloadAction aAction,
if (!foundBlocker) { if (!foundBlocker) {
return NS_OK; return NS_OK;
} }
if (aAction != PermitUnloadAction::Prompt) { if (aAction != ePrompt) {
*aPermitUnload = aAction == PermitUnloadAction::Unload; *aPermitUnload = aAction == eDontPromptAndUnload;
return NS_OK; return NS_OK;
} }
} }