tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

form-validation-willValidate.html (5383B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>The constraint validation API Test: element.willValidate</title>
      4 <link rel="author" title="Intel" href="http://www.intel.com/">
      5 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-cva-willvalidate">
      6 <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-constraint-validation-api">
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 <script src="support/validator.js"></script>
     10 <div id="log"></div>
     11 <script>
     12  var testElements = [
     13    //input in hidden, button and reset status must be barred from the constraint validation
     14    {
     15      tag: "input",
     16      types: ["hidden", "button", "reset"],
     17      testData: [{conditions: {}, expected: false, name: "[target] Must be barred from the constraint validation"}]
     18    },
     19    //button in button and reset status must be barred from the constraint validation
     20    {
     21      tag: "button",
     22      types: ["button", "reset"],
     23      testData: [{conditions: {}, expected: false, name: "[target] Must be barred from the constraint validation"}]
     24    },
     25    // FIELDSET and OUTPUT elements are not "submittable elements" and therefore never validate.
     26    {
     27      tag: "fieldset",
     28      types: [],
     29      testData: [{conditions: {}, expected: false, name: "[target] The willValidate attribute must be false since FIELDSET is not a submittable element"}]
     30    },
     31    {
     32      tag: "output",
     33      types: [],
     34      testData: [{conditions: {}, expected: false, name: "[target] The willValidate attribute must be false since OUTPUT is not a submittable element"}]
     35    },
     36    //OBJECT, KEYGEN, elements must be barred from the constraint validation
     37    {
     38      tag: "object",
     39      types: [],
     40      testData: [{conditions: {}, expected: false, name: "[target] Must be barred from the constraint validation"}]
     41    },
     42    //If an element is disabled, it is barred from constraint validation.
     43    //The willValidate attribute must be true if an element is mutable
     44    //If the readonly attribute is specified on an INPUT element, the element is barred from constraint validation.
     45    {
     46      tag: "input",
     47      types: ["text", "search", "tel", "url", "email", "password", "datetime-local", "date", "month", "week", "time"],
     48      testData: [
     49        {conditions: {disabled: true}, expected: false, name: "[target] Must be barred from the constraint validation if it is disabled"},
     50        {conditions: {disabled: false, readOnly: false}, expected: true, name: "[target] The willValidate attribute must be true if an element is mutable"},
     51        {conditions: {readOnly: true}, expected: false, name: "[target] Must be barred from the constraint validation if it is readonly"},
     52        {conditions: {disabled: false, readOnly: false}, expected: false, name: "[target] The willValidate attribute must be false if it has a datalist ancestor", ancestor: "datalist"},
     53      ]
     54    },
     55    //In the following cases, the readonly attribute does not apply, however we should still bar the element from constraint validation.
     56    {
     57      tag: "input",
     58      types: ["color", "file", "submit"],
     59      testData: [
     60        {conditions: {disabled: true}, expected: false, name: "[target] Must be barred from the constraint validation if it is disabled"},
     61        {conditions: {disabled: false, readOnly: false}, expected: true, name: "[target] The willValidate attribute must be true if an element is mutable"},
     62        {conditions: {readOnly: true}, expected: false, name: "[target] Must be barred from the constraint validation if it is readonly"},
     63        {conditions: {disabled: false, readOnly: false}, expected: false, name: "[target] The willValidate attribute must be false if it has a datalist ancestor", ancestor: "datalist"},
     64      ]
     65    },
     66    {
     67      tag: "button",
     68      types: ["submit"],
     69      testData: [
     70        {conditions: {disabled: true}, expected: false, name: "[target] Must be barred from the constraint validation"},
     71        {conditions: {disabled: false}, expected: true, name: "[target] The willValidate attribute must be true if an element is mutable"},
     72        {conditions: {disabled: false}, expected: false, name: "[target] The willValidate attribute must be false if it has a datalist ancestor", ancestor: "datalist"}
     73      ]
     74    },
     75    {
     76      tag: "select",
     77      types: [],
     78      testData: [
     79        {conditions: {disabled: true}, expected: false, name: "[target] Must be barred from the constraint validation"},
     80        {conditions: {disabled: false}, expected: true, name: "[target] The willValidate attribute must be true if an element is mutable"},
     81        {conditions: {disabled: false}, expected: false, name: "[target] The willValidate attribute must be false if it has a datalist ancestor", ancestor: "datalist"}
     82      ]
     83    },
     84    {
     85      tag: "textarea",
     86      types: [],
     87      testData: [,
     88        {conditions: {disabled: true}, expected: false, name: "[target] Must be barred from the constraint validation"},
     89        {conditions: {disabled: false}, expected: true, name: "[target] The willValidate attribute must be true if an element is mutable"},
     90        {conditions: {disabled: false}, expected: false, name: "[target] The willValidate attribute must be false if it has a datalist ancestor", ancestor: "datalist"}
     91      ]
     92    }
     93  ];
     94 
     95  validator.run_test(testElements, "willValidate");
     96 </script>