forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic-iteration.html
67 lines (51 loc) · 2.98 KB
/
basic-iteration.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script src="resources/js-test-selection-shared.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description('Unit tests for WebCore text iterator');
function appendBrElement(node)
{
node.appendChild(document.createElement('br'));
}
function addShadowTreeWithDivElement(node)
{
node.webkitCreateShadowRoot();
internals.shadowRoot(node).innerHTML = '<div>b</div>';
}
var subframe = document.createElement('iframe');
document.body.appendChild(subframe);
var testDocument = subframe.contentDocument;
var range = testDocument.createRange();
var head = testDocument.createElement("head");
testDocument.documentElement.insertBefore(head, testDocument.documentElement.firstChild);
testDocument.body.innerHTML = '';
shouldBe('range.selectNodeContents(testDocument.body); internals.rangeAsText(range)', '""');
testDocument.body.innerHTML = 'a';
shouldBe('range.selectNodeContents(testDocument.body); internals.rangeAsText(range)', '"a"');
testDocument.body.innerHTML = '<div>a</div>';
shouldBe('range.selectNodeContents(testDocument.body); internals.rangeAsText(range)', '"a"');
testDocument.body.innerHTML = '<div>a</div><div>b</div>';
shouldBe('range.selectNodeContents(testDocument.body); internals.rangeAsText(range)', '"a\\nb"');
testDocument.body.innerHTML = '<div style="line-height: 18px; min-height: 436px; " id="node-content" class="note-content">debugging this note</div>';
shouldBe('range.selectNodeContents(testDocument.body); internals.rangeAsText(range)', '"debugging this note"');
testDocument.body.innerHTML = '<div>Hello<div><span><span><br></div></div>';
shouldBe('range.selectNodeContents(testDocument.body); internals.rangeAsText(range)', '"Hello\\n"');
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';
shouldBe('range.selectNodeContents(testDocument.body); internals.rangeAsText(range)', '"hey"');
shouldBe('range.setStartBefore(testDocument.body); range.setEndAfter(testDocument.body); internals.rangeAsText(range)', '"hey"');
testDocument.body.innerHTML = '<input id="a" value="b" />';
var input = testDocument.querySelector('input');
shouldBe('range.selectNodeContents(internals.shadowRoot(input)); internals.rangeAsText(range)', '"b"');
shouldBe('appendBrElement(internals.shadowRoot(input).childNodes[0]); range.selectNodeContents(internals.shadowRoot(input)); internals.rangeAsText(range)', '"b"');
document.body.removeChild(subframe);
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>