2 <script src=
"../../resources/js-test.js"></script>
5 background-color: white;
8 textarea:placeholder-shown {
9 background-color: rgb(
1,
2,
3);
11 textarea:not(:placeholder-shown) {
15 <div style=
"display:none">
16 <!-- Does not match: no placeholder defined. -->
17 <textarea id=
"no-placeholder"></textarea>
18 <!-- Does not match: empty placeholder. -->
19 <textarea id=
"empty-placeholder" placeholder
></textarea>
20 <textarea id=
"empty-placeholder2" placeholder=
""></textarea>
21 <!-- Does not match: placeholder contains only newline or carriage return characters. -->
22 <textarea id=
"placeholder-contains-only-newline"></textarea>
23 <textarea id=
"placeholder-contains-only-carriageReturn"></textarea>
24 <!-- Does not match: the placeholder is not shown when a value is set -->
25 <textarea id=
"with-value" placeholder=
"WebKit">FooBar
</textarea>
27 <textarea id=
"valid-placeholder" placeholder=
"WebKit"></textarea>
28 <!-- Value does not do anything on <textarea>, the content is the innerText -->
29 <textarea id=
"valid-placeholder-with-value-attribute" placeholder=
"WebKit" value
></textarea>
30 <textarea id=
"valid-placeholder-with-value-attribute2" placeholder=
"WebKit" value=
""></textarea>
31 <textarea id=
"valid-placeholder-with-value-attribute3" placeholder=
"WebKit" value=
"Rocks!"></textarea>
34 description('Check the basic features of the ":placeholder-shown" pseudo class with the <textarea> element.');
35 document
.getElementById('placeholder-contains-only-newline').setAttribute('placeholder', '\n');
36 document
.getElementById('placeholder-contains-only-carriageReturn').setAttribute('placeholder', '\r');
37 shouldBe('document.querySelectorAll(":placeholder-shown").length', '4');
38 shouldBe('document.querySelectorAll(":placeholder-shown")[0]', 'document.getElementById("valid-placeholder")');
39 shouldBe('document.querySelectorAll(":placeholder-shown")[1]', 'document.getElementById("valid-placeholder-with-value-attribute")');
40 shouldBe('document.querySelectorAll(":placeholder-shown")[2]', 'document.getElementById("valid-placeholder-with-value-attribute2")');
41 shouldBe('document.querySelectorAll(":placeholder-shown")[3]', 'document.getElementById("valid-placeholder-with-value-attribute3")');
42 shouldBeEqualToString('getComputedStyle(document.getElementById("no-placeholder")).backgroundColor', 'rgb(255, 255, 255)');
43 shouldBeEqualToString('getComputedStyle(document.getElementById("empty-placeholder")).backgroundColor', 'rgb(255, 255, 255)');
44 shouldBeEqualToString('getComputedStyle(document.getElementById("empty-placeholder2")).backgroundColor', 'rgb(255, 255, 255)');
45 shouldBeEqualToString('getComputedStyle(document.getElementById("placeholder-contains-only-newline")).backgroundColor', 'rgb(255, 255, 255)');
46 shouldBeEqualToString('getComputedStyle(document.getElementById("placeholder-contains-only-carriageReturn")).backgroundColor', 'rgb(255, 255, 255)');
47 shouldBeEqualToString('getComputedStyle(document.getElementById("with-value")).backgroundColor', 'rgb(255, 255, 255)');
48 shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder")).backgroundColor', 'rgb(1, 2, 3)');
49 shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder-with-value-attribute")).backgroundColor', 'rgb(1, 2, 3)');
50 shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder-with-value-attribute2")).backgroundColor', 'rgb(1, 2, 3)');
51 shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder-with-value-attribute3")).backgroundColor', 'rgb(1, 2, 3)');
53 shouldBe('document.querySelectorAll("textarea:not(:placeholder-shown)").length', '6');
54 shouldBe('document.querySelectorAll("textarea:not(:placeholder-shown)")[0]', 'document.getElementById("no-placeholder")');
55 shouldBe('document.querySelectorAll("textarea:not(:placeholder-shown)")[1]', 'document.getElementById("empty-placeholder")');
56 shouldBe('document.querySelectorAll("textarea:not(:placeholder-shown)")[2]', 'document.getElementById("empty-placeholder2")');
57 shouldBe('document.querySelectorAll("textarea:not(:placeholder-shown)")[3]', 'document.getElementById("placeholder-contains-only-newline")');
58 shouldBe('document.querySelectorAll("textarea:not(:placeholder-shown)")[4]', 'document.getElementById("placeholder-contains-only-carriageReturn")');
59 shouldBe('document.querySelectorAll("textarea:not(:placeholder-shown)")[5]', 'document.getElementById("with-value")');
60 shouldBeEqualToString('getComputedStyle(document.getElementById("no-placeholder")).color', 'rgb(4, 5, 6)');
61 shouldBeEqualToString('getComputedStyle(document.getElementById("empty-placeholder")).color', 'rgb(4, 5, 6)');
62 shouldBeEqualToString('getComputedStyle(document.getElementById("empty-placeholder2")).color', 'rgb(4, 5, 6)');
63 shouldBeEqualToString('getComputedStyle(document.getElementById("placeholder-contains-only-newline")).color', 'rgb(4, 5, 6)');
64 shouldBeEqualToString('getComputedStyle(document.getElementById("placeholder-contains-only-carriageReturn")).color', 'rgb(4, 5, 6)');
65 shouldBeEqualToString('getComputedStyle(document.getElementById("with-value")).color', 'rgb(4, 5, 6)');
66 shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder")).color', 'rgb(0, 0, 0)');
67 shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder-with-value-attribute")).color', 'rgb(0, 0, 0)');
68 shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder-with-value-attribute2")).color', 'rgb(0, 0, 0)');
69 shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder-with-value-attribute3")).color', 'rgb(0, 0, 0)');