зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset de4929e39b7e (bug 1351148)
This commit is contained in:
Родитель
5d5578ad36
Коммит
665fb7cd54
|
@ -113,7 +113,7 @@ function* respondsToMoveEvents(helper, testActor) {
|
|||
yield mouse.move(x, y);
|
||||
} else if (type === "keyboard") {
|
||||
let options = shift ? {shiftKey: true} : {};
|
||||
yield EventUtils.synthesizeAndWaitKey(key, options);
|
||||
yield EventUtils.synthesizeKey(key, options);
|
||||
}
|
||||
yield checkPosition(expected, helper);
|
||||
}
|
||||
|
@ -128,14 +128,14 @@ function* checkPosition({x, y}, {getElementAttribute}) {
|
|||
function* respondsToReturnAndEscape({isElementHidden, show}) {
|
||||
info("Simulating return to select the color and hide the eyedropper");
|
||||
|
||||
yield EventUtils.synthesizeAndWaitKey("VK_RETURN", {});
|
||||
yield EventUtils.synthesizeKey("VK_RETURN", {});
|
||||
let hidden = yield isElementHidden("root");
|
||||
ok(hidden, "The eyedropper has been hidden");
|
||||
|
||||
info("Showing the eyedropper again and simulating escape to hide it");
|
||||
|
||||
yield show("html");
|
||||
yield EventUtils.synthesizeAndWaitKey("VK_ESCAPE", {});
|
||||
yield EventUtils.synthesizeKey("VK_ESCAPE", {});
|
||||
hidden = yield isElementHidden("root");
|
||||
ok(hidden, "The eyedropper has been hidden again");
|
||||
}
|
||||
|
|
|
@ -18,14 +18,14 @@ add_task(async function() {
|
|||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
|
||||
let browser = tab.linkedBrowser;
|
||||
|
||||
await EventUtils.synthesizeAndWaitKey("d", { code: "KeyD", repeat: 3 });
|
||||
EventUtils.synthesizeKey("d", { code: "KeyD", repeat: 3 });
|
||||
|
||||
await ContentTask.spawn(browser, null, async function() {
|
||||
is(content.document.body.getAttribute("data-down"), "2", "Correct number of events");
|
||||
is(content.document.body.getAttribute("data-press"), "2", "Correct number of events");
|
||||
});
|
||||
|
||||
await EventUtils.synthesizeAndWaitKey("p", { code: "KeyP", repeat: 3 });
|
||||
EventUtils.synthesizeKey("p", { code: "KeyP", repeat: 3 });
|
||||
|
||||
await ContentTask.spawn(browser, null, async function() {
|
||||
is(content.document.body.getAttribute("data-down"), "4", "Correct number of events");
|
||||
|
|
|
@ -43,10 +43,11 @@ add_task(async function() {
|
|||
// but in non-e10s it is handled by the browser UI code and hence won't
|
||||
// reach the web page. As a result, we need to observe the event in
|
||||
// the content process only in e10s mode.
|
||||
if (gMultiProcessBrowser) {
|
||||
return EventUtils.synthesizeAndWaitKey("x", {accelKey: true, shiftKey: true});
|
||||
}
|
||||
var waitForKeypressContent = BrowserTestUtils.waitForContentEvent(aBrowser, "keypress");
|
||||
EventUtils.synthesizeKey("x", {accelKey: true, shiftKey: true});
|
||||
if (gMultiProcessBrowser) {
|
||||
return waitForKeypressContent;
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
|
|
|
@ -678,44 +678,6 @@ function synthesizeNativeMouseMove(aTarget, aOffsetX, aOffsetY, aCallback, aWind
|
|||
utils.sendNativeMouseMove(x * scale, y * scale, null, observer);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a wrapper around synthesizeNativeMouseMove that waits for the mouse
|
||||
* event to be dispatched to the target content.
|
||||
*
|
||||
* This API is supposed to be used in those test cases that synthesize some
|
||||
* input events to chrome process and have some checks in content.
|
||||
*/
|
||||
function synthesizeAndWaitNativeMouseMove(aTarget, aOffsetX, aOffsetY,
|
||||
aCallback, aWindow = window) {
|
||||
let browser = gBrowser.selectedTab.linkedBrowser;
|
||||
let mm = browser.messageManager;
|
||||
let ContentTask =
|
||||
_EU_Cu.import("resource://testing-common/ContentTask.jsm", null).ContentTask;
|
||||
|
||||
let eventRegisteredPromise = new Promise(resolve => {
|
||||
mm.addMessageListener("Test:MouseMoveRegistered", function processed(message) {
|
||||
mm.removeMessageListener("Test:MouseMoveRegistered", processed);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
let eventReceivedPromise = ContentTask.spawn(browser, [aOffsetX, aOffsetY],
|
||||
([clientX, clientY]) => {
|
||||
return new Promise(resolve => {
|
||||
addEventListener("mousemove", function onMouseMoveEvent(e) {
|
||||
if (e.clientX == clientX && e.clientY == clientY) {
|
||||
removeEventListener("mousemove", onMouseMoveEvent);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
sendAsyncMessage("Test:MouseMoveRegistered");
|
||||
});
|
||||
});
|
||||
eventRegisteredPromise.then(() => {
|
||||
synthesizeNativeMouseMove(aTarget, aOffsetX, aOffsetY, null, aWindow);
|
||||
});
|
||||
return eventReceivedPromise;
|
||||
}
|
||||
|
||||
function _computeKeyCodeFromChar(aChar)
|
||||
{
|
||||
if (aChar.length != 1) {
|
||||
|
@ -867,51 +829,6 @@ function synthesizeKey(aKey, aEvent, aWindow = window, aCallback)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a wrapper around synthesizeKey that waits for the key event to be
|
||||
* dispatched to the target content. It returns a promise which is resolved
|
||||
* when the content receives the key event.
|
||||
*
|
||||
* This API is supposed to be used in those test cases that synthesize some
|
||||
* input events to chrome process and have some checks in content.
|
||||
*/
|
||||
function synthesizeAndWaitKey(aKey, aEvent, aWindow = window,
|
||||
checkBeforeSynthesize, checkAfterSynthesize)
|
||||
{
|
||||
let browser = gBrowser.selectedTab.linkedBrowser;
|
||||
let mm = browser.messageManager;
|
||||
let keyCode = _createKeyboardEventDictionary(aKey, aEvent, aWindow).dictionary.keyCode;
|
||||
let ContentTask = _EU_Cu.import("resource://testing-common/ContentTask.jsm", null).ContentTask;
|
||||
|
||||
let keyRegisteredPromise = new Promise(resolve => {
|
||||
mm.addMessageListener("Test:KeyRegistered", function processed(message) {
|
||||
mm.removeMessageListener("Test:KeyRegistered", processed);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
let keyReceivedPromise = ContentTask.spawn(browser, keyCode, (keyCode) => {
|
||||
return new Promise(resolve => {
|
||||
addEventListener("keyup", function onKeyEvent(e) {
|
||||
if (e.keyCode == keyCode) {
|
||||
removeEventListener("keyup", onKeyEvent);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
sendAsyncMessage("Test:KeyRegistered");
|
||||
});
|
||||
});
|
||||
keyRegisteredPromise.then(() => {
|
||||
if (checkBeforeSynthesize) {
|
||||
checkBeforeSynthesize();
|
||||
}
|
||||
synthesizeKey(aKey, aEvent, aWindow);
|
||||
if (checkAfterSynthesize) {
|
||||
checkAfterSynthesize();
|
||||
}
|
||||
});
|
||||
return keyReceivedPromise;
|
||||
}
|
||||
|
||||
function _parseNativeModifiers(aModifiers, aWindow = window)
|
||||
{
|
||||
var navigator = _getNavigator(aWindow);
|
||||
|
|
|
@ -34,7 +34,9 @@ async function do_test(test) {
|
|||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
|
||||
|
||||
info("Moving mouse out of the way.");
|
||||
await EventUtils.synthesizeAndWaitNativeMouseMove(tab.linkedBrowser, 300, 300);
|
||||
await new Promise(resolve => {
|
||||
EventUtils.synthesizeNativeMouseMove(tab.linkedBrowser, 300, 300, resolve);
|
||||
});
|
||||
|
||||
info("creating input field");
|
||||
await ContentTask.spawn(tab.linkedBrowser, test, async function(test) {
|
||||
|
@ -90,11 +92,15 @@ async function do_test(test) {
|
|||
}, {once: true});
|
||||
});
|
||||
info("Initial mouse move");
|
||||
await EventUtils.synthesizeAndWaitNativeMouseMove(tab.linkedBrowser, 50, 5);
|
||||
await new Promise(resolve => {
|
||||
EventUtils.synthesizeNativeMouseMove(tab.linkedBrowser, 50, 5, resolve);
|
||||
});
|
||||
info("Waiting");
|
||||
await new Promise(resolve => setTimeout(resolve, 400));
|
||||
info("Second mouse move");
|
||||
await EventUtils.synthesizeAndWaitNativeMouseMove(tab.linkedBrowser, 70, 5);
|
||||
await new Promise(resolve => {
|
||||
EventUtils.synthesizeNativeMouseMove(tab.linkedBrowser, 70, 5, resolve);
|
||||
});
|
||||
info("Waiting for tooltip to open");
|
||||
let tooltip = await awaitTooltipOpen;
|
||||
|
||||
|
|
|
@ -175,11 +175,7 @@ add_task(async function() {
|
|||
let findBar = gFindBar;
|
||||
let initialValue = findBar._findField.value;
|
||||
|
||||
await EventUtils.synthesizeAndWaitKey("f", { accelKey: true }, window, null,
|
||||
() => {
|
||||
isnot(document.activeElement, findBar._findField.inputField,
|
||||
"findbar is not yet focused");
|
||||
});
|
||||
EventUtils.synthesizeKey("f", { accelKey: true }, window);
|
||||
|
||||
let promises = [
|
||||
BrowserTestUtils.sendChar("a", browser),
|
||||
|
@ -187,6 +183,8 @@ add_task(async function() {
|
|||
BrowserTestUtils.sendChar("c", browser)
|
||||
];
|
||||
|
||||
isnot(document.activeElement, findBar._findField.inputField,
|
||||
"findbar is not yet focused");
|
||||
is(findBar._findField.value, initialValue, "still has initial find query");
|
||||
|
||||
await Promise.all(promises);
|
||||
|
|
|
@ -100,16 +100,6 @@ function onEvent(aEvent)
|
|||
setTimeout(gCallback, 0);
|
||||
}
|
||||
|
||||
function observeKeyUpOnContent(aKeyCode, aCallback)
|
||||
{
|
||||
document.addEventListener("keyup", function keyUp(ev) {
|
||||
if (ev.keyCode == aKeyCode) {
|
||||
document.removeEventListener("keyup", keyUp);
|
||||
SimpleTest.executeSoon(aCallback);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const kTests = [
|
||||
{ description: "InternalScrollPortEvent (overflow, vertical)",
|
||||
targetID: "scrollable-div", eventType: "overflow",
|
||||
|
@ -160,8 +150,6 @@ const kTests = [
|
|||
document.getElementById(this.targetID).focus();
|
||||
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, kIsWin ? WIN_VK_A : MAC_VK_ANSI_A,
|
||||
{}, "a", "a");
|
||||
observeKeyUpOnContent(KeyboardEvent.DOM_VK_A, runNextTest);
|
||||
return true;
|
||||
},
|
||||
canRun: function () {
|
||||
return (kIsMac || kIsWin);
|
||||
|
@ -175,8 +163,6 @@ const kTests = [
|
|||
document.getElementById(this.targetID).focus();
|
||||
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, kIsWin ? WIN_VK_A : MAC_VK_ANSI_A,
|
||||
{}, "a", "a");
|
||||
observeKeyUpOnContent(KeyboardEvent.DOM_VK_A, runNextTest);
|
||||
return true;
|
||||
},
|
||||
canRun: function () {
|
||||
return (kIsMac || kIsWin);
|
||||
|
@ -190,8 +176,6 @@ const kTests = [
|
|||
document.getElementById(this.targetID).focus();
|
||||
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, kIsWin ? WIN_VK_B : MAC_VK_ANSI_B,
|
||||
{ shiftKey: true }, "B", "B");
|
||||
observeKeyUpOnContent(KeyboardEvent.DOM_VK_B, runNextTest);
|
||||
return true;
|
||||
},
|
||||
canRun: function () {
|
||||
return (kIsMac || kIsWin);
|
||||
|
@ -205,14 +189,6 @@ const kTests = [
|
|||
document.getElementById(this.targetID).focus();
|
||||
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, kIsWin ? WIN_VK_C : MAC_VK_ANSI_C,
|
||||
{ accelKey: true }, kIsWin ? "\u0003" : "c", "c");
|
||||
|
||||
// On Windows, synthesizeNativeKey will also fire keyup for accelKey
|
||||
// (control key on Windows). We have to wait for it to prevent the key
|
||||
// event break the next test case.
|
||||
let waitKeyCode = _EU_isWin(window) ? KeyboardEvent.DOM_VK_CONTROL :
|
||||
KeyboardEvent.DOM_VK_C;
|
||||
observeKeyUpOnContent(waitKeyCode, runNextTest);
|
||||
return true;
|
||||
},
|
||||
canRun: function () {
|
||||
return (kIsMac || kIsWin);
|
||||
|
@ -349,8 +325,6 @@ const kTests = [
|
|||
document.getElementById(this.targetID).focus();
|
||||
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, kIsWin ? WIN_VK_B : MAC_VK_ANSI_B,
|
||||
{ shiftKey: true }, "B", "B");
|
||||
observeKeyUpOnContent(KeyboardEvent.DOM_VK_B, runNextTest);
|
||||
return true;
|
||||
},
|
||||
canRun: function () {
|
||||
return (kIsMac || kIsWin);
|
||||
|
|
Загрузка…
Ссылка в новой задаче