Bug 716107 part 7 - Update fullscreen keys tests. r=smaug

This commit is contained in:
Chris Pearce 2012-05-09 09:47:19 +12:00
parent 959f2a3aa4
commit e15eb6cb51
3 changed files with 0 additions and 301 deletions

View File

@ -47,8 +47,6 @@ include $(topsrcdir)/config/rules.mk
_TEST_FILES = \
test_MozEnteredDomFullscreen_event.xul \
MozEnteredDomFullscreen_chrome.xul \
test_dom_fullscreen_warning.xul \
dom_fullscreen_warning.xul \
test_fullscreen.xul \
fullscreen.xul \
test_fullscreen_preventdefault.xul \

View File

@ -1,263 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<!--
Test that "MozShowFullScreenWarning" is dispatched to chrome on restricted keypress.
-->
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="start();">
<script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"><![CDATA[
// List of key codes, and whether they should cause a warning in full-screen mode.
var keyList = [
// Allowed: DOM_VK_CANCEL to DOM_VK_CAPS_LOCK, inclusive
{ code: "VK_CANCEL", warn: true},
{ code: "VK_HELP", warn: true},
{ code: "VK_BACK_SPACE", warn: true},
{ code: "VK_TAB", warn: false},
{ code: "VK_CLEAR", warn: true},
{ code: "VK_RETURN", warn: true},
{ code: "VK_ENTER", warn: true},
{ code: "VK_SHIFT", warn: false},
{ code: "VK_CONTROL", warn: false},
{ code: "VK_ALT", warn: false},
{ code: "VK_PAUSE", warn: true},
{ code: "VK_CAPS_LOCK", warn: true},
{ code: "VK_KANA", warn: true},
{ code: "VK_HANGUL", warn: true},
{ code: "VK_JUNJA", warn: true},
{ code: "VK_FINAL", warn: true},
{ code: "VK_HANJA", warn: true},
{ code: "VK_KANJI", warn: true},
{ code: "VK_ESCAPE", warn: false, exit: true},
{ code: "VK_CONVERT", warn: true},
{ code: "VK_NONCONVERT", warn: true},
{ code: "VK_ACCEPT", warn: true},
{ code: "VK_MODECHANGE", warn: true},
{ code: "VK_SPACE", warn: false},
{ code: "VK_PAGE_UP", warn: false},
{ code: "VK_PAGE_DOWN", warn: false},
{ code: "VK_END", warn: false},
{ code: "VK_HOME", warn: false},
{ code: "VK_LEFT", warn: false},
{ code: "VK_UP", warn: false},
{ code: "VK_RIGHT", warn: false},
{ code: "VK_DOWN", warn: false},
{ code: "VK_SELECT", warn: true},
{ code: "VK_PRINT", warn: true},
{ code: "VK_EXECUTE", warn: true},
{ code: "VK_PRINTSCREEN", warn: true},
{ code: "VK_INSERT", warn: true},
{ code: "VK_DELETE", warn: true},
{ code: "VK_0", warn: true},
{ code: "VK_1", warn: true},
{ code: "VK_2", warn: true},
{ code: "VK_3", warn: true},
{ code: "VK_4", warn: true},
{ code: "VK_5", warn: true},
{ code: "VK_6", warn: true},
{ code: "VK_7", warn: true},
{ code: "VK_8", warn: true},
{ code: "VK_9", warn: true},
{ code: "VK_SEMICOLON", warn: true},
{ code: "VK_EQUALS", warn: true},
{ code: "VK_A", warn: true},
{ code: "VK_B", warn: true},
{ code: "VK_C", warn: true},
{ code: "VK_D", warn: true},
{ code: "VK_E", warn: true},
{ code: "VK_F", warn: true},
{ code: "VK_G", warn: true},
{ code: "VK_H", warn: true},
{ code: "VK_I", warn: true},
{ code: "VK_J", warn: true},
{ code: "VK_K", warn: true},
{ code: "VK_L", warn: true},
{ code: "VK_M", warn: true},
{ code: "VK_N", warn: true},
{ code: "VK_O", warn: true},
{ code: "VK_P", warn: true},
{ code: "VK_Q", warn: true},
{ code: "VK_R", warn: true},
{ code: "VK_S", warn: true},
{ code: "VK_T", warn: true},
{ code: "VK_U", warn: true},
{ code: "VK_V", warn: true},
{ code: "VK_W", warn: true},
{ code: "VK_X", warn: true},
{ code: "VK_Y", warn: true},
{ code: "VK_Z", warn: true},
{ code: "VK_CONTEXT_MENU", warn: true},
{ code: "VK_SLEEP", warn: true},
{ code: "VK_NUMPAD0", warn: true},
{ code: "VK_NUMPAD1", warn: true},
{ code: "VK_NUMPAD2", warn: true},
{ code: "VK_NUMPAD3", warn: true},
{ code: "VK_NUMPAD4", warn: true},
{ code: "VK_NUMPAD5", warn: true},
{ code: "VK_NUMPAD6", warn: true},
{ code: "VK_NUMPAD7", warn: true},
{ code: "VK_NUMPAD8", warn: true},
{ code: "VK_NUMPAD9", warn: true},
{ code: "VK_MULTIPLY", warn: true},
{ code: "VK_ADD", warn: true},
{ code: "VK_SEPARATOR", warn: true},
{ code: "VK_SUBTRACT", warn: true},
{ code: "VK_DECIMAL", warn: true},
{ code: "VK_DIVIDE", warn: true},
{ code: "VK_F1", warn: true},
{ code: "VK_F2", warn: true},
{ code: "VK_F3", warn: true},
{ code: "VK_F4", warn: true},
{ code: "VK_F5", warn: true},
{ code: "VK_F6", warn: true},
{ code: "VK_F7", warn: true},
{ code: "VK_F8", warn: true},
{ code: "VK_F9", warn: true},
{ code: "VK_F10", warn: true},
{ code: "VK_F11", warn: true}, // F11 exit full-screen handler is in browser.js, so won't cause exit here.
{ code: "VK_F12", warn: true},
{ code: "VK_F13", warn: true},
{ code: "VK_F14", warn: true},
{ code: "VK_F15", warn: true},
{ code: "VK_F16", warn: true},
{ code: "VK_F17", warn: true},
{ code: "VK_F18", warn: true},
{ code: "VK_F19", warn: true},
{ code: "VK_F20", warn: true},
{ code: "VK_F21", warn: true},
{ code: "VK_F22", warn: true},
{ code: "VK_F23", warn: true},
{ code: "VK_F24", warn: true},
{ code: "VK_NUM_LOCK", warn: true},
{ code: "VK_SCROLL_LOCK", warn: true},
{ code: "VK_COMMA", warn: true},
{ code: "VK_PERIOD", warn: true},
{ code: "VK_SLASH", warn: true},
{ code: "VK_BACK_QUOTE", warn: true},
{ code: "VK_OPEN_BRACKET", warn: true},
{ code: "VK_BACK_SLASH", warn: true},
{ code: "VK_CLOSE_BRACKET", warn: true},
{ code: "VK_QUOTE", warn: true},
{ code: "VK_META", warn: false},
];
function ok(condition, msg) {
window.opener.wrappedJSObject.ok(condition, msg);
}
function is(a, b, msg) {
window.opener.wrappedJSObject.is(a, b, msg);
}
var gKeyTestIndex = 0;
var gKeyName;
var gKeyCode;
var gWarningEventReceived = false;
var gExpectWarning;
var gExpectExit;
var gBrowser;
function checkKeyEffect() {
is(gBrowser.contentDocument.mozFullScreen, !gExpectExit,
(gExpectExit ? ("Should exit full-screen for " + gKeyName + " press ")
: ("Should remain in full-screen for " + gKeyName + " press")));
is(gWarningEventReceived, gExpectWarning, "Should " + (gExpectWarning ? "" : "not ") +
"receive MozShowFullScreenWarning for " + gKeyName + " press");
if (gKeyTestIndex < keyList.length) {
setTimeout(startNextTest, 0);
} else {
gBrowser.contentDocument.mozCancelFullScreen();
window.opener.wrappedJSObject.done();
}
}
function testTrustedKeyEvents() {
gBrowser.contentWindow.focus();
gWarningEventReceived = false;
synthesizeKey(gKeyName, {});
setTimeout(checkKeyEffect, 0);
}
function testScriptInitiatedKeyEvents() {
// Script initiated untrusted key events should not cause the warning to show.
gBrowser.contentWindow.focus();
gWarningEventReceived = false;
var evt = gBrowser.contentDocument.createEvent("KeyEvents");
evt.initKeyEvent("keydown", true, true, window,
false, false, false, false,
gKeyCode, 0);
gBrowser.contentDocument.body.dispatchEvent(evt);
evt = gBrowser.contentDocument.createEvent("KeyEvents");
evt.initKeyEvent("keypress", true, true, window,
false, false, false, false,
gKeyCode, 0);
gBrowser.contentDocument.body.dispatchEvent(evt);
evt = gBrowser.contentDocument.createEvent("KeyEvents");
evt.initKeyEvent("keyup", true, true, window,
false, false, false, false,
gKeyCode, 0);
gBrowser.contentDocument.body.dispatchEvent(evt);
setTimeout(checkScriptInitiatedEvents, 0);
}
function checkScriptInitiatedEvents() {
is(gWarningEventReceived, false, "Should not receive MozShowFullScreenWarning on synthesized key events.");
ok(gBrowser.contentDocument.mozFullScreen,
"Should remain in full-screen mode for script initiated key events for " + gKeyName);
testTrustedKeyEvents();
}
function testNextKey() {
ok(gBrowser.contentDocument.mozFullScreen, "Must be in full-screen mode");
gKeyName = keyList[gKeyTestIndex].code;
gKeyCode = KeyEvent["DOM_" + gKeyName];
gExpectWarning = keyList[gKeyTestIndex].warn;
gExpectExit = (keyList[gKeyTestIndex].exit != undefined) ?
keyList[gKeyTestIndex].exit : false;
gKeyTestIndex++;
testScriptInitiatedKeyEvents();
}
function startNextTest() {
if (!gBrowser.contentDocument.mozFullScreen) {
gBrowser.contentDocument.body.mozRequestFullScreen();
}
// mozRequestFullScreen is async...
setTimeout(testNextKey, 0);
}
function keyHandler(event) {
event.preventDefault();
}
window.addEventListener("MozShowFullScreenWarning", function(){ gWarningEventReceived = true; }, true);
window.addEventListener("keydown", keyHandler, true);
window.addEventListener("keyup", keyHandler, true);
window.addEventListener("keypress", keyHandler, true);
function start() {
SimpleTest.waitForFocus(
function() {
gBrowser = document.getElementById("browser");
gBrowser.contentWindow.focus();
gBrowser.contentDocument.body.mozRequestFullScreen();
setTimeout(startNextTest, 0);
});
}
]]>
</script>
<browser type="content" id="browser" width="400" height="400"/>
</window>

View File

@ -1,36 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<!--
Test that "MozShowFullScreenWarning" is dispatched to chrome on restricted keypress.
-->
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" width="400" height="400">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
SimpleTest.waitForExplicitFinish();
// Ensure the full-screen api is enabled, and will be disabled on test exit.
var gPrevEnabled = SpecialPowers.getBoolPref("full-screen-api.enabled");
SpecialPowers.setBoolPref("full-screen-api.enabled", true);
var gPrevTrusted = SpecialPowers.getBoolPref("full-screen-api.allow-trusted-requests-only");
SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only", false);
newwindow = window.open("dom_fullscreen_warning.xul", "_blank","chrome,resizable=yes,width=400,height=400");
function done()
{
newwindow.close();
SpecialPowers.setBoolPref("full-screen-api.enabled", gPrevEnabled);
SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only", gPrevTrusted);
SimpleTest.finish();
}
</script>
<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
</window>