summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/inspector/elements/modify-chardata.html
blob: 08ab0a6d457644ca65ae85564ac2bb51419beca9 (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/elements-test.js"></script>
<script>

function modifyChars()
{
    var node = document.getElementById("node");
    node.firstChild.textContent = "Bar";
}

function modifyViaRange()
{
    var range = document.createRange();
    var referenceNode = document.getElementById("rangenode").firstChild;
    range.selectNode(referenceNode);
    range.setStart(referenceNode, 9);
    range.setEnd(referenceNode, 9 + 5);
    range.deleteContents();
    var span = range.startContainer.ownerDocument.createElement("span");
    span.innerHTML = "test";
    range.insertNode(span);
}

function test()
{
    var targetNode;

    InspectorTest.runTestSuite([
        function testDumpInitial(next)
        {
            function callback(node)
            {
                targetNode = node;
                InspectorTest.addResult("========= Original for normal mutation ========");
                InspectorTest.dumpElementsTree(targetNode);
                next();
            }
            InspectorTest.selectNodeWithId("node", callback);
        },

        function testSetAttribute(next)
        {
            function callback()
            {
                InspectorTest.addResult("===== Mutated text node =====");
                InspectorTest.dumpElementsTree(targetNode);
                next();
            }
            InspectorTest.evaluateInPage("modifyChars()", callback);
        },

        function testModifyViaRange(next)
        {
            function callback()
            {
                InspectorTest.addResult("===== Contents modified via Range =====");
                InspectorTest.dumpElementsTree(targetNode);
                next();
            }
            function expandCallback()
            {
                InspectorTest.expandElementsTree(callback);
            }
            function selectCallback(node)
            {
                targetNode = node;
                InspectorTest.addResult("========= Original for Range mutation ========");
                InspectorTest.dumpElementsTree(targetNode);
                InspectorTest.evaluateInPage("modifyViaRange()", expandCallback);
            }
            InspectorTest.selectNodeWithId("rangenode", selectCallback);
        }
    ]);
}

</script>
</head>

<body onload="runTest()">
<p>
Tests that elements panel updates dom tree structure upon changes to characters.
</p>

<div id="node">Foo</div>
<div id="rangenode">Lorem ipsum dolor sit amet</div>

</body>
</html>