mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 942321 - Changing a select option field via javascript updates validity state. r=bz
This commit is contained in:
parent
a4da8b744e
commit
8855692a5d
@ -243,6 +243,25 @@ HTMLOptionElement::BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
HTMLOptionElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||||
|
const nsAttrValue* aValue, bool aNotify)
|
||||||
|
{
|
||||||
|
if (aNameSpaceID == kNameSpaceID_None &&
|
||||||
|
aName == nsGkAtoms::value && Selected()) {
|
||||||
|
// Since this option is selected, changing value
|
||||||
|
// may have changed missing validity state of the
|
||||||
|
// Select element
|
||||||
|
HTMLSelectElement* select = GetSelect();
|
||||||
|
if (select) {
|
||||||
|
select->UpdateValueMissingValidityState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName,
|
||||||
|
aValue, aNotify);
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
HTMLOptionElement::GetText(nsAString& aText)
|
HTMLOptionElement::GetText(nsAString& aText)
|
||||||
{
|
{
|
||||||
|
@ -51,6 +51,8 @@ public:
|
|||||||
virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||||
const nsAttrValueOrString* aValue,
|
const nsAttrValueOrString* aValue,
|
||||||
bool aNotify) MOZ_OVERRIDE;
|
bool aNotify) MOZ_OVERRIDE;
|
||||||
|
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||||
|
const nsAttrValue* aValue, bool aNotify) MOZ_OVERRIDE;
|
||||||
|
|
||||||
void SetSelectedInternal(bool aValue, bool aNotify);
|
void SetSelectedInternal(bool aValue, bool aNotify);
|
||||||
|
|
||||||
|
@ -395,6 +395,7 @@ public:
|
|||||||
nsresult GetValidationMessage(nsAString& aValidationMessage,
|
nsresult GetValidationMessage(nsAString& aValidationMessage,
|
||||||
ValidityStateType aType) MOZ_OVERRIDE;
|
ValidityStateType aType) MOZ_OVERRIDE;
|
||||||
|
|
||||||
|
void UpdateValueMissingValidityState();
|
||||||
/**
|
/**
|
||||||
* Insert aElement before the node given by aBefore
|
* Insert aElement before the node given by aBefore
|
||||||
*/
|
*/
|
||||||
@ -511,7 +512,6 @@ protected:
|
|||||||
// nsIConstraintValidation
|
// nsIConstraintValidation
|
||||||
void UpdateBarredFromConstraintValidation();
|
void UpdateBarredFromConstraintValidation();
|
||||||
bool IsValueMissing();
|
bool IsValueMissing();
|
||||||
void UpdateValueMissingValidityState();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find out how deep this content is from the select (1=direct child)
|
* Find out how deep this content is from the select (1=direct child)
|
||||||
|
@ -74,6 +74,7 @@ skip-if = e10s
|
|||||||
[test_restore_form_elements.html]
|
[test_restore_form_elements.html]
|
||||||
[test_save_restore_radio_groups.html]
|
[test_save_restore_radio_groups.html]
|
||||||
[test_select_selectedOptions.html]
|
[test_select_selectedOptions.html]
|
||||||
|
[test_select_validation.html]
|
||||||
[test_set_range_text.html]
|
[test_set_range_text.html]
|
||||||
[test_step_attribute.html]
|
[test_step_attribute.html]
|
||||||
skip-if = e10s
|
skip-if = e10s
|
||||||
|
39
content/html/content/test/forms/test_select_validation.html
Normal file
39
content/html/content/test/forms/test_select_validation.html
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=942321
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<title>Test for Bug 942321</title>
|
||||||
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=942321">Mozilla Bug 942321</a>
|
||||||
|
<p id="display"></p>
|
||||||
|
<form id="form" href="">
|
||||||
|
<select required id="testselect">
|
||||||
|
<option id="placeholder" value="" selected>placeholder</option>
|
||||||
|
<option value="test" id="actualvalue">test</option>
|
||||||
|
<select>
|
||||||
|
<input type="submit" />
|
||||||
|
</form>
|
||||||
|
<script class="testbody" type="text/javascript">
|
||||||
|
/** Test for Bug 942321 **/
|
||||||
|
var option = document.getElementById("actualvalue");
|
||||||
|
option.selected = true;
|
||||||
|
is(form.checkValidity(), true, "Select is required and should be valid");
|
||||||
|
|
||||||
|
var placeholder = document.getElementById("placeholder");
|
||||||
|
placeholder.selected = true;
|
||||||
|
is(form.checkValidity(), false, "Select is required and should be invalid");
|
||||||
|
|
||||||
|
placeholder.value = "not-invalid-anymore";
|
||||||
|
is(form.checkValidity(), true, "Select is required and should be valid when option's value is changed by javascript");
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user