widget/tests/test_key_event_counts.xul

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 <?xml version="1.0"?>
     2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
     5 <!-- We've had issues on Mac OS X where native key events either don't get processed
     6      or they get processed twice. This test tests some of those scenarios. -->
     8 <window id="window1" title="Test Key Event Counts" onload="runTest()"
     9   xmlns:html="http://www.w3.org/1999/xhtml"
    10   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    12   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    13   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
    14   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/NativeKeyCodes.js"/>
    16   <!-- test results are displayed in the html:body -->
    17   <body xmlns="http://www.w3.org/1999/xhtml">
    18     <p id="display"></p>
    19     <div id="content" style="display: none"></div>
    20     <pre id="test"></pre>
    21   </body>
    23   <script type="application/javascript"><![CDATA[
    24     var gKeyPressEventCount = 0;
    26     function onKeyPress(e)
    27     {
    28       gKeyPressEventCount++;
    29       e.preventDefault();
    30     }
    32     function runTest()
    33     {
    34       window.addEventListener("keypress", onKeyPress, false);
    36       // Test ctrl-tab
    37       gKeyPressEventCount = 0;
    38       synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_Tab, {ctrlKey:1}, "\t", "\t");
    39       is(gKeyPressEventCount, 1);
    41       // Test cmd+shift+a
    42       gKeyPressEventCount = 0;
    43       synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_A, {metaKey:1, shiftKey:1}, "a", "A");
    44       is(gKeyPressEventCount, 1);
    46       // Test cmd-;
    47       gKeyPressEventCount = 0;
    48       synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_Semicolon, {metaKey:1}, ";", ";");
    49       is(gKeyPressEventCount, 1);
    51       window.removeEventListener("keypress", onKeyPress, false);
    52     }
    53   ]]></script>
    55 </window>

mercurial