OLD | NEW |
1 description( | 1 description( |
2 'This test checks behavior of Node.contains. <div id="test1">[test1 <span id="te
st2">[test 2]</span>]</div>' | 2 'This test checks behavior of Node.contains. <div id="test1">[test1 <span id="te
st2">[test 2]</span>]</div>' |
3 ); | 3 ); |
4 | 4 |
5 var test1 = document.getElementById('test1'); | 5 var test1 = document.getElementById('test1'); |
6 var test1TextChild = document.getElementById('test1').firstChild; | 6 var test1TextChild = document.getElementById('test1').firstChild; |
7 var test2 = document.getElementById('test2'); | 7 var test2 = document.getElementById('test2'); |
8 | 8 |
9 shouldBeEqualToString("typeof document.contains", "function"); | 9 shouldBeEqualToString("typeof document.contains", "function"); |
10 shouldBeTrue("test1.contains(test2)"); | 10 shouldBeTrue("test1.contains(test2)"); |
11 shouldBeTrue("test1.contains(test1TextChild)"); | 11 shouldBeTrue("test1.contains(test1TextChild)"); |
12 shouldBeTrue("document.contains(test1)"); | 12 shouldBeTrue("document.contains(test1)"); |
13 shouldBeTrue("document.contains(test1TextChild)"); | 13 shouldBeTrue("document.contains(test1TextChild)"); |
14 shouldBeTrue("document.contains(document)"); | 14 shouldBeTrue("document.contains(document)"); |
15 shouldBeTrue("test1.contains(test1)"); | 15 shouldBeTrue("test1.contains(test1)"); |
16 shouldBeTrue("test1TextChild.contains(test1TextChild)"); | 16 shouldBeTrue("test1TextChild.contains(test1TextChild)"); |
17 shouldBeFalse("test1.contains(123)"); | 17 shouldThrow("test1.contains(123)"); |
18 shouldBeFalse("test1.contains(null)"); | 18 shouldBeFalse("test1.contains(null)"); |
19 | 19 |
20 // Cross document tests | 20 // Cross document tests |
21 var iframe = document.createElement("iframe"); | 21 var iframe = document.createElement("iframe"); |
22 | 22 |
23 shouldBeFalse("document.contains(iframe)"); // Not in document | 23 shouldBeFalse("document.contains(iframe)"); // Not in document |
24 shouldBeTrue("iframe.contains(iframe)"); | 24 shouldBeTrue("iframe.contains(iframe)"); |
25 | 25 |
26 document.body.appendChild(iframe); | 26 document.body.appendChild(iframe); |
27 debug('iframe is now in document'); | 27 debug('iframe is now in document'); |
28 shouldBeTrue("document.contains(iframe)"); | 28 shouldBeTrue("document.contains(iframe)"); |
29 | 29 |
30 var iframeDoc = iframe.contentDocument; | 30 var iframeDoc = iframe.contentDocument; |
31 var iframeBody = iframeDoc.body; | 31 var iframeBody = iframeDoc.body; |
32 | 32 |
33 shouldBeFalse("document.contains(iframeDoc)"); | 33 shouldBeFalse("document.contains(iframeDoc)"); |
34 shouldBeTrue("iframeDoc.contains(iframeBody)"); | 34 shouldBeTrue("iframeDoc.contains(iframeBody)"); |
35 shouldBeFalse("document.contains(iframeBody)"); | 35 shouldBeFalse("document.contains(iframeBody)"); |
OLD | NEW |