1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
<!DOCTYPE HTML>
<html>
<head>
<title>Test for HTMLButtonElement attributes reflection</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="../reflect.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for HTMLButtonElement attributes reflection */
// .autofocus
reflectBoolean({
element: document.createElement("button"),
attribute: "autofocus",
});
// .disabled
reflectBoolean({
element: document.createElement("button"),
attribute: "disabled",
});
// .formAction
reflectURL({
element: document.createElement("button"),
attribute: "formAction",
});
// .formEnctype
reflectLimitedEnumerated({
element: document.createElement("button"),
attribute: "formEnctype",
validValues: [
"application/x-www-form-urlencoded",
"multipart/form-data",
"text/plain",
],
invalidValues: [ "text/html", "", "tulip" ],
defaultValue: {
invalid: "application/x-www-form-urlencoded",
missing: "",
}
});
// .formMethod
add_task(async function() {
reflectLimitedEnumerated({
element: document.createElement("button"),
attribute: "formMethod",
validValues: [ "get", "post", "dialog"],
invalidValues: [ "put", "", "tulip" ],
defaultValue: {
invalid: "get",
missing: "",
}
});
});
// .formNoValidate
reflectBoolean({
element: document.createElement("button"),
attribute: "formNoValidate",
});
// .formTarget
reflectString({
element: document.createElement("button"),
attribute: "formTarget",
otherValues: [ "_blank", "_self", "_parent", "_top" ],
});
// .name
reflectString({
element: document.createElement("button"),
attribute: "name",
otherValues: [ "isindex", "_charset_" ]
});
// .type
reflectLimitedEnumerated({
element: document.createElement("button"),
attribute: "type",
validValues: [ "submit", "reset", "button" ],
invalidValues: [ "this-is-probably-a-wrong-type", "", "tulip" ],
unsupportedValues: [ "menu" ],
defaultValue: "submit",
});
// .value
reflectString({
element: document.createElement("button"),
attribute: "value",
});
// .willValidate
ok("willValidate" in document.createElement("button"),
"willValidate should be an IDL attribute of the button element");
is(typeof(document.createElement("button").willValidate), "boolean",
"button.willValidate should be a boolean");
// .validity
ok("validity" in document.createElement("button"),
"validity should be an IDL attribute of the button element");
is(typeof(document.createElement("button").validity), "object",
"button.validity should be an object");
ok(document.createElement("button").validity instanceof ValidityState,
"button.validity sohuld be an instance of ValidityState");
// .validationMessage
ok("validationMessage" in document.createElement("button"),
"validationMessage should be an IDL attribute of the button element");
is(typeof(document.createElement("button").validationMessage), "string",
"button.validationMessage should be a string");
// .checkValidity()
ok("checkValidity" in document.createElement("button"),
"checkValidity() should be a method of the button element");
is(typeof(document.createElement("button").checkValidity), "function",
"button.checkValidity should be a function");
// .setCustomValidity()
ok("setCustomValidity" in document.createElement("button"),
"setCustomValidity() should be a method of the button element");
is(typeof(document.createElement("button").setCustomValidity), "function",
"button.setCustomValidity should be a function");
// .labels
ok("labels" in document.createElement("button"),
"button.labels should be an IDL attribute of the button element");
is(typeof(document.createElement("button").labels), "object",
"button.labels should be an object");
ok(document.createElement("button").labels instanceof NodeList,
"button.labels sohuld be an instance of NodeList");
</script>
</pre>
</body>
</html>
|