widget/tests/test_plugin_input_event.html

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <title>Test for plugin input event</title>
michael@0 5 <script type="text/javascript"
michael@0 6 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 7 <script type="text/javascript"
michael@0 8 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
michael@0 9 <script type="text/javascript"
michael@0 10 src="chrome://mochikit/content/tests/SimpleTest/NativeKeyCodes.js"></script>
michael@0 11 <link rel="stylesheet" type="text/css"
michael@0 12 href="chrome://mochikit/content/tests/SimpleTest/test.css" />
michael@0 13 </head>
michael@0 14 <body>
michael@0 15 <script type="application/javascript">
michael@0 16 var pluginHost = SpecialPowers.Cc["@mozilla.org/plugin/host;1"]
michael@0 17 .getService(SpecialPowers.Ci.nsIPluginHost);
michael@0 18 var pluginTags = pluginHost.getPluginTags();
michael@0 19 for (var tag of pluginTags) {
michael@0 20 if (tag.name == "Test Plug-in") {
michael@0 21 tag.enabledState = SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED;;
michael@0 22 }
michael@0 23 }
michael@0 24 </script>
michael@0 25
michael@0 26 <p id="display">
michael@0 27 <embed id="plugin" type="application/x-test" wmode="opaque">
michael@0 28 </p>
michael@0 29 <div id="content" style="display: none">
michael@0 30
michael@0 31 </div>
michael@0 32 <pre id="test">
michael@0 33 </pre>
michael@0 34
michael@0 35 <script type="application/javascript">
michael@0 36 SimpleTest.waitForExplicitFinish();
michael@0 37
michael@0 38 var gPlugin = document.getElementById("plugin");
michael@0 39
michael@0 40 var gUtils = window.
michael@0 41 QueryInterface(Components.interfaces.nsIInterfaceRequestor).
michael@0 42 getInterface(Components.interfaces.nsIDOMWindowUtils);
michael@0 43
michael@0 44 function doTest() {
michael@0 45 gPlugin.focus();
michael@0 46
michael@0 47 is(gUtils.IMEStatus, gUtils.IME_STATUS_PLUGIN,
michael@0 48 "Plugin failed to get focus");
michael@0 49
michael@0 50 is(gPlugin.getLastKeyText(), "", "Must be empty before first key test");
michael@0 51
michael@0 52 synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, WIN_VK_A, {}, "a", "a");
michael@0 53 is(gPlugin.getLastKeyText(), "a", "Invalid character was inputted");
michael@0 54
michael@0 55 synthesizeNativeKey(KEYBOARD_LAYOUT_GERMAN, WIN_VK_OEM_PLUS, {}, "+", "+");
michael@0 56 is(gPlugin.getLastKeyText(), "+", "Invalid character was inputted");
michael@0 57
michael@0 58 synthesizeNativeKey(KEYBOARD_LAYOUT_GERMAN, WIN_VK_OEM_PLUS, {altGrKey:1}, "~", "+");
michael@0 59 is(gPlugin.getLastKeyText(), "~", "Invalid character was inputted");
michael@0 60
michael@0 61 SimpleTest.finish();
michael@0 62 }
michael@0 63
michael@0 64 SimpleTest.waitForFocus(doTest);
michael@0 65
michael@0 66 </script>
michael@0 67 </body>
michael@0 68 </html>

mercurial