summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/forms/the-input-element/input-type-button.html
blob: 0f269355a5116b177395ccb34abcf7093c2b2eba (plain)
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
<!DOCTYPE HTML>
<head>
<title>input type button</title>
<link rel="author" title="Takeharu.Oshida" href="mailto:georgeosddev@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#button-state-(type=button)">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<div id="hide" style="display">
  <input type="button"/>
  <input type="button" value="BUTTON"/>
  <form action="/" method="get" onsubmit="isSubmitted = true;return false;">
    <input type="button" value="mutable"/>
  </form>
  <form action="/" method="get" onsubmit="isSubmitted = true;return false;">
    <input type="button" value="immutable" disabled/>
  </form>
</div>
<script>
var isSubmitted = false;
var buttons = document.getElementsByTagName("input");

test(function() {
  assert_equals(buttons[0].click(), undefined, "The input element represents a button with no default behavior");
},"default behavior");

test(function() {
  assert_equals(buttons[0].value, "", "It must be the empty string");
},"empty value attribute");

test(function() {
  document.getElementById("hide").style.display = "block";
  assert_not_equals(buttons[0].offsetWidth, buttons[1].offsetWidth, "If the element has a value attribute, the button's label must be the value of that attribute");
  document.getElementById("hide").style.display = "none";
},"label value");

test(function() {
  isSubmitted = false;
  buttons[2].click();
  assert_equals(isSubmitted, false, "If the element is mutable, the element's activation behavior is to do nothing.");
},"mutable element's activation behavior is to do nothing.");

test(function() {
  isSubmitted = false;
  buttons[3].click()
  assert_equals(isSubmitted, false, "If the element is immutable, the element has no activation behavior.");
},"immutable element has no activation behavior.");
</script>
</body>