Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / selectors / placeholder-shown-with-input-basics.html
blobc9d9b9425956db4c3f7500740f1886a3bbb12df3
1 <!doctype html>
2 <script src="../../resources/js-test.js"></script>
3 <style>
4 input {
5 background-color: white;
6 color: black;
8 input:placeholder-shown {
9 background-color: rgb(1, 2, 3);
11 input:not(:placeholder-shown) {
12 color: rgb(4, 5, 6);
14 </style>
15 <div style="display:none">
16 <!-- Does not match: no placeholder defined. -->
17 <input type="text" id="no-placeholder">
18 <!-- Does not match: empty placeholder. -->
19 <input type="text" id="empty-placeholder" placeholder>
20 <input type="text" id="empty-placeholder2" placeholder="">
21 <!-- Does not match: placeholder contains only newline or carriage return characters. -->
22 <input type="text" id="placeholder-contains-only-newline">
23 <input type="text" id="placeholder-contains-only-carriageReturn">
24 <!-- Does not match: the placeholder is not shown when a value is set -->
25 <input type="text" id="with-value" placeholder="WebKit" value="FooBar">
26 <!-- Valid cases -->
27 <input type="text" id="valid-placeholder" placeholder="WebKit">
28 <input type="text" id="valid-placeholder-with-empty-value" placeholder="WebKit" value>
29 <input type="text" id="valid-placeholder-with-empty-value2" placeholder="WebKit" value="">
30 </div>
31 <script>
32 description('Check the basic features of the ":placeholder-shown" pseudo class with the &lt;input&gt; element.');
33 document.getElementById('placeholder-contains-only-newline').setAttribute('placeholder', '\n');
34 document.getElementById('placeholder-contains-only-carriageReturn').setAttribute('placeholder', '\r');
35 shouldBe('document.querySelectorAll(":placeholder-shown").length', '3');
36 shouldBe('document.querySelectorAll(":placeholder-shown")[0]', 'document.getElementById("valid-placeholder")');
37 shouldBe('document.querySelectorAll(":placeholder-shown")[1]', 'document.getElementById("valid-placeholder-with-empty-value")');
38 shouldBe('document.querySelectorAll(":placeholder-shown")[2]', 'document.getElementById("valid-placeholder-with-empty-value2")');
39 shouldBeEqualToString('getComputedStyle(document.getElementById("no-placeholder")).backgroundColor', 'rgb(255, 255, 255)');
40 shouldBeEqualToString('getComputedStyle(document.getElementById("empty-placeholder")).backgroundColor', 'rgb(255, 255, 255)');
41 shouldBeEqualToString('getComputedStyle(document.getElementById("empty-placeholder2")).backgroundColor', 'rgb(255, 255, 255)');
42 shouldBeEqualToString('getComputedStyle(document.getElementById("placeholder-contains-only-newline")).backgroundColor', 'rgb(255, 255, 255)');
43 shouldBeEqualToString('getComputedStyle(document.getElementById("placeholder-contains-only-carriageReturn")).backgroundColor', 'rgb(255, 255, 255)');
44 shouldBeEqualToString('getComputedStyle(document.getElementById("with-value")).backgroundColor', 'rgb(255, 255, 255)');
45 shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder")).backgroundColor', 'rgb(1, 2, 3)');
46 shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder-with-empty-value")).backgroundColor', 'rgb(1, 2, 3)');
47 shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder-with-empty-value2")).backgroundColor', 'rgb(1, 2, 3)');
48 debug("");
49 shouldBe('document.querySelectorAll("input:not(:placeholder-shown)").length', '6');
50 shouldBe('document.querySelectorAll("input:not(:placeholder-shown)")[0]', 'document.getElementById("no-placeholder")');
51 shouldBe('document.querySelectorAll("input:not(:placeholder-shown)")[1]', 'document.getElementById("empty-placeholder")');
52 shouldBe('document.querySelectorAll("input:not(:placeholder-shown)")[2]', 'document.getElementById("empty-placeholder2")');
53 shouldBe('document.querySelectorAll("input:not(:placeholder-shown)")[3]', 'document.getElementById("placeholder-contains-only-newline")');
54 shouldBe('document.querySelectorAll("input:not(:placeholder-shown)")[4]', 'document.getElementById("placeholder-contains-only-carriageReturn")');
55 shouldBe('document.querySelectorAll("input:not(:placeholder-shown)")[5]', 'document.getElementById("with-value")');
56 shouldBeEqualToString('getComputedStyle(document.getElementById("no-placeholder")).color', 'rgb(4, 5, 6)');
57 shouldBeEqualToString('getComputedStyle(document.getElementById("empty-placeholder")).color', 'rgb(4, 5, 6)');
58 shouldBeEqualToString('getComputedStyle(document.getElementById("empty-placeholder2")).color', 'rgb(4, 5, 6)');
59 shouldBeEqualToString('getComputedStyle(document.getElementById("placeholder-contains-only-newline")).color', 'rgb(4, 5, 6)');
60 shouldBeEqualToString('getComputedStyle(document.getElementById("placeholder-contains-only-carriageReturn")).color', 'rgb(4, 5, 6)');
61 shouldBeEqualToString('getComputedStyle(document.getElementById("with-value")).color', 'rgb(4, 5, 6)');
62 shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder")).color', 'rgb(0, 0, 0)');
63 shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder-with-empty-value")).color', 'rgb(0, 0, 0)');
64 shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder-with-empty-value2")).color', 'rgb(0, 0, 0)');
65 </script>