mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
5af5a73d3d
find /files/mozilla/build/d/_tests/testing/mochitest/tests/ | egrep "\.(xhtml|html|xml|js)$" | grep -v SimpleTest | grep -vi mochikit | grep -v simpleThread | grep -v test_ipc_messagemanager_blob.html | grep -v "indexedDB/test" | xargs grep -l Components | xargs grep -L enablePrivilege | perl -pe 's#.*mochitest/tests/##' | xargs perl -p -i.bakkk -e 's/Components\.interfaces(\s|;|\.|\[)/SpecialPowers\.Ci$1/g, s/SpecialPowers\.wrap\(Components\)\.(.)(lasses|tils|nterfaces|esults)/SpecialPowers.C$1/g, s/(?<![\.a-zA-Z])Components/SpecialPowers\.Components/g, s/window\.Components/window\.SpecialPowers\.Components/g'
82 lines
2.6 KiB
JavaScript
82 lines
2.6 KiB
JavaScript
/* Any copyright is dedicated to the public domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
// Test that an iframe with the |mozbrowser| attribute does bubble some
|
|
// whitelisted key events.
|
|
"use strict";
|
|
|
|
let Ci = SpecialPowers.Ci;
|
|
|
|
let whitelistedEvents = [
|
|
Ci.nsIDOMKeyEvent.DOM_VK_ESCAPE, // Back button.
|
|
Ci.nsIDOMKeyEvent.DOM_VK_SLEEP, // Power button
|
|
Ci.nsIDOMKeyEvent.DOM_VK_CONTEXT_MENU,
|
|
Ci.nsIDOMKeyEvent.DOM_VK_F5, // Search button.
|
|
Ci.nsIDOMKeyEvent.DOM_VK_PAGE_UP, // Volume up.
|
|
Ci.nsIDOMKeyEvent.DOM_VK_PAGE_DOWN // Volume down.
|
|
];
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
browserElementTestHelpers.setEnabledPref(true);
|
|
browserElementTestHelpers.addPermission();
|
|
browserElementTestHelpers.setOOPDisabledPref(true); // this is breaking the autofocus.
|
|
|
|
var iframe = document.createElement('iframe');
|
|
iframe.mozbrowser = true;
|
|
iframe.src = browserElementTestHelpers.focusPage;
|
|
document.body.appendChild(iframe);
|
|
|
|
// Number of expected events at which point we will consider the test as done.
|
|
var nbEvents = whitelistedEvents.length * 3;
|
|
|
|
function eventHandler(e) {
|
|
ok(((e.type == 'keydown' || e.type == 'keypress' || e.type == 'keyup') &&
|
|
!e.defaultPrevented &&
|
|
(whitelistedEvents.indexOf(e.keyCode) != -1)),
|
|
"[ " + e.type + "] Handled event should be a non prevented key event in the white list.");
|
|
|
|
nbEvents--;
|
|
|
|
if (nbEvents == 0) {
|
|
browserElementTestHelpers.restoreOriginalPrefs();
|
|
SimpleTest.finish();
|
|
return;
|
|
}
|
|
|
|
if (nbEvents < 0) {
|
|
ok(false, "got an unexpected event! " + e.type + " " + e.keyCode);
|
|
SimpleTest.finish();
|
|
return;
|
|
}
|
|
}
|
|
|
|
function runTest() {
|
|
is(document.activeElement, iframe, "iframe should be focused");
|
|
|
|
addEventListener('keydown', eventHandler);
|
|
addEventListener('keypress', eventHandler);
|
|
addEventListener('keyup', eventHandler);
|
|
|
|
// Those event should not be received because not whitelisted.
|
|
synthesizeKey("VK_A", {});
|
|
synthesizeKey("VK_B", {});
|
|
|
|
// Those events should not be received because prevent default is called.
|
|
synthesizeKey("VK_ESCAPE", {});
|
|
|
|
// Those events should be received.
|
|
synthesizeKey("VK_F5", {}); // F5 key is going to be canceled by ESC key.
|
|
synthesizeKey("VK_ESCAPE", {});
|
|
synthesizeKey("VK_PAGE_UP", {}); // keypress is ignored because .preventDefault() will be called.
|
|
synthesizeKey("VK_PAGE_DOWN", {}); // keypress is ignored because .preventDefault() will be called.
|
|
synthesizeKey("VK_CONTEXT_MENU", {});
|
|
synthesizeKey("VK_SLEEP", {});
|
|
}
|
|
|
|
SimpleTest.waitForFocus(function() {
|
|
iframe.focus();
|
|
SimpleTest.executeSoon(runTest);
|
|
});
|
|
|