mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-08 20:47:44 +00:00
Bug 667864 - Tests more nsHTMLInputElement attributes reflection. r=Ms2ger
--HG-- rename : content/html/content/test/test_bug557628-1.html => content/html/content/test/test_bug557628.html
This commit is contained in:
parent
b03226f205
commit
7248bcbce8
@ -216,8 +216,7 @@ _TEST_FILES = \
|
||||
test_bug555840.html \
|
||||
test_bug561636.html \
|
||||
test_bug590363.html \
|
||||
test_bug557628-1.html \
|
||||
test_bug557628-2.html \
|
||||
test_bug557628.html \
|
||||
test_bug592802.html \
|
||||
test_bug595429.html \
|
||||
test_bug595447.html \
|
||||
|
@ -20,9 +20,72 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=551670
|
||||
|
||||
/** Test for Bug 551670 **/
|
||||
|
||||
// TODO: maybe make those reflections be tested against all input types.
|
||||
|
||||
// .accept
|
||||
reflectString(document.createElement("input"), "accept",
|
||||
[ "audio/*", "video/*", "image/*", "image/png",
|
||||
"application/msword", "appplication/pdf" ]);
|
||||
|
||||
// .alt
|
||||
reflectString(document.createElement("input"), "alt");
|
||||
|
||||
// .autocomplete
|
||||
reflectLimitedEnumerated(document.createElement("input"), "autocomplete",
|
||||
[ "on", "off" ], [ "", "default", "foo", "tulip" ]);
|
||||
|
||||
// TODO: autofocus (boolean)
|
||||
// TODO: defaultChecked (boolean)
|
||||
// TODO: checked (boolean)
|
||||
// TODO: dirName (not implemented)
|
||||
// TODO: disabled (boolean)
|
||||
// TODO: form (HTMLFormElement)
|
||||
// TODO: files (FileList)
|
||||
// TODO: formAction (URL)
|
||||
|
||||
// .formEnctype
|
||||
reflectLimitedEnumerated(document.createElement("input"), "formEnctype",
|
||||
[ "application/x-www-form-urlencoded",
|
||||
"multipart/form-data", "text/plain" ],
|
||||
[ "", "foo", "tulip", "multipart/foo" ],
|
||||
"application/x-www-form-urlencoded");
|
||||
|
||||
// .formMethod
|
||||
reflectLimitedEnumerated(document.createElement("input"), "formMethod",
|
||||
[ "get", "post" ], [ "", "foo", "tulip" ], "get");
|
||||
|
||||
// TODO: formNoValidate (boolean)
|
||||
|
||||
// .formTarget
|
||||
reflectString(document.createElement("input"), "formTarget",
|
||||
[ "_blank", "_self", "_parent", "_top" ]);
|
||||
|
||||
// TODO: height (non-negative integer)
|
||||
// TODO: indeterminate (boolean)
|
||||
// TODO: list (HTMLElement)
|
||||
// TODO: max (not implemented)
|
||||
// TODO: maxLength (long)
|
||||
// TODO: min (not implemented)
|
||||
// TODO: multiple (boolean)
|
||||
|
||||
// .name
|
||||
reflectString(document.createElement("input"), "name",
|
||||
[ "isindex", "_charset_" ]);
|
||||
|
||||
// .pattern
|
||||
reflectString(document.createElement("input"), "pattern",
|
||||
[ "[0-9][A-Z]{3}" ]);
|
||||
|
||||
// .placeholder
|
||||
reflectString(document.createElement("input"), "placeholder",
|
||||
[ "foo\nbar", "foo\rbar", "foo\r\nbar" ]);
|
||||
|
||||
// TODO: readOnly (boolean)
|
||||
// TODO: required (boolean)
|
||||
// TODO: size (unsigned long)
|
||||
// TODO: src (URL)
|
||||
// TODO: step (not implemented)
|
||||
|
||||
// .type
|
||||
reflectLimitedEnumerated(document.createElement("input"),
|
||||
"type",
|
||||
@ -34,6 +97,17 @@ reflectLimitedEnumerated(document.createElement("input"),
|
||||
[ "datetime", "date", "month", "week", "time",
|
||||
"datetime-local", "number", "range", "color" ]);
|
||||
|
||||
// TODO: defaultValue (reflects @value)
|
||||
// .value doesn't reflect a content attribute.
|
||||
// TODO: valueAsDate (not implemented)
|
||||
// TODO: valueAsNumber (not implemented)
|
||||
// TODO: selectedOption (not implemented)
|
||||
// TODO: width (non-negative integer)
|
||||
// .willValidate doesn't reflect a content attribute.
|
||||
// .validity doesn't reflect a content attribute.
|
||||
// .validationMessage doesn't reflect a content attribute.
|
||||
// .labels doesn't reflect a content attribute.
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -33,34 +33,6 @@ function invalidEventHandler(e)
|
||||
gInvalid = true;
|
||||
}
|
||||
|
||||
function checkPatternAttribute(element)
|
||||
{
|
||||
ok('pattern' in element, "Element should have the pattern attribute");
|
||||
|
||||
is(element.pattern, "tulip",
|
||||
"pattern IDL attribute value should be 'tulip'");
|
||||
is(element.getAttribute('pattern'), "tulip",
|
||||
"pattern content attribute value should be 'tulip'");
|
||||
|
||||
element.pattern = "foo";
|
||||
is(element.pattern, "foo",
|
||||
"pattern IDL attribute value should be 'foo'");
|
||||
is(element.getAttribute('pattern'), "foo",
|
||||
"pattern content attribute value should be 'foo'");
|
||||
|
||||
element.removeAttribute('pattern');
|
||||
ok(!element.pattern,
|
||||
"Element pattern attribute shouldn't be specified");
|
||||
is(element.getAttribute('pattern'), null,
|
||||
"Element pattern attribute shouldn't be specified");
|
||||
|
||||
element.setAttribute("pattern", "bar");
|
||||
is(element.pattern, "bar",
|
||||
"pattern IDL attribute value should be 'bar'");
|
||||
is(element.getAttribute('pattern'), "bar",
|
||||
"pattern content attribute value should be 'bar'");
|
||||
}
|
||||
|
||||
function completeValidityCheck(element, alwaysValid, isBarred)
|
||||
{
|
||||
if (element.type == 'file') {
|
||||
@ -286,9 +258,6 @@ function checkPatternValidity(element)
|
||||
|
||||
var input = document.getElementById('i');
|
||||
|
||||
// All input types should have the pattern attribute.
|
||||
checkPatternAttribute(input);
|
||||
|
||||
// |validTypes| are the types which accept @pattern
|
||||
// and |invalidTypes| are the ones which do not accept it.
|
||||
var validTypes = Array('text', 'password', 'search', 'tel', 'email', 'url');
|
||||
|
@ -1,11 +1,14 @@
|
||||
/**
|
||||
* Checks that a given attribute is correctly reflected as a string.
|
||||
*
|
||||
* @param aElement Element node to test
|
||||
* @param aAttr String name of the attribute
|
||||
* @param aElement Element node to test
|
||||
* @param aAttr String name of the attribute
|
||||
* @param aOtherValues Array other values to test in addition of the default ones [optional]
|
||||
*/
|
||||
function reflectString(aElement, aAttr)
|
||||
function reflectString(aElement, aAttr, aOtherValues)
|
||||
{
|
||||
var otherValues = aOtherValues !== undefined ? aOtherValues : [];
|
||||
|
||||
// Tests when the attribute isn't set.
|
||||
is(aElement.getAttribute(aAttr), null,
|
||||
"When not set, the content attribute should be undefined.");
|
||||
@ -57,6 +60,8 @@ function reflectString(aElement, aAttr)
|
||||
"bar" ]
|
||||
];
|
||||
|
||||
otherValues.forEach(function(v) { stringsToTest.push([v, v]) });
|
||||
|
||||
stringsToTest.forEach(function([v, r]) {
|
||||
aElement.setAttribute(aAttr, v);
|
||||
is(aElement[aAttr], r,
|
||||
|
@ -13,8 +13,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=457800
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=457800">Mozilla Bug 457800</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
<input type="text" id="inputtext"/><br/>
|
||||
<input type="password"id="inputpassword"/><br/>
|
||||
<textarea id="textarea"></textarea>
|
||||
</div>
|
||||
<pre id="test">
|
||||
@ -51,8 +49,6 @@ function testPlaceholderForElement(element)
|
||||
is(element.getAttribute('placeholder'), 'place\rholder', "\\r shouldn't be stripped");
|
||||
}
|
||||
|
||||
testPlaceholderForElement(document.getElementById('inputtext'));
|
||||
testPlaceholderForElement(document.getElementById('inputpassword'));
|
||||
testPlaceholderForElement(document.getElementById('textarea'));
|
||||
|
||||
</script>
|
||||
|
@ -1,72 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=557628
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 557628</title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.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=557628">Mozilla Bug 557628</a>
|
||||
<p id="display"></p>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 557628 **/
|
||||
|
||||
var inputAutocompleteTestData = [
|
||||
// Default value.
|
||||
[ "" ],
|
||||
// Valid values.
|
||||
[ "on", "off" ],
|
||||
// Invalid values.
|
||||
[ "", " ", "foo", "default", "foo bar" ]
|
||||
];
|
||||
|
||||
function checkAttribute(element, name, data)
|
||||
{
|
||||
is(element.getAttribute(name), undefined,
|
||||
"By default " + name + " content attribute should be undefined");
|
||||
is(element[name], data[0][0],
|
||||
"By default " + name + " IDL attribute should be equal to " +
|
||||
data[0][0]);
|
||||
|
||||
// Valid values.
|
||||
for (i in data[1]) {
|
||||
element.setAttribute(name, data[1][i]);
|
||||
is(element.getAttribute(name), data[1][i],
|
||||
"getAttribute should return the content attribute");
|
||||
is(element[name], data[1][i], "When getting, " + name + " IDL attribute " +
|
||||
"should be equal to the content attribute if the value is known");
|
||||
}
|
||||
|
||||
// Invalid values.
|
||||
for (i in data[2]) {
|
||||
element.setAttribute(name, data[2][i]);
|
||||
is(element.getAttribute(name), data[2][i],
|
||||
"getAttribute should return the content attribute");
|
||||
is(element[name], data[0][0], "When getting, " + name + " IDL attribute " +
|
||||
"should return the default value if the content attribute value isn't known");
|
||||
}
|
||||
|
||||
// TODO values.
|
||||
for (i in data[3]) {
|
||||
element.setAttribute(name, data[3][i]);
|
||||
is(element.getAttribute(name), data[3][i],
|
||||
"getAttribute should return the content attribute");
|
||||
todo_is(element[name], data[3][i], "When getting, " + name + " IDL attribute " +
|
||||
"should be equal to the content attribute if the value is known");
|
||||
}
|
||||
}
|
||||
|
||||
var input = document.createElement('input');
|
||||
|
||||
checkAttribute(input, 'autocomplete', inputAutocompleteTestData);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -48,13 +48,10 @@ function checkFormTarget(aElement)
|
||||
isFormTargetEquals(aElement, "", true);
|
||||
}
|
||||
|
||||
var input = document.createElement('input');
|
||||
var button = document.createElement('button');
|
||||
|
||||
ok('formTarget' in input, "formTarget is a HTMLInputElement property");
|
||||
ok('formTarget' in button, "formTarget is a HTMLButtonElement property");
|
||||
|
||||
checkFormTarget(input);
|
||||
checkFormTarget(button);
|
||||
|
||||
</script>
|
||||
|
@ -63,13 +63,10 @@ function checkAttribute(form, attrName, idlName, data)
|
||||
}
|
||||
|
||||
var form = document.createElement('form');
|
||||
var input = document.createElement('input');
|
||||
var button = document.createElement('button');
|
||||
|
||||
checkAttribute(form, 'enctype', 'enctype', enctypeTestData);
|
||||
checkAttribute(form, 'method', 'method', methodTestData);
|
||||
checkAttribute(input, 'formenctype', 'formEnctype', enctypeTestData);
|
||||
checkAttribute(input, 'formmethod', 'formMethod', methodTestData);
|
||||
checkAttribute(button, 'formenctype', 'formEnctype', enctypeTestData);
|
||||
checkAttribute(button, 'formmethod', 'formMethod', methodTestData);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user