summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/uievents/legacy-domevents-tests/submissions/Microsoft/ProcessingInstruction.DOMCharacterDataModified.xml
blob: 34ad59064ffb9147e211df34c056ebf927e89432 (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
<?xml version="1.0"?>
<root>
    <head xmlns="http://www.w3.org/1999/xhtml">
        <title> ProcessingInstruction.data and DOMCharacterDataModified event </title>
    </head>

    <p xmlns="http://www.w3.org/1999/xhtml">
        <h3>DOM Events</h3>
        <h4>
            Test Description: DOMCharacterDataModified event fires after ProcessingInstruction.data have been modified,
            but the node itself has not been inserted or deleted. The proximal event target of this event shall be the
            ProcessingInstruction node.
        </h4>

        <pi><?foo bar?></pi>

        <p>Test passes if the word "PASS" appears below.</p>
        <div>Test result: </div>
        <div><testresult>FAIL</testresult></div>

        <script type="text/javascript" xmlns="http://www.w3.org/1999/xhtml">
            <![CDATA[
                var PassTest = function()
                {
                    document.getElementsByTagName("testresult")[0].firstChild.data = "PASS";
                    TestResult = true;
                }

                var FailTest = function()
                {
                    document.getElementsByTagName("testresult")[0].firstChild.data = "FAIL";
                    TestResult = false;
                }

                var EVENT = "DOMCharacterDataModified";
                var TARGET = document.getElementsByTagName('pi')[0].firstChild;
                var TestResult = false;

                try
                {
                    TARGET.addEventListener(EVENT, TestEvent, false);
                    TARGET.data = "new" + TARGET.data;
                }
                catch(ex)
                {
                    FailTest();
                }

                function TestEvent(evt)
                {
                    if ((EVENT == evt.type) && (TARGET == evt.target) && ("newbar" == evt.newValue))
                    {
                        PassTest();
                    }
                    else
                    {
                        FailTest();
                    }
                }
            ]]>
        </script>
    </p>
</root>