зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1517368
- Expose PopupBlocker status via ChromeUtils, r=smaug
This commit is contained in:
Родитель
aa8cddddd7
Коммит
ab2574b4d1
|
@ -770,5 +770,34 @@ constexpr auto kSkipSelfHosted = JS::SavedFrameSelfHosted::Exclude;
|
|||
NS_ConvertUTF16toUTF8(aOrigin));
|
||||
}
|
||||
|
||||
/* static */ PopupBlockerState ChromeUtils::GetPopupControlState(
|
||||
GlobalObject& aGlobal) {
|
||||
switch (PopupBlocker::GetPopupControlState()) {
|
||||
case PopupBlocker::PopupControlState::openAllowed:
|
||||
return PopupBlockerState::OpenAllowed;
|
||||
|
||||
case PopupBlocker::PopupControlState::openControlled:
|
||||
return PopupBlockerState::OpenControlled;
|
||||
|
||||
case PopupBlocker::PopupControlState::openBlocked:
|
||||
return PopupBlockerState::OpenBlocked;
|
||||
|
||||
case PopupBlocker::PopupControlState::openAbused:
|
||||
return PopupBlockerState::OpenAbused;
|
||||
|
||||
case PopupBlocker::PopupControlState::openOverridden:
|
||||
return PopupBlockerState::OpenOverridden;
|
||||
|
||||
default:
|
||||
MOZ_CRASH(
|
||||
"PopupBlocker::PopupControlState and PopupBlockerState are out of "
|
||||
"sync");
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ bool ChromeUtils::IsPopupTokenUnused(GlobalObject& aGlobal) {
|
||||
return PopupBlocker::IsPopupOpeningTokenUnused();
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -172,6 +172,10 @@ class ChromeUtils {
|
|||
static bool HasReportingHeaderForOrigin(GlobalObject& global,
|
||||
const nsAString& aOrigin,
|
||||
ErrorResult& aRv);
|
||||
|
||||
static PopupBlockerState GetPopupControlState(GlobalObject& aGlobal);
|
||||
|
||||
static bool IsPopupTokenUnused(GlobalObject& aGlobal);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -141,6 +141,10 @@ PopupBlocker::GetPopupControlState() {
|
|||
return false;
|
||||
}
|
||||
|
||||
/* static */ bool PopupBlocker::IsPopupOpeningTokenUnused() {
|
||||
return sUnusedPopupToken;
|
||||
}
|
||||
|
||||
/* static */ void PopupBlocker::PopupStatePusherCreated() {
|
||||
++sPopupStatePusherCount;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ class PopupBlocker final {
|
|||
// permissive to least permissive so that it's safe to push state in
|
||||
// all situations. Pushing popup state onto the stack never makes the
|
||||
// current popup state less permissive.
|
||||
// Keep this in sync with PopupBlockerState webidl dictionary!
|
||||
enum PopupControlState {
|
||||
openAllowed = 0, // open that window without worries
|
||||
openControlled, // it's a popup, but allow it
|
||||
|
@ -47,6 +48,8 @@ class PopupBlocker final {
|
|||
// allowed per event.
|
||||
static bool TryUsePopupOpeningToken();
|
||||
|
||||
static bool IsPopupOpeningTokenUnused();
|
||||
|
||||
static PopupBlocker::PopupControlState GetEventPopupControlState(
|
||||
WidgetEvent* aEvent, Event* aDOMEvent = nullptr);
|
||||
|
||||
|
|
|
@ -379,6 +379,12 @@ partial namespace ChromeUtils {
|
|||
|
||||
[ChromeOnly, Throws]
|
||||
boolean hasReportingHeaderForOrigin(DOMString aOrigin);
|
||||
|
||||
[ChromeOnly]
|
||||
PopupBlockerState getPopupControlState();
|
||||
|
||||
[ChromeOnly]
|
||||
boolean isPopupTokenUnused();
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -537,3 +543,12 @@ dictionary Base64URLDecodeOptions {
|
|||
/** Specifies the padding mode for decoding the input. */
|
||||
required Base64URLDecodePadding padding;
|
||||
};
|
||||
|
||||
// Keep this in sync with PopupBlocker::PopupControlState!
|
||||
enum PopupBlockerState {
|
||||
"openAllowed",
|
||||
"openControlled",
|
||||
"openBlocked",
|
||||
"openAbused",
|
||||
"openOverridden",
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче