forked from mirrors/gecko-dev
Now, callers of EventUtils.synthesizeKey() don't need to specify KeyboardEvent.code value anymore if they assume that active keyboard layout is US keyboard layout. Note that this patch changes the meaning of only test_bug551434.html. Some callers in it don't match the key value and code value but that looks like that they don't checking such odd keyboard events. So, they must be bug of the test. MozReview-Commit-ID: Itxo7yZ9rkK --HG-- extra : rebase_source : 856ef3715c924ca16e993ea57d92d1243b5cc6be
36 lines
1.3 KiB
JavaScript
36 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(async function() {
|
|
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
|
|
let browser = tab.linkedBrowser;
|
|
|
|
await EventUtils.synthesizeAndWaitKey("d", {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", {repeat: 3});
|
|
|
|
await ContentTask.spawn(browser, null, async 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();
|
|
});
|