DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Untracked file

Line Code
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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                 type="text/css"?>
<window title="Key event tests"
  onload="runTest()"
  xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <title>Key event tests</title>
  <script type="application/javascript" 
   src="chrome://mochikit/content/MochiKit/packed.js"></script>
  <script type="application/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />

<keyset>
  <key id="unshiftedKey" key=";" modifiers="accel" oncommand="this.activeCount++"/>
  <key id="shiftedKey" key=":" modifiers="accel" oncommand="this.activeCount++"/>
  <key id="commandOptionF" key='f' modifiers="accel,alt" oncommand="this.activeCount++"/>
  <key id="question" key='?' modifiers="accel" oncommand="this.activeCount++"/>
  <key id="unshiftedX" key="x" modifiers="accel" oncommand="this.activeCount++"/>
  <key id="shiftedX" key="X" modifiers="accel,shift" oncommand="this.activeCount++"/>
  <key id="unshiftedPlus" key="+" modifiers="accel" oncommand="this.activeCount++"/>
</keyset>

<body  xmlns="http://www.w3.org/1999/xhtml">
<p id="display">
  <!-- for some reason, if we don't have 'accesskey' here, adding it dynamically later
       doesn't work! -->
  <button id="button" accesskey="z">Hello</button>
  <input type="text" id="textbox" value=""/>
</p>
<div id="content" style="display: none">
  
</div>
<pre id="test">
</pre>
</body>

