Bug 1678389 - Use transient user activation for <input> file/color picker. r=edgar
This matches other browsers, see [1], and should fix this and other similar bugs like bug 1610726. [1]: https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/html/forms/file_input_type.cc;l=163;drc=8a5de62dd01360cfe3d150640d3ff4d974bbe842 Differential Revision: https://phabricator.services.mozilla.com/D97640
This commit is contained in:
@@ -661,19 +661,15 @@ nsColorPickerShownCallback::Done(const nsAString& aColor) {
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsColorPickerShownCallback, nsIColorPickerShownCallback)
|
||||
|
||||
bool HTMLInputElement::IsPopupBlocked() const {
|
||||
nsCOMPtr<nsPIDOMWindowOuter> win = OwnerDoc()->GetWindow();
|
||||
MOZ_ASSERT(win, "window should not be null");
|
||||
if (!win) {
|
||||
return true;
|
||||
static bool IsPopupBlocked(Document* aDoc) {
|
||||
if (aDoc->ConsumeTransientUserGestureActivation()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if page can open a popup without abuse regardless of allowed events
|
||||
if (PopupBlocker::GetPopupControlState() <= PopupBlocker::openBlocked) {
|
||||
return !PopupBlocker::TryUsePopupOpeningToken(OwnerDoc()->NodePrincipal());
|
||||
}
|
||||
|
||||
return !PopupBlocker::CanShowPopupByPermission(OwnerDoc()->NodePrincipal());
|
||||
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "DOM"_ns, aDoc,
|
||||
nsContentUtils::eDOM_PROPERTIES,
|
||||
"InputPickerBlockedNoUserActivation");
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult HTMLInputElement::InitColorPicker() {
|
||||
@@ -689,7 +685,7 @@ nsresult HTMLInputElement::InitColorPicker() {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (IsPopupBlocked()) {
|
||||
if (IsPopupBlocked(doc)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -734,7 +730,7 @@ nsresult HTMLInputElement::InitFilePicker(FilePickerType aType) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (IsPopupBlocked()) {
|
||||
if (IsPopupBlocked(doc)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user