mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 947115 All tests shouldn't use nsIDOMWindowUtils.sendNativeKeyEvent() directly. Use synthesizeNativeKey() instead. r=smaug
This commit is contained in:
parent
013f2630d9
commit
04cc04ac24
@ -561,23 +561,6 @@ function waitForObserver(aObsEvent, aTimeoutMs) {
|
||||
* generating os level input events that get processed by widget and
|
||||
* apzc logic.
|
||||
*===========================================================================*/
|
||||
|
||||
// Keyboard layouts for use with synthesizeNativeKey
|
||||
const usEnglish = 0x409;
|
||||
const arSpanish = 0x2C0A;
|
||||
|
||||
// Modifiers for use with synthesizeNativeKey
|
||||
const leftShift = 0x100;
|
||||
const rightShift = 0x200;
|
||||
const leftControl = 0x400;
|
||||
const rightControl = 0x800;
|
||||
const leftAlt = 0x1000;
|
||||
const rightAlt = 0x2000;
|
||||
|
||||
function synthesizeNativeKey(aKbLayout, aVKey, aModifiers) {
|
||||
Browser.windowUtils.sendNativeKeyEvent(aKbLayout, aVKey, aModifiers, '', '');
|
||||
}
|
||||
|
||||
function synthesizeNativeMouse(aElement, aOffsetX, aOffsetY, aMsg) {
|
||||
let x = aOffsetX;
|
||||
let y = aOffsetY;
|
||||
|
@ -38,8 +38,7 @@ function runNextTest() {
|
||||
win.onunload = function() {
|
||||
didClose = true;
|
||||
}
|
||||
var utils = SpecialPowers.getDOMWindowUtils(win);
|
||||
utils.sendNativeKeyEvent(0, MAC_VK_ANSI_W, 0x4000 /* cmd */, "w", "w");
|
||||
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_W, {metaKey:1}, "w", "w");
|
||||
|
||||
setTimeout(function () {
|
||||
ok(didClose, "Cmd+W should have closed the tab");
|
||||
|
@ -620,10 +620,47 @@ function _parseNativeModifiers(aModifiers)
|
||||
modifiers |=
|
||||
(navigator.platform.indexOf("Mac") == 0) ? 0x00008000 : 0x00000800;
|
||||
}
|
||||
if (aModifiers.altGrKey) {
|
||||
modifiers |=
|
||||
(navigator.platform.indexOf("Win") == 0) ? 0x00002800 : 0x00001000;
|
||||
}
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
const KEYBOARD_LAYOUT_EN_US = 0;
|
||||
// Mac: Any unused number is okay for adding new keyboard layout.
|
||||
// When you add new keyboard layout here, you need to modify
|
||||
// TISInputSourceWrapper::InitByLayoutID().
|
||||
// Win: These constants can be found by inspecting registry keys under
|
||||
// HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Keyboard Layouts
|
||||
|
||||
const KEYBOARD_LAYOUT_ARABIC =
|
||||
{ name: "Arabic", Mac: 6, Win: 0x00000401 };
|
||||
const KEYBOARD_LAYOUT_BRAZILIAN_ABNT =
|
||||
{ name: "Brazilian ABNT", Mac: null, Win: 0x00000416 };
|
||||
const KEYBOARD_LAYOUT_DVORAK_QWERTY =
|
||||
{ name: "Dvorak-QWERTY", Mac: 4, Win: null };
|
||||
const KEYBOARD_LAYOUT_EN_US =
|
||||
{ name: "US", Mac: 0, Win: 0x00000409 };
|
||||
const KEYBOARD_LAYOUT_FRENCH =
|
||||
{ name: "French", Mac: 7, Win: 0x0000040C };
|
||||
const KEYBOARD_LAYOUT_GREEK =
|
||||
{ name: "Greek", Mac: 1, Win: 0x00000408 };
|
||||
const KEYBOARD_LAYOUT_GERMAN =
|
||||
{ name: "German", Mac: 2, Win: 0x00000407 };
|
||||
const KEYBOARD_LAYOUT_HEBREW =
|
||||
{ name: "Hebrew", Mac: 8, Win: 0x0000040D };
|
||||
const KEYBOARD_LAYOUT_JAPANESE =
|
||||
{ name: "Japanese", Mac: null, Win: 0x00000411 };
|
||||
const KEYBOARD_LAYOUT_LITHUANIAN =
|
||||
{ name: "Lithuanian", Mac: 9, Win: 0x00010427 };
|
||||
const KEYBOARD_LAYOUT_NORWEGIAN =
|
||||
{ name: "Norwegian", Mac: 10, Win: 0x00000414 };
|
||||
const KEYBOARD_LAYOUT_SPANISH =
|
||||
{ name: "Spanish", Mac: 11, Win: 0x0000040A };
|
||||
const KEYBOARD_LAYOUT_SWEDISH =
|
||||
{ name: "Swedish", Mac: 3, Win: 0x0000041D };
|
||||
const KEYBOARD_LAYOUT_THAI =
|
||||
{ name: "Thai", Mac: 5, Win: 0x0002041E };
|
||||
|
||||
/**
|
||||
* synthesizeNativeKey() dispatches native key event on active window.
|
||||
@ -651,24 +688,13 @@ function synthesizeNativeKey(aKeyboardLayout, aNativeKeyCode, aModifiers,
|
||||
if (!utils) {
|
||||
return false;
|
||||
}
|
||||
var nativeKeyboardLayout;
|
||||
var nativeKeyboardLayout = null;
|
||||
if (navigator.platform.indexOf("Mac") == 0) {
|
||||
switch (aKeyboardLayout) {
|
||||
case KEYBOARD_LAYOUT_EN_US:
|
||||
nativeKeyboardLayout = 0;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
nativeKeyboardLayout = aKeyboardLayout.Mac;
|
||||
} else if (navigator.platform.indexOf("Win") == 0) {
|
||||
switch (aKeyboardLayout) {
|
||||
case KEYBOARD_LAYOUT_EN_US:
|
||||
nativeKeyboardLayout = 0x409;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
nativeKeyboardLayout = aKeyboardLayout.Win;
|
||||
}
|
||||
if (nativeKeyboardLayout === null) {
|
||||
return false;
|
||||
}
|
||||
utils.sendNativeKeyEvent(nativeKeyboardLayout, aNativeKeyCode,
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* This file defines all virtual keycodes for
|
||||
* nsIDOMWindowUtils.sendNativeKeyEvent()
|
||||
* This file defines all virtual keycodes for synthesizeNativeKey() of
|
||||
* EventUtils.js and nsIDOMWindowUtils.sendNativeKeyEvent().
|
||||
* These values are defined in each platform's SDK or documents.
|
||||
*/
|
||||
|
||||
|
@ -94,6 +94,12 @@ public:
|
||||
* 3: Swedish-Pro
|
||||
* 4: Dvorak-Qwerty Cmd
|
||||
* 5: Thai
|
||||
* 6: Arabic
|
||||
* 7: French
|
||||
* 8: Hebrew
|
||||
* 9: Lithuanian
|
||||
* 10: Norwegian
|
||||
* 11: Spanish
|
||||
* @param aOverrideKeyboard When testing set to TRUE, otherwise, set to
|
||||
* FALSE. When TRUE, we use an ANSI keyboard
|
||||
* instead of the actual keyboard.
|
||||
|
@ -527,6 +527,24 @@ TISInputSourceWrapper::InitByLayoutID(SInt32 aLayoutID,
|
||||
case 5:
|
||||
InitByInputSourceID("com.apple.keylayout.Thai");
|
||||
break;
|
||||
case 6:
|
||||
InitByInputSourceID("com.apple.keylayout.Arabic");
|
||||
break;
|
||||
case 7:
|
||||
InitByInputSourceID("com.apple.keylayout.French");
|
||||
break;
|
||||
case 8:
|
||||
InitByInputSourceID("com.apple.keylayout.Hebrew");
|
||||
break;
|
||||
case 9:
|
||||
InitByInputSourceID("com.apple.keylayout.Lithuanian");
|
||||
break;
|
||||
case 10:
|
||||
InitByInputSourceID("com.apple.keylayout.Norwegian");
|
||||
break;
|
||||
case 11:
|
||||
InitByInputSourceID("com.apple.keylayout.Spanish");
|
||||
break;
|
||||
default:
|
||||
Clear();
|
||||
break;
|
||||
|
@ -26,8 +26,6 @@
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var gUtils;
|
||||
|
||||
var gCmdOptYReceived = false;
|
||||
|
||||
// Look for a cmd-opt-y event.
|
||||
@ -41,8 +39,6 @@
|
||||
}
|
||||
|
||||
function setGlobals() {
|
||||
gUtils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
|
||||
getService(Components.interfaces.nsIWindowMediator);
|
||||
gChromeWindow = wm.getMostRecentWindow("navigator:browser");
|
||||
@ -147,11 +143,11 @@
|
||||
// DebugEventsPlugin v1.01 from bmo bug 441880.
|
||||
|
||||
function synthesizeNativeReturnKey() {
|
||||
gUtils.sendNativeKeyEvent(0, MAC_VK_Return, 0, "\u000a", "\u000a");
|
||||
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_Return, {}, "\u000a", "\u000a");
|
||||
}
|
||||
|
||||
function synthesizeNativeCmdOptY() {
|
||||
gUtils.sendNativeKeyEvent(0, MAC_VK_ANSI_Y, 0x5000, "y", "y");
|
||||
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_Y, {metaKey:1, altKey:1}, "y", "y");
|
||||
}
|
||||
|
||||
]]></script>
|
||||
|
@ -31,24 +31,21 @@
|
||||
|
||||
function runTest()
|
||||
{
|
||||
var domWindowUtils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
|
||||
window.addEventListener("keypress", onKeyPress, false);
|
||||
|
||||
// Test ctrl-tab
|
||||
gKeyPressEventCount = 0;
|
||||
domWindowUtils.sendNativeKeyEvent(0, MAC_VK_Tab, 0x0400, "\t", "\t");
|
||||
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_Tab, {ctrlKey:1}, "\t", "\t");
|
||||
is(gKeyPressEventCount, 1);
|
||||
|
||||
// Test cmd+shift+a
|
||||
gKeyPressEventCount = 0;
|
||||
domWindowUtils.sendNativeKeyEvent(0, MAC_VK_ANSI_A, 0x4000 | 0x0100, "a", "A");
|
||||
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_A, {metaKey:1, shiftKey:1}, "a", "A");
|
||||
is(gKeyPressEventCount, 1);
|
||||
|
||||
// Test cmd-;
|
||||
gKeyPressEventCount = 0;
|
||||
domWindowUtils.sendNativeKeyEvent(0, MAC_VK_ANSI_Semicolon, 0x4000, ";", ";");
|
||||
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_Semicolon, {metaKey:1}, ";", ";");
|
||||
is(gKeyPressEventCount, 1);
|
||||
|
||||
window.removeEventListener("keypress", onKeyPress, false);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -96,24 +96,12 @@
|
||||
<script type="text/javascript;version=1.8">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
let utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
|
||||
let layouts = {
|
||||
"US": 0,
|
||||
"Greek": 1,
|
||||
"German": 2,
|
||||
"Swedish": 3,
|
||||
"Dvorak-Qwerty": 4,
|
||||
"Thai": 5
|
||||
};
|
||||
|
||||
let synthesizedKeys = [];
|
||||
let expectations = [];
|
||||
|
||||
// Move to beginning of line
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_LeftArrow,
|
||||
{ctrl: true}, "\uf702", "\uf702"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_LeftArrow,
|
||||
{ctrlKey: true}, "\uf702", "\uf702"]);
|
||||
expectations.push({
|
||||
editable: [0, 0],
|
||||
textarea: [0, 0],
|
||||
@ -121,8 +109,8 @@
|
||||
});
|
||||
|
||||
// Move to end of line
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_RightArrow,
|
||||
{ctrl: true}, "\uf703", "\uf703"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow,
|
||||
{ctrlKey: true}, "\uf703", "\uf703"]);
|
||||
expectations.push({
|
||||
editable: [73, 73],
|
||||
textarea: [72, 72],
|
||||
@ -130,8 +118,8 @@
|
||||
});
|
||||
|
||||
// Move down
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_ANSI_N,
|
||||
{ctrl: true}, "\u000e", "n"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_N,
|
||||
{ctrlKey: true}, "\u000e", "n"]);
|
||||
expectations.push({
|
||||
editable: [140, 140],
|
||||
textarea: [145, 145],
|
||||
@ -139,8 +127,8 @@
|
||||
});
|
||||
|
||||
// Move to beginning of line
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_LeftArrow,
|
||||
{ctrl: true}, "\uf702", "\uf702"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_LeftArrow,
|
||||
{ctrlKey: true}, "\uf702", "\uf702"]);
|
||||
expectations.push({
|
||||
editable: [73, 73],
|
||||
textarea: [73, 73],
|
||||
@ -148,8 +136,8 @@
|
||||
});
|
||||
|
||||
// Move word right and modify selection
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_RightArrow,
|
||||
{alt: true, shift: true}, "\uf703", "\uf703"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow,
|
||||
{altKey: true, shiftKey: true}, "\uf703", "\uf703"]);
|
||||
expectations.push({
|
||||
editable: [73, 84],
|
||||
textarea: [73, 90],
|
||||
@ -157,8 +145,8 @@
|
||||
});
|
||||
|
||||
// Move word right
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_RightArrow,
|
||||
{alt: true}, "\uf703", "\uf703"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow,
|
||||
{altKey: true}, "\uf703", "\uf703"]);
|
||||
expectations.push({
|
||||
editable: [84, 84],
|
||||
textarea: [90, 90],
|
||||
@ -166,8 +154,8 @@
|
||||
});
|
||||
|
||||
// Move word right
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_RightArrow,
|
||||
{alt: true}, "\uf703", "\uf703"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow,
|
||||
{altKey: true}, "\uf703", "\uf703"]);
|
||||
expectations.push({
|
||||
editable: [89, 89],
|
||||
textarea: [95, 95],
|
||||
@ -175,8 +163,8 @@
|
||||
});
|
||||
|
||||
// Move down and modify selection
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_DownArrow,
|
||||
{shift: true}, "\uf701", "\uf701"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_DownArrow,
|
||||
{shiftKey: true}, "\uf701", "\uf701"]);
|
||||
expectations.push({
|
||||
editable: [89, 171],
|
||||
textarea: [95, 175],
|
||||
@ -184,8 +172,8 @@
|
||||
});
|
||||
|
||||
// Move backward and modify selection
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_ANSI_B,
|
||||
{ctrl: true, shift: true}, "\u0002", "B"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_B,
|
||||
{ctrlKey: true, shiftKey: true}, "\u0002", "B"]);
|
||||
expectations.push({
|
||||
editable: [89, 170],
|
||||
textarea: [95, 174],
|
||||
@ -193,8 +181,8 @@
|
||||
});
|
||||
|
||||
// Delete forward
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_ANSI_D,
|
||||
{ctrl: true}, "\u0004", "d"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_D,
|
||||
{ctrlKey: true}, "\u0004", "d"]);
|
||||
expectations.push({
|
||||
editable: [89, 89],
|
||||
textarea: [95, 95],
|
||||
@ -202,8 +190,8 @@
|
||||
});
|
||||
|
||||
// Delete backward
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_ANSI_H,
|
||||
{ctrl: true}, "\u0008", "h"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_H,
|
||||
{ctrlKey: true}, "\u0008", "h"]);
|
||||
expectations.push({
|
||||
editable: [88, 88],
|
||||
textarea: [94, 94],
|
||||
@ -211,8 +199,8 @@
|
||||
});
|
||||
|
||||
// Move backward
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_ANSI_B,
|
||||
{ctrl: true}, "\u0002", "b"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_B,
|
||||
{ctrlKey: true}, "\u0002", "b"]);
|
||||
expectations.push({
|
||||
editable: [87, 87],
|
||||
textarea: [93, 93],
|
||||
@ -220,8 +208,8 @@
|
||||
});
|
||||
|
||||
// Move to beginning of paragraph (line for now)
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_ANSI_A,
|
||||
{ctrl: true}, "\u0001", "a"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_A,
|
||||
{ctrlKey: true}, "\u0001", "a"]);
|
||||
expectations.push({
|
||||
editable: [73, 73],
|
||||
textarea: [73, 73],
|
||||
@ -229,8 +217,8 @@
|
||||
});
|
||||
|
||||
// Move forward
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_ANSI_F,
|
||||
{ctrl: true}, "\u0006", "f"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_F,
|
||||
{ctrlKey: true}, "\u0006", "f"]);
|
||||
expectations.push({
|
||||
editable: [74, 74],
|
||||
textarea: [74, 74],
|
||||
@ -238,8 +226,8 @@
|
||||
});
|
||||
|
||||
// Move word right
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_RightArrow,
|
||||
{alt: true}, "\uf703", "\uf703"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow,
|
||||
{altKey: true}, "\uf703", "\uf703"]);
|
||||
expectations.push({
|
||||
editable: [84, 84],
|
||||
textarea: [90, 90],
|
||||
@ -247,8 +235,8 @@
|
||||
});
|
||||
|
||||
// Move word right
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_RightArrow,
|
||||
{alt: true}, "\uf703", "\uf703"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow,
|
||||
{altKey: true}, "\uf703", "\uf703"]);
|
||||
expectations.push({
|
||||
editable: [88, 88],
|
||||
textarea: [94, 94],
|
||||
@ -256,8 +244,8 @@
|
||||
});
|
||||
|
||||
// Delete to end of paragraph (line for now)
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_ANSI_K,
|
||||
{ctrl: true}, "\u000b", "k"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_K,
|
||||
{ctrlKey: true}, "\u000b", "k"]);
|
||||
expectations.push({
|
||||
editable: [88, 88],
|
||||
textarea: [94, 94],
|
||||
@ -265,8 +253,8 @@
|
||||
});
|
||||
|
||||
// Move backward and modify selection
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_ANSI_B,
|
||||
{ctrl: true, shift: true}, "\u0002", "B"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_B,
|
||||
{ctrlKey: true, shiftKey: true}, "\u0002", "B"]);
|
||||
expectations.push({
|
||||
editable: [88, 87],
|
||||
textarea: [93, 94],
|
||||
@ -274,8 +262,8 @@
|
||||
});
|
||||
|
||||
// Move to end of paragraph (line for now)
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_ANSI_E,
|
||||
{ctrl: true}, "\u0005", "e"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_E,
|
||||
{ctrlKey: true}, "\u0005", "e"]);
|
||||
expectations.push({
|
||||
editable: [144, 144],
|
||||
textarea: [94, 94],
|
||||
@ -283,36 +271,14 @@
|
||||
});
|
||||
|
||||
// Move up
|
||||
synthesizedKeys.push([layouts.US, MAC_VK_ANSI_P,
|
||||
{ctrl: true}, "\u0010", "p"]);
|
||||
synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_P,
|
||||
{ctrlKey: true}, "\u0010", "p"]);
|
||||
expectations.push({
|
||||
editable: [73, 73],
|
||||
textarea: [21, 21],
|
||||
input: [0, 0]
|
||||
});
|
||||
|
||||
function synthesizeNativeKey(aLayout, aKeyCode, aModifiers, aSystemChars,
|
||||
aSystemUnmodifiedChars)
|
||||
{
|
||||
let 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.commandRight) modifiers |= 0x8000;
|
||||
if (aModifiers.help) modifiers |= 0x10000;
|
||||
if (aModifiers.function) modifiers |= 0x100000;
|
||||
if (aModifiers.numericKeyPad) modifiers |= 0x01000000;
|
||||
|
||||
utils.sendNativeKeyEvent(aLayout, aKeyCode, modifiers,
|
||||
aSystemChars, aSystemUnmodifiedChars);
|
||||
}
|
||||
|
||||
function checkWindowSelection(aElement, aSelection)
|
||||
{
|
||||
let selection = window.getSelection();
|
||||
|
@ -49,19 +49,13 @@ function doTest() {
|
||||
|
||||
is(gPlugin.getLastKeyText(), "", "Must be empty before first key test");
|
||||
|
||||
gUtils.sendNativeKeyEvent(0x409 /* US */,
|
||||
WIN_VK_A, 0,
|
||||
"a", "a");
|
||||
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, WIN_VK_A, {}, "a", "a");
|
||||
is(gPlugin.getLastKeyText(), "a", "Invalid character was inputted");
|
||||
|
||||
gUtils.sendNativeKeyEvent(0x407 /* German */,
|
||||
WIN_VK_OEM_PLUS, 0,
|
||||
"+", "+");
|
||||
synthesizeNativeKey(KEYBOARD_LAYOUT_GERMAN, WIN_VK_OEM_PLUS, {}, "+", "+");
|
||||
is(gPlugin.getLastKeyText(), "+", "Invalid character was inputted");
|
||||
|
||||
gUtils.sendNativeKeyEvent(0x407 /* German */,
|
||||
WIN_VK_OEM_PLUS, 0x1400 /* Ctrl + Alt (AltGr) */,
|
||||
"~", "+");
|
||||
synthesizeNativeKey(KEYBOARD_LAYOUT_GERMAN, WIN_VK_OEM_PLUS, {altGrKey:1}, "~", "+");
|
||||
is(gPlugin.getLastKeyText(), "~", "Invalid character was inputted");
|
||||
|
||||
SimpleTest.finish();
|
||||
|
@ -36,8 +36,7 @@
|
||||
|
||||
function sendAKeyEvent()
|
||||
{
|
||||
SpecialPowers.getDOMWindowUtils(window)
|
||||
.sendNativeKeyEvent(0, MAC_VK_ANSI_A, 0, "a", "a");
|
||||
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_A, {}, "a", "a");
|
||||
}
|
||||
|
||||
function isFocused(aElement)
|
||||
|
Loading…
Reference in New Issue
Block a user