OLD | NEW |
1 description( | 1 description( |
2 "This tests that querySelector, querySelectorAll and matchesSelector (webkitMatc
hesSelector) don't crash when used in a viewless document." | 2 "This tests that querySelector, querySelectorAll and matchesSelector (webkitMatc
hesSelector) don't crash when used in a viewless document." |
3 ); | 3 ); |
4 | 4 |
5 var testDoc = document.implementation.createDocument("http://www.w3.org/1999/xht
ml", "html"); | 5 var testDoc = document.implementation.createDocument("http://www.w3.org/1999/xht
ml", "html", null); |
6 testDoc.documentElement.appendChild(testDoc.createElement("body")); | 6 testDoc.documentElement.appendChild(testDoc.createElement("body")); |
7 testDoc.body.appendChild(testDoc.createElement("p")).id = "p1"; | 7 testDoc.body.appendChild(testDoc.createElement("p")).id = "p1"; |
8 testDoc.getElementById("p1").appendChild(testDoc.createElement("span")).id = "s1
"; | 8 testDoc.getElementById("p1").appendChild(testDoc.createElement("span")).id = "s1
"; |
9 testDoc.body.appendChild(testDoc.createElement("span")).id = "s2"; | 9 testDoc.body.appendChild(testDoc.createElement("span")).id = "s2"; |
10 testDoc.body.appendChild(testDoc.createElement("div")).className = "d1"; | 10 testDoc.body.appendChild(testDoc.createElement("div")).className = "d1"; |
11 | 11 |
12 var p1 = testDoc.getElementById("p1"); | 12 var p1 = testDoc.getElementById("p1"); |
13 var s1 = testDoc.getElementById("s1"); | 13 var s1 = testDoc.getElementById("s1"); |
14 var s2 = testDoc.getElementById("s2"); | 14 var s2 = testDoc.getElementById("s2"); |
15 var d1 = testDoc.body.lastChild; | 15 var d1 = testDoc.body.lastChild; |
16 | 16 |
17 shouldBe("testDoc.querySelector('p')", "p1"); | 17 shouldBe("testDoc.querySelector('p')", "p1"); |
18 shouldBe("testDoc.querySelectorAll('span').length", "2"); | 18 shouldBe("testDoc.querySelectorAll('span').length", "2"); |
19 shouldBe("testDoc.querySelectorAll('span').item(1)", "s2"); | 19 shouldBe("testDoc.querySelectorAll('span').item(1)", "s2"); |
20 shouldBe("testDoc.querySelector('.d1')", "d1"); | 20 shouldBe("testDoc.querySelector('.d1')", "d1"); |
21 shouldBe("testDoc.querySelectorAll('p span').length", "1"); | 21 shouldBe("testDoc.querySelectorAll('p span').length", "1"); |
22 | 22 |
23 shouldBeTrue("p1.webkitMatchesSelector('p')"); | 23 shouldBeTrue("p1.webkitMatchesSelector('p')"); |
24 shouldBeTrue("s1.webkitMatchesSelector('p span')"); | 24 shouldBeTrue("s1.webkitMatchesSelector('p span')"); |
25 shouldBeTrue("s2.webkitMatchesSelector('#s2')"); | 25 shouldBeTrue("s2.webkitMatchesSelector('#s2')"); |
26 shouldBeTrue("d1.webkitMatchesSelector('.d1')"); | 26 shouldBeTrue("d1.webkitMatchesSelector('.d1')"); |
OLD | NEW |