diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp
index 4b17b5a74ce5..f828a5cf43f8 100644
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -3116,11 +3116,6 @@ void HTMLInputElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
if (textControlFrame) textControlFrame->EnsureEditorInitialized();
}
- // FIXME Allow submission etc. also when there is no prescontext, Bug 329509.
- if (!aVisitor.mPresContext) {
- nsGenericHTMLFormElementWithState::GetEventTargetParent(aVisitor);
- return;
- }
//
// Web pages expect the value of a radio button or checkbox to be set
// *before* onclick and DOMActivate fire, and they expect that if they set
@@ -3316,9 +3311,6 @@ void HTMLInputElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
}
nsresult HTMLInputElement::PreHandleEvent(EventChainVisitor& aVisitor) {
- if (!aVisitor.mPresContext) {
- return nsGenericHTMLFormElementWithState::PreHandleEvent(aVisitor);
- }
nsresult rv;
if (aVisitor.mItemFlags & NS_PRE_HANDLE_BLUR_EVENT) {
MOZ_ASSERT(aVisitor.mEvent->mMessage == eBlur);
@@ -3594,12 +3586,6 @@ static bool IgnoreInputEventWithModifier(WidgetInputEvent* aEvent,
}
nsresult HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
- if (!aVisitor.mPresContext) {
- // Hack alert! In order to open file picker even in case the element isn't
- // in document, try to init picker even without PresContext.
- return MaybeInitPickers(aVisitor);
- }
-
if (aVisitor.mEvent->mMessage == eFocus ||
aVisitor.mEvent->mMessage == eBlur) {
if (aVisitor.mEvent->mMessage == eBlur) {
@@ -3638,7 +3624,9 @@ nsresult HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
InternalUIEvent actEvent(true, eLegacyDOMActivate, mouseEvent);
actEvent.mDetail = 1;
- if (RefPtr presShell = aVisitor.mPresContext->GetPresShell()) {
+ if (RefPtr presShell =
+ aVisitor.mPresContext ? aVisitor.mPresContext->GetPresShell()
+ : nullptr) {
nsEventStatus status = nsEventStatus_eIgnore;
mInInternalActivate = true;
rv = presShell->HandleDOMEventWithTarget(this, &actEvent, &status);
@@ -3782,7 +3770,8 @@ nsresult HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
case NS_FORM_INPUT_CHECKBOX:
case NS_FORM_INPUT_RADIO: {
// Checkbox and Radio try to submit on Enter press
- if (keyEvent->mKeyCode != NS_VK_SPACE) {
+ if (keyEvent->mKeyCode != NS_VK_SPACE &&
+ aVisitor.mPresContext) {
MaybeSubmitForm(MOZ_KnownLive(aVisitor.mPresContext));
break; // If we are submitting, do not send click event
@@ -3861,8 +3850,10 @@ nsresult HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
mType == NS_FORM_INPUT_NUMBER ||
IsExperimentalMobileType(mType) || IsDateTimeInputType(mType))) {
FireChangeEventIfNeeded();
- rv = MaybeSubmitForm(MOZ_KnownLive(aVisitor.mPresContext));
- NS_ENSURE_SUCCESS(rv, rv);
+ if (aVisitor.mPresContext) {
+ rv = MaybeSubmitForm(MOZ_KnownLive(aVisitor.mPresContext));
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
}
if (aVisitor.mEvent->mMessage == eKeyPress &&
diff --git a/testing/web-platform/meta/dom/events/Event-dispatch-click.html.ini b/testing/web-platform/meta/dom/events/Event-dispatch-click.html.ini
index dfec0afafc10..2c8175d2cb97 100644
--- a/testing/web-platform/meta/dom/events/Event-dispatch-click.html.ini
+++ b/testing/web-platform/meta/dom/events/Event-dispatch-click.html.ini
@@ -14,9 +14,3 @@
[disabled checkbox still has activation behavior, part 2]
expected: FAIL
- [disconnected checkbox should be checked]
- expected: FAIL
-
- [disconnected radio should be checked]
- expected: FAIL
-
diff --git a/testing/web-platform/meta/html/semantics/forms/the-input-element/checkbox-click-events.html.ini b/testing/web-platform/meta/html/semantics/forms/the-input-element/checkbox-click-events.html.ini
deleted file mode 100644
index 5513667fa2b6..000000000000
--- a/testing/web-platform/meta/html/semantics/forms/the-input-element/checkbox-click-events.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[checkbox-click-events.html]
- [clicking and preventDefaulting a checkbox causes the checkbox to be checked during the click handler but reverted]
- expected: FAIL
-