tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

TextEvent.initTextEvent.html (2010B)


      1 <!DOCTYPE html>
      2 <html>
      3    <head>
      4        <title id='desc'> TextEvent.initTextEvent() and Event.trusted </title>
      5        <script type="text/javascript">
      6            var PassTest = function()
      7            {
      8                document.getElementById("testresult").firstChild.data = "PASS";
      9            }
     10 
     11            var FailTest = function()
     12            {
     13                document.getElementById("testresult").firstChild.data = "FAIL";
     14            }
     15 
     16            var EVENT = "foo";
     17            var TARGET;
     18 
     19            window.onload = function()
     20            {
     21                try
     22                {
     23                    TARGET = document.getElementById("target");
     24                    TARGET.addEventListener(EVENT, TestEvent, true);
     25 
     26                    var evt = document.createEvent("TextEvent");
     27                    evt.initTextEvent(EVENT,    /* type */
     28                                      true,     /* bubbles */
     29                                      true,     /* cancelable */
     30                                      window,   /* view */
     31                                      "domstr", /* data*/
     32                                      0         /* inputMode */ );
     33                    TARGET.dispatchEvent(evt);
     34                }
     35                catch(ex)
     36                {
     37                    FailTest();
     38                }
     39 
     40            }
     41 
     42            function TestEvent(evt)
     43            {
     44                if ((EVENT == evt.type) && (false == evt.trusted))
     45                {
     46                    PassTest();
     47                }
     48                else
     49                {
     50                    FailTest();
     51                }
     52            }
     53        </script>
     54    </head>
     55    <body>
     56        <h3>DOM Events</h3>
     57        <h4>
     58            Test Description: initTextEvent initializes attributes of a TextEvent object.
     59        </h4>
     60 
     61        <input id="target" type="hidden" />
     62        <p>Test passes if the word "PASS" appears below.</p>
     63        <div>Test result: </div>
     64        <div id='testresult'>FAIL</div>
     65    </body>
     66 </html>