1 description('Unit tests for WebCore text iterator');
3 function appendBrElement(node
)
5 node
.appendChild(document
.createElement('br'));
8 function addShadowTreeWithDivElement(node
)
10 node
.createShadowRoot();
11 internals
.oldestShadowRoot(node
).innerHTML
= '<div>b</div>';
14 var subframe
= document
.createElement('iframe');
15 document
.body
.appendChild(subframe
);
17 var testDocument
= subframe
.contentDocument
;
18 var range
= testDocument
.createRange();
20 var head
= testDocument
.createElement("head");
21 testDocument
.documentElement
.insertBefore(head
, testDocument
.documentElement
.firstChild
);
23 testDocument
.body
.innerHTML
= '';
24 shouldBe('range.selectNodeContents(testDocument.body); internals.rangeAsText(range)', '""');
26 testDocument
.body
.innerHTML
= 'a';
27 shouldBe('range.selectNodeContents(testDocument.body); internals.rangeAsText(range)', '"a"');
29 testDocument
.body
.innerHTML
= '<div>a</div>';
30 shouldBe('range.selectNodeContents(testDocument.body); internals.rangeAsText(range)', '"a"');
32 testDocument
.body
.innerHTML
= '<div>a</div><div>b</div>';
33 shouldBe('range.selectNodeContents(testDocument.body); internals.rangeAsText(range)', '"a\\nb"');
35 testDocument
.body
.innerHTML
= '<div style="line-height: 18px; min-height: 436px; " id="node-content" class="note-content">debugging this note</div>';
36 shouldBe('range.selectNodeContents(testDocument.body); internals.rangeAsText(range)', '"debugging this note"');
38 testDocument
.body
.innerHTML
= '<div>Hello<div><span><span><br></div></div>';
39 shouldBe('range.selectNodeContents(testDocument.body); internals.rangeAsText(range)', '"Hello\\n"');
41 testDocument
.body
.innerHTML
= '<div class="note-rule-vertical" style="left:22px"></div>\n\t\t<div class="note-rule-vertical" style="left:26px"></div>\n\n\t\t<div class="note-wrapper">\n\t\t\t<div class="note-header">\n\t\t\t\t<div class="note-body" id="note-body">\n\t\t\t\t\t<div class="note-content" id="note-content" contenteditable="true" style="line-height: 20px; min-height: 580px; ">hey</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t\n';
42 shouldBe('range.selectNodeContents(testDocument.body); internals.rangeAsText(range)', '"hey"');
43 shouldBe('range.setStartBefore(testDocument.body); range.setEndAfter(testDocument.body); internals.rangeAsText(range)', '"hey"');
45 testDocument
.body
.innerHTML
= '<input id="a" value="b" />';
46 var input
= testDocument
.querySelector('input');
47 shouldBe('range.selectNodeContents(internals.oldestShadowRoot(input)); internals.rangeAsText(range)', '"b"');
49 shouldBe('appendBrElement(internals.oldestShadowRoot(input).childNodes[0]); range.selectNodeContents(internals.oldestShadowRoot(input)); internals.rangeAsText(range)', '"b"');
51 document
.body
.removeChild(subframe
);
53 var successfullyParsed
= true;