90 lines
5.8 KiB
HTML
90 lines
5.8 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<script src="../../resources/js-test-pre.js"></script>
|
|
<style>
|
|
textarea {
|
|
background-color: white;
|
|
color: black;
|
|
}
|
|
textarea:placeholder-shown {
|
|
background-color: rgb(1, 2, 3);
|
|
}
|
|
textarea:not(:placeholder-shown) {
|
|
color: rgb(4, 5, 6);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div style="display:none">
|
|
<!-- Does not match: no placeholder defined. -->
|
|
<textarea id="no-placeholder"></textarea>
|
|
|
|
<!-- Does not match: empty placeholder. -->
|
|
<textarea id="empty-placeholder" placeholder></textarea>
|
|
<textarea id="empty-placeholder2" placeholder=""></textarea>
|
|
|
|
<!-- Does not match: placeholder contains only newline or carriage return characters. -->
|
|
<textarea id="placeholder-contains-only-newline"></textarea>
|
|
<textarea id="placeholder-contains-only-carriageReturn"></textarea>
|
|
|
|
<!-- Does not match: the placeholder is not shown when a value is set -->
|
|
<textarea id="with-value" placeholder="WebKit">FooBar</textarea>
|
|
|
|
<!-- Valid cases -->
|
|
<textarea id="valid-placeholder" placeholder="WebKit"></textarea>
|
|
|
|
<!-- Value does not do anything on <textarea>, the content is the innerText -->
|
|
<textarea id="valid-placeholder-with-value-attribute" placeholder="WebKit" value></textarea>
|
|
<textarea id="valid-placeholder-with-value-attribute2" placeholder="WebKit" value=""></textarea>
|
|
<textarea id="valid-placeholder-with-value-attribute3" placeholder="WebKit" value="Rocks!"></textarea>
|
|
</div>
|
|
</body>
|
|
<script>
|
|
description('Check the basic features of the ":placeholder-shown" pseudo class with the <textarea> element.');
|
|
|
|
document.getElementById('placeholder-contains-only-newline').setAttribute('placeholder', '\n');
|
|
document.getElementById('placeholder-contains-only-carriageReturn').setAttribute('placeholder', '\r');
|
|
|
|
shouldBe('document.querySelectorAll(":placeholder-shown").length', '4');
|
|
shouldBe('document.querySelectorAll(":placeholder-shown")[0]', 'document.getElementById("valid-placeholder")');
|
|
shouldBe('document.querySelectorAll(":placeholder-shown")[1]', 'document.getElementById("valid-placeholder-with-value-attribute")');
|
|
shouldBe('document.querySelectorAll(":placeholder-shown")[2]', 'document.getElementById("valid-placeholder-with-value-attribute2")');
|
|
shouldBe('document.querySelectorAll(":placeholder-shown")[3]', 'document.getElementById("valid-placeholder-with-value-attribute3")');
|
|
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("no-placeholder")).backgroundColor', 'rgb(255, 255, 255)');
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("empty-placeholder")).backgroundColor', 'rgb(255, 255, 255)');
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("empty-placeholder2")).backgroundColor', 'rgb(255, 255, 255)');
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("placeholder-contains-only-newline")).backgroundColor', 'rgb(255, 255, 255)');
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("placeholder-contains-only-carriageReturn")).backgroundColor', 'rgb(255, 255, 255)');
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("with-value")).backgroundColor', 'rgb(255, 255, 255)');
|
|
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder")).backgroundColor', 'rgb(1, 2, 3)');
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder-with-value-attribute")).backgroundColor', 'rgb(1, 2, 3)');
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder-with-value-attribute2")).backgroundColor', 'rgb(1, 2, 3)');
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder-with-value-attribute3")).backgroundColor', 'rgb(1, 2, 3)');
|
|
|
|
debug("");
|
|
shouldBe('document.querySelectorAll("textarea:not(:placeholder-shown)").length', '6');
|
|
shouldBe('document.querySelectorAll("textarea:not(:placeholder-shown)")[0]', 'document.getElementById("no-placeholder")');
|
|
shouldBe('document.querySelectorAll("textarea:not(:placeholder-shown)")[1]', 'document.getElementById("empty-placeholder")');
|
|
shouldBe('document.querySelectorAll("textarea:not(:placeholder-shown)")[2]', 'document.getElementById("empty-placeholder2")');
|
|
shouldBe('document.querySelectorAll("textarea:not(:placeholder-shown)")[3]', 'document.getElementById("placeholder-contains-only-newline")');
|
|
shouldBe('document.querySelectorAll("textarea:not(:placeholder-shown)")[4]', 'document.getElementById("placeholder-contains-only-carriageReturn")');
|
|
shouldBe('document.querySelectorAll("textarea:not(:placeholder-shown)")[5]', 'document.getElementById("with-value")');
|
|
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("no-placeholder")).color', 'rgb(4, 5, 6)');
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("empty-placeholder")).color', 'rgb(4, 5, 6)');
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("empty-placeholder2")).color', 'rgb(4, 5, 6)');
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("placeholder-contains-only-newline")).color', 'rgb(4, 5, 6)');
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("placeholder-contains-only-carriageReturn")).color', 'rgb(4, 5, 6)');
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("with-value")).color', 'rgb(4, 5, 6)');
|
|
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder")).color', 'rgb(0, 0, 0)');
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder-with-value-attribute")).color', 'rgb(0, 0, 0)');
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder-with-value-attribute2")).color', 'rgb(0, 0, 0)');
|
|
shouldBeEqualToString('getComputedStyle(document.getElementById("valid-placeholder-with-value-attribute3")).color', 'rgb(0, 0, 0)');
|
|
</script>
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</html>
|