Backed out changeset 46970b1c1903 (bug 1877969) for causing xpcshell failures in test_bug1086684.js CLOSED TREE

This commit is contained in:
Cristian Tuns
2024-06-21 11:48:23 -04:00
parent ecab83f214
commit 1613f5053a
19 changed files with 102 additions and 74 deletions

View File

@@ -683,11 +683,16 @@ nsColorPickerShownCallback::Done(const nsAString& aColor) {
NS_IMPL_ISUPPORTS(nsColorPickerShownCallback, nsIColorPickerShownCallback)
static bool IsPickerBlocked(Document* aDoc) {
static bool IsPopupBlocked(Document* aDoc) {
if (aDoc->ConsumeTransientUserGestureActivation()) {
return false;
}
WindowContext* wc = aDoc->GetWindowContext();
if (wc && wc->CanShowPopup()) {
return false;
}
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "DOM"_ns, aDoc,
nsContentUtils::eDOM_PROPERTIES,
"InputPickerBlockedNoUserActivation");
@@ -736,7 +741,7 @@ nsresult HTMLInputElement::InitColorPicker() {
return NS_ERROR_FAILURE;
}
if (IsPickerBlocked(doc)) {
if (IsPopupBlocked(doc)) {
return NS_OK;
}
@@ -784,7 +789,7 @@ nsresult HTMLInputElement::InitFilePicker(FilePickerType aType) {
return NS_ERROR_FAILURE;
}
if (IsPickerBlocked(doc)) {
if (IsPopupBlocked(doc)) {
return NS_OK;
}
@@ -3591,7 +3596,7 @@ nsresult HTMLInputElement::MaybeInitPickers(EventChainPostVisitor& aVisitor) {
// open a color picker when we receive a click on a <input type='color'>.
// A click is handled if it's the left mouse button.
// We do not prevent non-trusted click because authors can already use
// .click(). However, the pickers will check and consume user activation.
// .click(). However, the pickers will follow the rules of popup-blocking.
WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent();
if (!(mouseEvent && mouseEvent->IsLeftClickEvent())) {
return NS_OK;
@@ -5859,11 +5864,7 @@ void HTMLInputElement::ShowPicker(ErrorResult& aRv) {
// Step 2. If element is not mutable, then return.
// (See above.)
// Step 3. Consume user activation given element's relevant global object.
// InitFilePicker() and InitColorPicker() consume it themselves,
// so only consume in this function if not those.
// Step 4. If element's type attribute is in the File Upload state, then run
// Step 3. If element's type attribute is in the File Upload state, then run
// these steps in parallel:
if (mType == FormControlType::InputFile) {
FilePickerType type = FILE_PICKER_FILE;
@@ -5875,7 +5876,7 @@ void HTMLInputElement::ShowPicker(ErrorResult& aRv) {
return;
}
// Step 5. Otherwise, the user agent should show any relevant user interface
// Step 4. Otherwise, the user agent should show any relevant user interface
// for selecting a value for element, in the way it normally would when the
// user interacts with the control
if (mType == FormControlType::InputColor) {
@@ -5883,9 +5884,6 @@ void HTMLInputElement::ShowPicker(ErrorResult& aRv) {
return;
}
// See Step 3.
OwnerDoc()->ConsumeTransientUserGestureActivation();
if (!IsInComposedDoc()) {
return;
}