benjamin@webkit.org | ff47a36 | 2014-08-15 04:06:27 +0000 | [diff] [blame] | 1 | <!doctype html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <script src="../../resources/js-test-pre.js"></script> |
| 5 | <style> |
| 6 | testcase { |
| 7 | background-color: white; |
| 8 | } |
| 9 | testcase:empty { |
| 10 | background-color: rgb(1, 2, 3); |
| 11 | } |
| 12 | </style> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div style="display:none"> |
| 16 | <!-- Success: No content --> |
| 17 | <testcase id="no-content"></testcase> |
| 18 | |
| 19 | <!-- Success: Comments are not elment --> |
| 20 | <testcase id="comment"><!-- empty --></testcase> |
| 21 | |
| 22 | <!-- Success: Empty text node are okay. --> |
| 23 | <testcase id="empty-textnodes"></testcase> |
| 24 | |
| 25 | <!-- Success: The two above. --> |
| 26 | <testcase id="comments-and-empty-textnodes"></testcase> |
| 27 | |
| 28 | <!-- Failure: Non empty text node, there is a space character. --> |
| 29 | <testcase id="space-character"> </testcase> |
| 30 | |
| 31 | <!-- Failure: the <span> element inside makes the node non-empty. --> |
| 32 | <testcase id="element"><span></span></testcase> |
| 33 | </div> |
| 34 | </body> |
| 35 | <script> |
| 36 | description('Check the basic features of the ":empty" pseudo class.'); |
| 37 | |
| 38 | var emptyTextnodes = document.getElementById("empty-textnodes"); |
| 39 | for (var i = 0; i < 10; ++i) |
| 40 | emptyTextnodes.appendChild(document.createTextNode("")); |
| 41 | |
| 42 | var commentsAndEmptyTextnodes = document.getElementById("comments-and-empty-textnodes"); |
| 43 | for (var i = 0; i < 10; ++i) { |
| 44 | commentsAndEmptyTextnodes.appendChild(document.createTextNode("")); |
| 45 | commentsAndEmptyTextnodes.appendChild(document.createComment("WebKit!")); |
| 46 | } |
| 47 | |
| 48 | shouldBe('document.querySelectorAll("testcase:empty").length', '4'); |
| 49 | shouldBe('document.querySelectorAll("testcase:empty")[0]', 'document.getElementById("no-content")'); |
| 50 | shouldBe('document.querySelectorAll("testcase:empty")[1]', 'document.getElementById("comment")'); |
| 51 | shouldBe('document.querySelectorAll("testcase:empty")[2]', 'document.getElementById("empty-textnodes")'); |
| 52 | shouldBe('document.querySelectorAll("testcase:empty")[3]', 'document.getElementById("comments-and-empty-textnodes")'); |
| 53 | |
| 54 | shouldBeEqualToString('getComputedStyle(document.getElementById("no-content")).backgroundColor', 'rgb(1, 2, 3)'); |
| 55 | shouldBeEqualToString('getComputedStyle(document.getElementById("comment")).backgroundColor', 'rgb(1, 2, 3)'); |
| 56 | shouldBeEqualToString('getComputedStyle(document.getElementById("empty-textnodes")).backgroundColor', 'rgb(1, 2, 3)'); |
| 57 | shouldBeEqualToString('getComputedStyle(document.getElementById("comments-and-empty-textnodes")).backgroundColor', 'rgb(1, 2, 3)'); |
| 58 | shouldBeEqualToString('getComputedStyle(document.getElementById("space-character")).backgroundColor', 'rgb(255, 255, 255)'); |
| 59 | shouldBeEqualToString('getComputedStyle(document.getElementById("element")).backgroundColor', 'rgb(255, 255, 255)'); |
| 60 | |
| 61 | </script> |
| 62 | <script src="../../resources/js-test-post.js"></script> |
| 63 | </html> |