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
Родитель ea34810caa
Коммит 5dcad9e9b5
7 изменённых файлов: 42 добавлений и 24 удалений

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

@ -14,8 +14,6 @@ webidl Node;
#include "nsTArray.h"
#include "nsRect.h"
#include "mozilla/dom/WindowGlobalActorsBinding.h"
class nsIWidget;
class nsPresContext;
class nsView;
@ -37,7 +35,6 @@ class WindowGlobalChild;
[ptr] native Encoding(const mozilla::Encoding);
[ptr] native PresShellPtr(mozilla::PresShell);
[ptr] native WindowGlobalChildPtr(mozilla::dom::WindowGlobalChild);
native PermitUnloadAction(mozilla::dom::PermitUnloadAction);
[scriptable, builtinclass, uuid(2da17016-7851-4a45-a7a8-00b360e01595)]
interface nsIContentViewer : nsISupports
@ -54,6 +51,23 @@ interface nsIContentViewer : nsISupports
[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`,
* 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++
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 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.
@ -325,6 +340,7 @@ interface nsIContentViewer : nsISupports
namespace mozilla {
namespace dom {
using XPCOMPermitUnloadAction = nsIContentViewer::PermitUnloadAction;
using PermitUnloadResult = nsIContentViewer::PermitUnloadResult;
} // namespace dom

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

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

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

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

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

@ -20,7 +20,7 @@ using mozilla::gfx::IntRect from "mozilla/gfx/Rect.h";
using moveonly mozilla::gfx::PaintFragment from "mozilla/gfx/CrossProcessPaint.h";
using nscolor from "nsColor.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::layers::LayersId from "mozilla/layers/LayersTypes.h";
using refcounted class nsITransportSecurityInfo from "nsITransportSecurityInfo.h";
@ -165,7 +165,7 @@ parent:
// values). The sender is responsible for checking documents in its own
// process, and passing true for `aHasInProcessBlocker` if any exist. Windows
// 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);
async Destroy();

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

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

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

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

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

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