summaryrefslogtreecommitdiffstats
path: root/dom/html/test/forms/test_input_number_placeholder_shown.html
blob: c9c2a7f515b477af4214afa9a5a0f0a079eb2e23 (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
<!doctype html>
<title>Test for :placeholder-shown on input elements and invalid values.</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<style>
input {
  border: 1px solid purple;
}
input:placeholder-shown {
  border-color: blue;
}
</style>
<input type="number" placeholder="foo">
<script>
  SimpleTest.waitForExplicitFinish();
  SimpleTest.waitForFocus(function() {
    test();
    SimpleTest.finish();
  });

  function test() {
    let input = document.querySelector('input');
    input.focus();
    is(getComputedStyle(input).borderLeftColor, "rgb(0, 0, 255)",
       ":placeholder-shown should apply")
    sendString("x");
    isnot(getComputedStyle(input).borderLeftColor, "rgb(0, 0, 255)",
          ":placeholder-shown should not apply, even though the value is invalid")
  }
</script>