<script class="testbody" type="application/javascript">
<![CDATA[

SimpleTest.waitForExplicitFinish();

function synthesizeNativeKey(aLayout, aKeyCode, aModifiers, aSystemChars,
                             aSystemUnmodifiedChars, aWindow)
{
  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

  if (!aWindow)
    aWindow = window;

  var utils = aWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
                      getInterface(Components.interfaces.nsIDOMWindowUtils);

  if (utils) {
    var modifiers = 0;
    if (aModifiers.capsLock) modifiers |= 0x01;
    if (aModifiers.numLock) modifiers |= 0x02;
    if (aModifiers.shift) modifiers |= 0x0100;
    if (aModifiers.shiftRight) modifiers |= 0x0200;
    if (aModifiers.ctrl) modifiers |= 0x0400;
    if (aModifiers.ctrlRight) modifiers |= 0x0800;
    if (aModifiers.alt) modifiers |= 0x1000;
    if (aModifiers.altRight) modifiers |= 0x2000;
    if (aModifiers.command) modifiers |= 0x4000;
    if (aModifiers.help) modifiers |= 0x8000;
    if (aModifiers.function) modifiers |= 0x10000;
    if (aModifiers.numericKeyPad) modifiers |= 0x01000000;
    
    utils.sendNativeKeyEvent(aLayout, aKeyCode, modifiers,
                             aSystemChars, aSystemUnmodifiedChars);
  }
}

var keyboardLayouts;
if (navigator.platform.indexOf("Mac") == 0) {
  // These constants can be found by inspecting files under
  // /System/Library/Keyboard\ Layouts/Unicode.bundle/Contents/Resources/
  // XXX if you need a new keyboard layout and that uses KCHR resource,
  // you need to modify GetScriptFromKeyboardLayout of nsChildView.mm
  keyboardLayouts = {
    "US":0,
    "Greek":-18944,
    "German":3,
    "Swedish":224
  };
} else if (navigator.platform.indexOf("Win") == 0) {
  // These constants can be found by inspecting registry keys under
  // HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Keyboard Layouts
  keyboardLayouts = {
    "US":0x409,
    "Greek":0x408,
    "Swedish":0x41d,
    "Arabic":0x401,
    "Hebrew":0x40d,
    "Japanese":0x411,
    "Lithuanian":0x10427
  };
}

function eventToString(aEvent)
{
  var name = aEvent.layout + " '" + aEvent.chars + "'";
  if (aEvent.shift) {
    name += " [Shift]";
  }
  if (aEvent.ctrl) {
    name += " [Ctrl]";
  }
  if (aEvent.alt) {
    name += " [Alt]";
  }
  if (aEvent.command) {
    name += " [Command]";
  }

  return name;  
}

function synthesizeKey(aEvent, aFocusElementId)
{
  document.getElementById(aFocusElementId).focus();

  synthesizeNativeKey(keyboardLayouts[aEvent.layout],
                      aEvent.keyCode, aEvent, aEvent.chars, aEvent.unmodifiedChars);
}

// Test the charcodes and modifiers being delivered to keypress handlers.
function runPressTests()
{
  var pressList;
  function onKeyPress(e)
  {
    pressList.push(e);
    e.preventDefault();
  }

  // The first parameter is the complete input event. The second parameter is
  // what to test against.
  // XXX should probably check that keydown and keyup events were dispatched too
  function testKey(aEvent, aExpectGeckoChar)
  {
    pressList = [];
    
    synthesizeKey(aEvent, "button");

    var name = eventToString(aEvent);

    is(pressList.length, aExpectGeckoChar == "" ? 0 : 1, name + ", wrong number of press events");
    if (pressList.length == 0)
      return;
    var e = pressList[0];
    is(e.ctrlKey, aEvent.ctrl || 0, name + ", Ctrl mismatch");
    is(e.metaKey, aEvent.command || 0, name + ", Command mismatch");
    is(e.altKey, aEvent.alt || 0, name + ", Alt mismatch");
    is(e.shiftKey, aEvent.shift || 0, name + ", Shift mismatch");
  
    if (aExpectGeckoChar.length > 0) {
      is(e.charCode, aExpectGeckoChar.charCodeAt(0), name + ", charcode");
    } else {
      is(e.charCode, 0, name + ", no charcode");
    }
  }

  // These tests have to be per-plaform.
  document.addEventListener("keypress", onKeyPress, false);

  if (navigator.platform.indexOf("Mac") == 0) {
    // On Mac, you can produce event records for any desired keyboard input
    // by running with NSPR_LOG_MODULES=nsCocoaWidgets:5 and typing into the browser.
    // We will dump the key event fields to the console. Use the International system
    // preferences widget to enable other keyboard layouts and select them from the
    // input menu to see what keyboard events they generate.
    // Note that it's possible to send bogus key events here, e.g.
    // {keyCode:0, chars:"z", unmodifiedChars:"P"} --- sendNativeKeyEvent
    // makes no attempt to verify that the keyCode matches the characters. So only
    // test key event records that you saw Cocoa send.

    // Plain text input
    testKey({layout:"US", keyCode:0, chars:"a", unmodifiedChars:"a"},
            "a");
    testKey({layout:"US", keyCode:11, chars:"b", unmodifiedChars:"b"},
            "b");
    testKey({layout:"US", keyCode:0, shift:1, chars:"A", unmodifiedChars:"A"},
            "A");

    // Ctrl keys
    testKey({layout:"US", keyCode:0, ctrl:1, chars:"\u0001", unmodifiedChars:"a"},
            "a");
    testKey({layout:"US", keyCode:0, ctrl:1, shift:1, chars:"\u0001", unmodifiedChars:"A"},
            "A");

    // Alt keys
    testKey({layout:"US", keyCode:0, alt:1, chars:"\u00e5", unmodifiedChars:"a"},
            "\u00e5");
    testKey({layout:"US", keyCode:0, alt:1, shift:1, chars:"\u00c5", unmodifiedChars:"A"},
            "\u00c5");
    
    // Command keys
    testKey({layout:"US", keyCode:0, command:1, chars:"a", unmodifiedChars:"a"},
            "a");
    // Shift-cmd gives us the shifted character
    testKey({layout:"US", keyCode:0, command:1, shift:1, chars:"a", unmodifiedChars:"A"},
            "A");
    // Ctrl-cmd gives us the unshifted character
    testKey({layout:"US", keyCode:0, command:1, ctrl:1, chars:"\u0001", unmodifiedChars:"a"},
            "a");
    // Alt-cmd gives us the shifted character
    testKey({layout:"US", keyCode:0, command:1, alt:1, chars:"\u00e5", unmodifiedChars:"a"},
            "\u00e5");
    testKey({layout:"US", keyCode:0, command:1, alt:1, shift:1, chars:"\u00c5", unmodifiedChars:"a"},
            "\u00c5");

    // Greek ctrl keys produce Latin charcodes
    testKey({layout:"Greek", keyCode:0, ctrl:1, chars:"\u0001", unmodifiedChars:"\u03b1"},
            "a");
    testKey({layout:"Greek", keyCode:0, ctrl:1, shift:1, chars:"\u0001", unmodifiedChars:"\u0391"},
            "A");

    // Greek command keys
    testKey({layout:"Greek", keyCode:0, command:1, chars:"a", unmodifiedChars:"\u03b1"},
            "a");
    // Shift-cmd gives us the shifted character
    testKey({layout:"Greek", keyCode:0, command:1, shift:1, chars:"a", unmodifiedChars:"\u391"},
            "A");
    // Ctrl-cmd gives us the unshifted character
    testKey({layout:"Greek", keyCode:0, command:1, ctrl:1, chars:"\u0001", unmodifiedChars:"\u03b1"},
            "a");
    // Alt-cmd gives us the shifted character
    testKey({layout:"Greek", keyCode:0, command:1, alt:1, chars:"\u00a8", unmodifiedChars:"\u03b1"},
            "\u00a8");
    testKey({layout:"Greek", keyCode:0, command:1, alt:1, shift:1, chars:"\u00b9", unmodifiedChars:"\u0391"},
            "\u00b9");

    // German (KCHR/KeyTranslate case)
    testKey({layout:"German", keyCode:0, chars:"a", unmodifiedChars:"a"},
            "a");
    testKey({layout:"German", keyCode:33, chars:"\u00fc", unmodifiedChars:"\u00fc"},
            "\u00fc");
    testKey({layout:"German", keyCode:27, chars:"\u00df", unmodifiedChars:"\u00df"},
            "\u00df");
    testKey({layout:"German", keyCode:27, shift:1, chars:"?", unmodifiedChars:"?"},
            "?");
    testKey({layout:"German", keyCode:27, command:1, chars:"\u00df", unmodifiedChars:"\u00df"},
            "\u00df");
    // Shift+SS is '?' but Cmd+Shift+SS is '/' on German layout.
    // XXX this test failed on 10.4
    //testKey({layout:"German", keyCode:27, command:1, shift:1, chars:"/", unmodifiedChars:"?"},
    //        "?");
  }
  
  if (navigator.platform.indexOf("Win") == 0) {
    // On Windows, you can use Spy++ or Winspector (free) to watch window messages.
    // The keyCode is given by the wParam of the last WM_KEYDOWN message. The
    // chars string is given by the wParam of the WM_CHAR message. unmodifiedChars
    // is not needed on Windows.

    // Plain text input
    testKey({layout:"US", keyCode:65, chars:"a"},
            "a");
    testKey({layout:"US", keyCode:66, chars:"b"},
            "b");
    testKey({layout:"US", keyCode:65, shift:1, chars:"A"},
            "A");

    // Ctrl keys
    testKey({layout:"US", keyCode:65, ctrl:1, chars:"\u0001"},
            "a");
    testKey({layout:"US", keyCode:65, ctrl:1, shift:1, chars:"\u0001"},
            "A");

    // Alt keys
    testKey({layout:"US", keyCode:65, alt:1, chars:"a"},
            "a");
    testKey({layout:"US", keyCode:65, alt:1, shift:1, chars:"A"},
            "A");
            
    // Shift-ctrl-alt generates no WM_CHAR, but we still get a keypress
    testKey({layout:"US", keyCode:65, alt:1, ctrl:1, shift:1, chars:""},
            "A");

    // Greek plain text
    testKey({layout:"Greek", keyCode:65, chars:"\u03b1"},
            "\u03b1");
    testKey({layout:"Greek", keyCode:65, shift:1, chars:"\u0391"},
            "\u0391");

    // Greek ctrl keys produce Latin charcodes
    testKey({layout:"Greek", keyCode:65, ctrl:1, chars:"\u0001"},
            "a");
    testKey({layout:"Greek", keyCode:65, ctrl:1, shift:1, chars:"\u0001"},
            "A");
  }

  document.removeEventListener("keypress", onKeyPress, false);
}

// Test the activation (or not) of an HTML accesskey
function runAccessKeyTests()
{
  var button = document.getElementById("button");
  var activationCount;

  function onClick(e)
  {
    ++activationCount;
  }

  // The first parameter is the complete input event. The second and third parameters are
  // what to test against.
  function testKey(aEvent, aAccessKey, aShouldActivate)
  {
    activationCount = 0;
    button.setAttribute("accesskey", aAccessKey);

    synthesizeKey(aEvent, "button");

    var name = eventToString(aEvent);

    is(activationCount, aShouldActivate ? 1 : 0, name + ", activating '" + aAccessKey + "'");
  }

  button.addEventListener("click", onClick, false);
  
  // These tests have to be per-plaform.
  if (navigator.platform.indexOf("Mac") == 0) {
    // Basic sanity checks
    testKey({layout:"US", keyCode:0, chars:"a", unmodifiedChars:"a"},
            "a", false);
    testKey({layout:"US", keyCode:0, ctrl:1, chars:"\u0001", unmodifiedChars:"a"},
            "a", true);
    testKey({layout:"US", keyCode:0, ctrl:1, chars:"\u0001", unmodifiedChars:"a"},
            "A", true);

    // Shift-ctrl does not activate accesskeys
    testKey({layout:"US", keyCode:0, ctrl:1, shift:1, chars:"\u0001", unmodifiedChars:"A"},
            "a", false);
    testKey({layout:"US", keyCode:0, ctrl:1, shift:1, chars:"\u0001", unmodifiedChars:"A"},
            "A", false);
    // Alt-ctrl does not activate accesskeys
    testKey({layout:"US", keyCode:0, ctrl:1, alt:1, chars:"\u0001", unmodifiedChars:"a"},
            "a", false);
    testKey({layout:"US", keyCode:0, ctrl:1, alt:1, chars:"\u0001", unmodifiedChars:"a"},
            "A", false);
            
    // Greek layout can activate a Latin accesskey
    testKey({layout:"Greek", keyCode:0, ctrl:1, chars:"\u0001", unmodifiedChars:"\u03b1"},
            "a", true);
    testKey({layout:"Greek", keyCode:0, ctrl:1, chars:"\u0001", unmodifiedChars:"\u03b1"},
            "A", true);
    // ... and a Greek accesskey!
    testKey({layout:"Greek", keyCode:0, ctrl:1, chars:"\u0001", unmodifiedChars:"\u03b1"},
            "\u03b1", true);
    testKey({layout:"Greek", keyCode:0, ctrl:1, chars:"\u0001", unmodifiedChars:"\u03b1"},
            "\u0391", true);

    // bug 359638
    testKey({layout:"US", keyCode:47, ctrl:1, chars:".", unmodifiedChars:"."},
            ".", true);

    // German (KCHR/KeyTranslate case)
    testKey({layout:"German", keyCode:0, ctrl:1, chars:"a", unmodifiedChars:"a"},
            "a", true);
    testKey({layout:"German", keyCode:0, ctrl:1, chars:"a", unmodifiedChars:"a"},
            "A", true);
    testKey({layout:"German", keyCode:33, ctrl:1, chars:"\u00fc", unmodifiedChars:"\u00fc"},
            "\u00fc", true);
    testKey({layout:"German", keyCode:33, ctrl:1, chars:"\u00fc", unmodifiedChars:"\u00fc"},
            "\u00dc", true);
  }
  
  if (navigator.platform.indexOf("Win") == 0) {
    // Basic sanity checks
    testKey({layout:"US", keyCode:65, chars:"a"},
            "a", false);
    testKey({layout:"US", keyCode:65, shift:1, alt:1, chars:"A"},
            "a", true);
    testKey({layout:"US", keyCode:65, shift:1, alt:1, chars:"A"},
            "A", true);

    // shift-alt-ctrl does not activate accesskeys
    testKey({layout:"US", keyCode:65, ctrl:1, shift:1, alt:1, chars:""},
            "a", false);
    testKey({layout:"US", keyCode:65, ctrl:1, shift:1, alt:1, chars:""},
            "A", false);

    // Greek layout can activate a Latin accesskey
    testKey({layout:"Greek", keyCode:65, shift:1, alt:1, chars:"A"},
            "a", true);
    testKey({layout:"Greek", keyCode:65, shift:1, alt:1, chars:"A"},
            "A", true);
    // ... and a Greek accesskey!
    testKey({layout:"Greek", keyCode:65, shift:1, alt:1, chars:"A"},
            "\u03b1", true);
    testKey({layout:"Greek", keyCode:65, shift:1, alt:1, chars:"A"},
            "\u0391", true);

    // bug 359638
    testKey({layout:"US", keyCode:190, shift:1, alt:1, chars:".", unmodifiedChars:"."},
            ".", true);
  }
  
  button.removeEventListener("click", onClick, false);
}

function runXULKeyTests()
{
  function testKey(aEvent, aElem, aShouldActivate)
  {
    var elem = document.getElementById(aElem);
    elem.activeCount = 0;

    synthesizeKey(aEvent, "button");

    var name = eventToString(aEvent);

    is(elem.activeCount, aShouldActivate ? 1 : 0,
       name + " activating " + aElem);
  }

  if (navigator.platform.indexOf("Mac") == 0) {
    testKey({layout:"US", keyCode:41, command:1, chars:";", unmodifiedChars:";"},
            "unshiftedKey", true);
    testKey({layout:"US", keyCode:41, command:1, chars:";", unmodifiedChars:";"},
            "shiftedKey", false);
    testKey({layout:"US", keyCode:41, command:1, shift:1, chars:";", unmodifiedChars:":"},
            "shiftedKey", true);
    testKey({layout:"US", keyCode:41, command:1, shift:1, chars:";", unmodifiedChars:":"},
            "unshiftedKey", false);
  }
  if (navigator.platform.indexOf("Win") == 0) {
    testKey({layout:"US", keyCode:186, ctrl:1, chars:";"},
            "unshiftedKey", true);
    testKey({layout:"US", keyCode:186, ctrl:1, chars:";"},
            "shiftedKey", false);
    testKey({layout:"US", keyCode:186, ctrl:1, shift:1, chars:";"},
            "shiftedKey", true);
    testKey({layout:"US", keyCode:186, ctrl:1, shift:1, chars:";"},
            "unshiftedKey", false);
  }

  keyElems = ["commandOptionF"];

  // 429160
  if (navigator.platform.indexOf("Mac") == 0) {
    testKey({layout:"US", keyCode:3, command:1, alt:1, chars:"\u0192", unmodifiedChars:"f"},
            "commandOptionF", true);
  }
  if (navigator.platform.indexOf("Win") == 0) {
    testKey({layout:"US", keyCode:70, ctrl:1, alt:1, chars:"\u0006"},
            "commandOptionF", true);
  }
  
  // 432112
  if (navigator.platform.indexOf("Mac") == 0) {
// test currently does not work, getting the Swedish layout fails
//  testKey({layout:"Swedish", keyCode:27, command:1, shift:1, chars:"+", unmodifiedChars:"?"},
//          "question", true);
  }
  if (navigator.platform.indexOf("Win") == 0) {
    testKey({layout:"Swedish", keyCode:187, ctrl:1, shift:1, chars:""},
            "question", true);
    testKey({layout:"Swedish", keyCode:187, ctrl:1, chars:""},
            "question", false);
  }

  // bug 433192
  if (navigator.platform.indexOf("Win") == 0) {
    testKey({layout:"US", keyCode:88, ctrl:1, chars:"\u0018"},
            "unshiftedX", true);
    testKey({layout:"US", keyCode:88, ctrl:1, chars:"\u0018"},
            "shiftedX", false);
    testKey({layout:"US", keyCode:88, ctrl:1, shift:1, chars:"\u0018"},
            "unshiftedX", false);
    testKey({layout:"US", keyCode:88, ctrl:1, shift:1, chars:"\u0018"},
            "shiftedX", true);
    testKey({layout:"Arabic", keyCode:88, ctrl:1, chars:"\u0018"},
            "unshiftedX", true);
    testKey({layout:"Arabic", keyCode:88, ctrl:1, chars:"\u0018"},
            "shiftedX", false);
    testKey({layout:"Arabic", keyCode:88, ctrl:1, shift:1, chars:"\u0018"},
            "unshiftedX", false);
    testKey({layout:"Arabic", keyCode:88, ctrl:1, shift:1, chars:"\u0018"},
            "shiftedX", true);
    testKey({layout:"Hebrew", keyCode:88, ctrl:1, chars:"\u0018"},
            "unshiftedX", true);
    testKey({layout:"Hebrew", keyCode:88, ctrl:1, chars:"\u0018"},
            "shiftedX", false);
    testKey({layout:"Hebrew", keyCode:88, ctrl:1, shift:1, chars:"\u0018"},
            "unshiftedX", false);
    testKey({layout:"Hebrew", keyCode:88, ctrl:1, shift:1, chars:"\u0018"},
            "shiftedX", true);
    testKey({layout:"Japanese", keyCode:187, ctrl:1, chars:""},
            "unshiftedPlus", false);
    testKey({layout:"Japanese", keyCode:187, ctrl:1, shift:1, chars:""},
            "unshiftedPlus", true);
  }
}

function runTextInputTests()
{
  var textbox = document.getElementById("textbox");

  function testKey(aEvent, aExpectText) {
    textbox.value = "";
    textbox.focus();

    synthesizeKey(aEvent, "textbox");

    var name = eventToString(aEvent);

    is(textbox.value, aExpectText, name + " does not input correct text.");
  }

  if (navigator.platform.indexOf("Win") == 0) {
    // Basic sanity checks
    testKey({layout:"US", keyCode:65, chars:"a"},
            "a");
    testKey({layout:"US", keyCode:65, shift:1, chars:"A"},
            "A");
    // When Ctrl+Alt are pressed, any text should not be inputted.
    testKey({layout:"US", keyCode:65, ctrl:1, alt:1, chars:""},
            "");

    // Lithuanian AltGr should be consumed at 9/0 keys pressed
    testKey({layout:"Lithuanian", keyCode:56, chars:"\u016B"},
            "\u016B");
    testKey({layout:"Lithuanian", keyCode:57, chars:"9"},
            "9");
    testKey({layout:"Lithuanian", keyCode:48, chars:"0"},
            "0");
    testKey({layout:"Lithuanian", keyCode:56, ctrl:1, alt:1, chars:"8"},
            "8");
    testKey({layout:"Lithuanian", keyCode:57, ctrl:1, alt:1, chars:"9"},
            "9");
    testKey({layout:"Lithuanian", keyCode:48, ctrl:1, alt:1, chars:"0"},
            "0");
  }
}

function runTest()
{
  runPressTests();
  runAccessKeyTests();
  runXULKeyTests();
  runTextInputTests();
  SimpleTest.finish();
}

]]>
</script>

</window>