summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/forms/the-button-element/button-type.html
blob: 6cfd6687c707479600534de03156afa698daa314 (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
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTMLButtonElement.prototype.type</title>
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-button-type">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<script>
"use strict";

test(() => {

  const button = document.createElement("button");
  assert_equals(button.type, "submit");

}, "a button's type should be submit by default");

test(() => {

  const button = document.createElement("button");

  for (const type of ["reset", "button", "submit"]) {
    button.type = type;
    assert_equals(button.type, type);

    button.type = type.toUpperCase();
    assert_equals(button.type, type);
  }

  button.type = "reset";
  button.type = "asdfgdsafd";
  assert_equals(button.type, "submit");

  button.type = "reset";
  button.type = "";
  assert_equals(button.type, "submit");

}, "a button's type should stay within the range of valid values");

</script>