tor-browser

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

compositionstart.preventDefault.html (2223B)


      1 <!DOCTYPE HTML>
      2 <html>
      3    <head>
      4        <title id='desc'> Cancelling compositionstart Event via Event.preventDefault() </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 = "compositionstart";
     17            var TARGET;
     18 
     19            window.onload = function(e)
     20            {
     21                try
     22                {
     23                    TARGET = document.getElementById("target");
     24                    TARGET.addEventListener(EVENT, TestEvent, true);
     25                    TARGET.addEventListener("keyup", TestEvent, true);
     26                }
     27                catch(ex)
     28                {
     29                    FailTest();
     30                }
     31            }
     32 
     33            function TestEvent(evt)
     34            {
     35                if (evt.type == EVENT)
     36                {
     37                    evt.preventDefault();
     38                }
     39 
     40                if (evt.type == "keyup")
     41                {
     42                    if (TARGET.value == "")
     43                    {
     44                        PassTest();
     45                    }
     46                    else
     47                    {
     48                        FailTest();
     49                    }
     50                }
     51            }
     52        </script>
     53    </head>
     54    <body>
     55        <h3>DOM Events</h3>
     56        <h4>
     57            Test Description: The default action of compositionstart event is to launch the appropriate text
     58            composition system. If this event is canceled, the text composition system must not be launched.
     59        </h4>
     60 
     61        <pre>
     62            <input id="target" value=""/>
     63 
     64            Steps:
     65            1) Open Japanese Microsoft IME and select Hiragana input method
     66            2) Click at the above textbox and then type 'a' using keyboard
     67        </pre>
     68 
     69        <p>Test passes if the word "PASS" appears below and nothing is typed to the textbox after following the above steps.</p>
     70        <div>Test result: </div>
     71        <div id='testresult'>FAIL</div>
     72    </body>
     73 </html>