Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / SelectorAPI / script-tests / viewless-document.js
blob7a9d43e2baca4fec79d15373abd98700078cc57d
1 description(
2 "This tests that querySelector, querySelectorAll and matchesSelector (webkitMatchesSelector) don't crash when used in a viewless document."
3 );
5 var testDoc = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html");
6 testDoc.documentElement.appendChild(testDoc.createElement("body"));
7 testDoc.body.appendChild(testDoc.createElement("p")).id = "p1";
8 testDoc.getElementById("p1").appendChild(testDoc.createElement("span")).id = "s1";
9 testDoc.body.appendChild(testDoc.createElement("span")).id = "s2";
10 testDoc.body.appendChild(testDoc.createElement("div")).className = "d1";
12 var p1 = testDoc.getElementById("p1");
13 var s1 = testDoc.getElementById("s1");
14 var s2 = testDoc.getElementById("s2");
15 var d1 = testDoc.body.lastChild;
17 shouldBe("testDoc.querySelector('p')", "p1");
18 shouldBe("testDoc.querySelectorAll('span').length", "2");
19 shouldBe("testDoc.querySelectorAll('span').item(1)", "s2");
20 shouldBe("testDoc.querySelector('.d1')", "d1");
21 shouldBe("testDoc.querySelectorAll('p span').length", "1");
23 shouldBeTrue("p1.webkitMatchesSelector('p')");
24 shouldBeTrue("s1.webkitMatchesSelector('p span')");
25 shouldBeTrue("s2.webkitMatchesSelector('#s2')");
26 shouldBeTrue("d1.webkitMatchesSelector('.d1')");