зеркало из https://github.com/mozilla/gecko-dev.git
Bug 910532 part 3 - Mochitest for canceling context menu in fullscreen via Esc. r=smaug
--HG-- extra : source : 5c85f40de2286e527c5856a39bd88387c3a5995e
This commit is contained in:
Родитель
8315be6683
Коммит
1da98c96a8
|
@ -0,0 +1,100 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=910532
|
||||||
|
|
||||||
|
Verify that an ESC key press canceling the context menu
|
||||||
|
won't exit DOM fullscreen.
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Text for bug 910532</title>
|
||||||
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||||
|
<script type="application/javascript" src="file_fullscreen-utils.js"></script>
|
||||||
|
<style>
|
||||||
|
body:-moz-full-screen {
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script type="application/javascript">
|
||||||
|
|
||||||
|
const Ci = SpecialPowers.Ci;
|
||||||
|
|
||||||
|
SimpleTest.requestFlakyTimeout("We need to wait a small time to confirm " +
|
||||||
|
"that the first ESC key does not exit fullscreen.");
|
||||||
|
|
||||||
|
function ok(condition, msg) {
|
||||||
|
opener.ok(condition, "[esc-context-menu] " + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
function is(a, b, msg) {
|
||||||
|
opener.is(a, b, "[esc-context-menu] " + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
var contextMenu;
|
||||||
|
var escapeSent = 0;
|
||||||
|
|
||||||
|
function sendEscape() {
|
||||||
|
escapeSent++;
|
||||||
|
synthesizeKey("VK_ESCAPE", {});
|
||||||
|
}
|
||||||
|
|
||||||
|
function begin() {
|
||||||
|
// Copy from browser/base/content/test/general/test_contextmenu.html
|
||||||
|
var chromeWin = SpecialPowers.wrap(window)
|
||||||
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
|
.getInterface(Ci.nsIWebNavigation)
|
||||||
|
.QueryInterface(Ci.nsIDocShellTreeItem)
|
||||||
|
.rootTreeItem
|
||||||
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
|
.getInterface(Ci.nsIDOMWindow)
|
||||||
|
.QueryInterface(Ci.nsIDOMChromeWindow);
|
||||||
|
contextMenu = chromeWin.document.getElementById("contentAreaContextMenu");
|
||||||
|
ok(contextMenu, "Got context menu XUL");
|
||||||
|
|
||||||
|
addFullscreenChangeContinuation("enter", fullscreenEntered);
|
||||||
|
SpecialPowers.setBoolPref("full-screen-api.approval-required", false);
|
||||||
|
document.body.mozRequestFullScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
function finish() {
|
||||||
|
SpecialPowers.clearUserPref("full-screen-api.approval-required");
|
||||||
|
opener.nextTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
function fullscreenEntered(event) {
|
||||||
|
ok(document.mozFullScreen, "Should have entered fullscreen mode");
|
||||||
|
is(document.mozFullScreenElement, document.body, "FSE should be doc");
|
||||||
|
contextMenu.addEventListener("popupshown", contextMenuOpened, false);
|
||||||
|
is(contextMenu.state, "closed", "Should not have opened context menu");
|
||||||
|
synthesizeMouseAtCenter(document.body, {type: 'contextmenu', button: 2});
|
||||||
|
}
|
||||||
|
|
||||||
|
function contextMenuOpened(event) {
|
||||||
|
contextMenu.removeEventListener("popupshown", contextMenuOpened);
|
||||||
|
is(contextMenu.state, "open", "Should have opened context menu");
|
||||||
|
addFullscreenChangeContinuation("exit", fullscreenExited);
|
||||||
|
contextMenu.addEventListener("popuphidden", contextMenuClosed, false);
|
||||||
|
sendEscape();
|
||||||
|
}
|
||||||
|
|
||||||
|
function contextMenuClosed(event) {
|
||||||
|
is(contextMenu.state, "closed", "Should have closed context menu");
|
||||||
|
setTimeout(function () {
|
||||||
|
ok(document.mozFullScreen, "Should still be in fullscreen mode");
|
||||||
|
sendEscape();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fullscreenExited(event) {
|
||||||
|
is(escapeSent, 2, "Only the second escape should exit fullscreen");
|
||||||
|
ok(!document.mozFullScreen, "Should have left fullscreen mode");
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -51,6 +51,7 @@ support-files =
|
||||||
file_fullscreen-api.html
|
file_fullscreen-api.html
|
||||||
file_fullscreen-denied-inner.html
|
file_fullscreen-denied-inner.html
|
||||||
file_fullscreen-denied.html
|
file_fullscreen-denied.html
|
||||||
|
file_fullscreen-esc-context-menu.html
|
||||||
file_fullscreen-esc-exit-inner.html
|
file_fullscreen-esc-exit-inner.html
|
||||||
file_fullscreen-esc-exit.html
|
file_fullscreen-esc-exit.html
|
||||||
file_fullscreen-hidden.html
|
file_fullscreen-hidden.html
|
||||||
|
|
|
@ -39,6 +39,7 @@ var gTestWindows = [
|
||||||
"file_fullscreen-ancestor-stacking-context.html",
|
"file_fullscreen-ancestor-stacking-context.html",
|
||||||
"file_fullscreen-multiple.html",
|
"file_fullscreen-multiple.html",
|
||||||
"file_fullscreen-rollback.html",
|
"file_fullscreen-rollback.html",
|
||||||
|
"file_fullscreen-esc-context-menu.html",
|
||||||
"file_fullscreen-esc-exit.html",
|
"file_fullscreen-esc-exit.html",
|
||||||
"file_fullscreen-denied.html",
|
"file_fullscreen-denied.html",
|
||||||
"file_fullscreen-api.html",
|
"file_fullscreen-api.html",
|
||||||
|
|
Загрузка…
Ссылка в новой задаче