diff --git a/content/html/content/test/file_fullscreen-api-keys.html b/content/html/content/test/file_fullscreen-api-keys.html
index 577344cf1c6..6af4251f0eb 100644
--- a/content/html/content/test/file_fullscreen-api-keys.html
+++ b/content/html/content/test/file_fullscreen-api-keys.html
@@ -43,7 +43,7 @@ var keyList = [
{ code: "VK_FINAL", allowed: false},
{ code: "VK_HANJA", allowed: false},
{ code: "VK_KANJI", allowed: false},
- { code: "VK_ESCAPE", allowed: false},
+ { code: "VK_ESCAPE", allowed: false, suppressed: true},
{ code: "VK_CONVERT", allowed: false},
{ code: "VK_NONCONVERT", allowed: false},
{ code: "VK_ACCEPT", allowed: false},
@@ -176,14 +176,16 @@ var gKeyTestIndex = 0;
var gKeyName;
var gKeyCode;
var gKeyAllowed;
+var gKeySuppressed;
var gKeyReceived = false;
function keyHandler(event) {
- event.preventDefault()
+ event.preventDefault();
gKeyReceived = true;
}
function checkKeyEffect() {
+ is(gKeySuppressed, !gKeyReceived, "Should not receive suppressed key events");
is(document.mozFullScreen, gKeyAllowed,
(gKeyAllowed ? ("Should remain in full-screen mode for allowed key press " + gKeyName)
: ("Should drop out of full-screen mode for restricted key press " + gKeyName)));
@@ -239,6 +241,8 @@ function testNextKey() {
gKeyName = keyList[gKeyTestIndex].code;
gKeyCode = KeyEvent["DOM_" + gKeyName];
gKeyAllowed = keyList[gKeyTestIndex].allowed;
+ gKeySuppressed = (keyList[gKeyTestIndex].suppressed != undefined) ?
+ keyList[gKeyTestIndex].suppressed : false;
gKeyTestIndex++;
testScriptInitiatedKeyEvents();
diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp
index 0066720a8bd..de212a0cc27 100644
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -6344,17 +6344,30 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView,
switch (aEvent->message) {
case NS_KEY_PRESS:
case NS_KEY_DOWN:
- case NS_KEY_UP:
+ case NS_KEY_UP: {
if (IsFullScreenAndRestrictedKeyEvent(mCurrentEventContent, aEvent) &&
- aEvent->message == NS_KEY_DOWN) {
+ aEvent->message == NS_KEY_UP) {
// We're in DOM full-screen mode, and a key with a restricted key
// code has been pressed. Exit full-screen mode.
NS_DispatchToCurrentThread(
NS_NewRunnableMethod(mCurrentEventContent->OwnerDoc(),
&nsIDocument::CancelFullScreen));
}
+ nsIDocument *doc = mCurrentEventContent ?
+ mCurrentEventContent->OwnerDoc() : nsnull;
+ if (doc &&
+ doc->IsFullScreenDoc() &&
+ static_cast(aEvent)->keyCode == NS_VK_ESCAPE) {
+ // Prevent default action on ESC key press when exiting
+ // DOM full-screen mode. This prevents the browser ESC key
+ // handler from stopping all loads in the document, which
+ // would cause