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