File: form-validation-willValidate.html

package info (click to toggle)
firefox-esr 140.4.0esr-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,539,276 kB
  • sloc: cpp: 7,381,286; javascript: 6,388,710; ansic: 3,710,139; python: 1,393,780; xml: 628,165; asm: 426,918; java: 184,004; sh: 65,742; makefile: 19,302; objc: 13,059; perl: 12,912; yacc: 4,583; cs: 3,846; pascal: 3,352; lex: 1,720; ruby: 1,226; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10
file content (96 lines) | stat: -rw-r--r-- 5,383 bytes parent folder | download | duplicates (16)
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
<!DOCTYPE html>
<meta charset="utf-8">
<title>The constraint validation API Test: element.willValidate</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-cva-willvalidate">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-constraint-validation-api">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/validator.js"></script>
<div id="log"></div>
<script>
  var testElements = [
    //input in hidden, button and reset status must be barred from the constraint validation
    {
      tag: "input",
      types: ["hidden", "button", "reset"],
      testData: [{conditions: {}, expected: false, name: "[target] Must be barred from the constraint validation"}]
    },
    //button in button and reset status must be barred from the constraint validation
    {
      tag: "button",
      types: ["button", "reset"],
      testData: [{conditions: {}, expected: false, name: "[target] Must be barred from the constraint validation"}]
    },
    // FIELDSET and OUTPUT elements are not "submittable elements" and therefore never validate.
    {
      tag: "fieldset",
      types: [],
      testData: [{conditions: {}, expected: false, name: "[target] The willValidate attribute must be false since FIELDSET is not a submittable element"}]
    },
    {
      tag: "output",
      types: [],
      testData: [{conditions: {}, expected: false, name: "[target] The willValidate attribute must be false since OUTPUT is not a submittable element"}]
    },
    //OBJECT, KEYGEN, elements must be barred from the constraint validation
    {
      tag: "object",
      types: [],
      testData: [{conditions: {}, expected: false, name: "[target] Must be barred from the constraint validation"}]
    },
    //If an element is disabled, it is barred from constraint validation.
    //The willValidate attribute must be true if an element is mutable
    //If the readonly attribute is specified on an INPUT element, the element is barred from constraint validation.
    {
      tag: "input",
      types: ["text", "search", "tel", "url", "email", "password", "datetime-local", "date", "month", "week", "time"],
      testData: [
        {conditions: {disabled: true}, expected: false, name: "[target] Must be barred from the constraint validation if it is disabled"},
        {conditions: {disabled: false, readOnly: false}, expected: true, name: "[target] The willValidate attribute must be true if an element is mutable"},
        {conditions: {readOnly: true}, expected: false, name: "[target] Must be barred from the constraint validation if it is readonly"},
        {conditions: {disabled: false, readOnly: false}, expected: false, name: "[target] The willValidate attribute must be false if it has a datalist ancestor", ancestor: "datalist"},
      ]
    },
    //In the following cases, the readonly attribute does not apply, however we should still bar the element from constraint validation.
    {
      tag: "input",
      types: ["color", "file", "submit"],
      testData: [
        {conditions: {disabled: true}, expected: false, name: "[target] Must be barred from the constraint validation if it is disabled"},
        {conditions: {disabled: false, readOnly: false}, expected: true, name: "[target] The willValidate attribute must be true if an element is mutable"},
        {conditions: {readOnly: true}, expected: false, name: "[target] Must be barred from the constraint validation if it is readonly"},
        {conditions: {disabled: false, readOnly: false}, expected: false, name: "[target] The willValidate attribute must be false if it has a datalist ancestor", ancestor: "datalist"},
      ]
    },
    {
      tag: "button",
      types: ["submit"],
      testData: [
        {conditions: {disabled: true}, expected: false, name: "[target] Must be barred from the constraint validation"},
        {conditions: {disabled: false}, expected: true, name: "[target] The willValidate attribute must be true if an element is mutable"},
        {conditions: {disabled: false}, expected: false, name: "[target] The willValidate attribute must be false if it has a datalist ancestor", ancestor: "datalist"}
      ]
    },
    {
      tag: "select",
      types: [],
      testData: [
        {conditions: {disabled: true}, expected: false, name: "[target] Must be barred from the constraint validation"},
        {conditions: {disabled: false}, expected: true, name: "[target] The willValidate attribute must be true if an element is mutable"},
        {conditions: {disabled: false}, expected: false, name: "[target] The willValidate attribute must be false if it has a datalist ancestor", ancestor: "datalist"}
      ]
    },
    {
      tag: "textarea",
      types: [],
      testData: [,
        {conditions: {disabled: true}, expected: false, name: "[target] Must be barred from the constraint validation"},
        {conditions: {disabled: false}, expected: true, name: "[target] The willValidate attribute must be true if an element is mutable"},
        {conditions: {disabled: false}, expected: false, name: "[target] The willValidate attribute must be false if it has a datalist ancestor", ancestor: "datalist"}
      ]
    }
  ];

  validator.run_test(testElements, "willValidate");
</script>