widget/tests/test_plugin_input_event.html
author Mike Hommey <mh+mozilla@glandium.org>
Fri, 11 Jan 2019 16:01:15 +0000
changeset 453570 daf50f25895db073e44d50fecf2e4f6fe873865d
parent 428244 d2df9ae93b11d29cb471fbecdf9616c277a27dd2
child 459392 0e0638c8ef27dea641754aae390213e829eb71f3
permissions -rw-r--r--
Bug 1519307 - Add a new project to build useful parts of breakpad independently. r=froydnj With `ac_add_options --enable-project=tools/crashreporter` in a mozconfig, `./mach build` builds minidump_stackwalk, dump_syms and fileid. One caveat is that due to limitation in how the build system works currently, it's cumbersome to keep dump_syms as a host program for Gecko, and to make it a target program for this project. For now, keep it as a host program. We're not going to use it on automation, but it's still convenient to have for quick local builds (I've had to resort to awful hacks downstream). Differential Revision: https://phabricator.services.mozilla.com/D16299

<!DOCTYPE HTML>
<html>
<head>
  <title>Test for plugin input event</title>
  <script type="text/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
  <script type="text/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/NativeKeyCodes.js"></script>
  <script type="text/javascript" src="utils.js"></script>
  <link rel="stylesheet" type="text/css"
          href="chrome://mochikit/content/tests/SimpleTest/test.css" />
</head>
<body>
<script type="application/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
</script>

<p id="display">
  <embed id="plugin" type="application/x-test" wmode="opaque">
</p>
<div id="content" style="display: none">

</div>
<pre id="test">
</pre>

<script type="application/javascript">
SimpleTest.waitForExplicitFinish();

var gPlugin = document.getElementById("plugin");

var gUtils = window.windowUtils;

function* doTest() {
  gPlugin.focus();

  is(gUtils.IMEStatus, gUtils.IME_STATUS_PLUGIN,
     "Plugin failed to get focus");

  is(gPlugin.getLastKeyText(), "", "Must be empty before first key test");

  yield synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, WIN_VK_A, {}, "a", "a", continueTest);
  is(gPlugin.getLastKeyText(), "a", "Invalid character was inputted");

  yield synthesizeNativeKey(KEYBOARD_LAYOUT_GERMAN, WIN_VK_OEM_PLUS, {}, "+", "+", continueTest);
  is(gPlugin.getLastKeyText(), "+", "Invalid character was inputted");

  yield synthesizeNativeKey(KEYBOARD_LAYOUT_GERMAN, WIN_VK_OEM_PLUS, {altGrKey:1}, "~", "+", continueTest);
  is(gPlugin.getLastKeyText(), "~", "Invalid character was inputted");
}

var gTestContinuation = null;

function continueTest() {
  if (!gTestContinuation) {
    gTestContinuation = doTest(continueTest);
  }
  var ret = gTestContinuation.next();
  if (ret.done) {
    SimpleTest.finish();
  } else {
    is(ret.value, true, "Key synthesized successfully");
  }
}

SimpleTest.waitForFocus(continueTest);

</script>
</body>
</html>