When eKeyPress event is dispatched from TabParent to a remote process, it should store edit command for all editor types. Then, copied WidgetKeyboardEvent in the remote process doesn't need to request the edit commands when its ExecuteEditCommands() is called. Note that this patch also changes a automated test, browser_bug1316330.js, that uses nsIDOMWindowUtils.dispatchDOMEventViaPresShell() to dispatch repeated keyboard events in the tab. However, it should use synthesizeKey() to emulate everything of native keyboard events and the API can dispatch repeated keyboard events too. (And the test has a bug. It tries to wait 0.5 sec when every keydown or keypress event. However, it fails since startTime is never initialized. This patch fixes this bug too.) MozReview-Commit-ID: IYhyxqH3Ch8
37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
const URL =
|
|
"data:text/html,<script>" +
|
|
"window.focus();" +
|
|
"var down = 0; var press = 0;" +
|
|
"onkeydown = function(e) {" +
|
|
" var startTime = Date.now();" +
|
|
" document.body.setAttribute('data-down', ++down);" +
|
|
" if (e.keyCode == KeyboardEvent.DOM_VK_D) while (Date.now() - startTime < 500) {}" +
|
|
"};" +
|
|
"onkeypress = function(e) {" +
|
|
" var startTime = Date.now();" +
|
|
" document.body.setAttribute('data-press', ++press);" +
|
|
" if (e.charCode == 'p'.charCodeAt(0)) while (Date.now() - startTime < 500) {}" +
|
|
"};" +
|
|
"</script>";
|
|
|
|
add_task(function* () {
|
|
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
|
|
let browser = tab.linkedBrowser;
|
|
|
|
EventUtils.synthesizeKey("d", { code: "KeyD", repeat: 3 });
|
|
|
|
yield ContentTask.spawn(browser, null, 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");
|
|
});
|
|
|
|
EventUtils.synthesizeKey("p", { code: "KeyP", repeat: 3 });
|
|
|
|
yield ContentTask.spawn(browser, null, function* () {
|
|
is(content.document.body.getAttribute("data-down"), "4", "Correct number of events");
|
|
is(content.document.body.getAttribute("data-press"), "4", "Correct number of events");
|
|
});
|
|
|
|
gBrowser.removeCurrentTab();
|
|
});
|