Bug 966552 - Ensure that we pick the editor XBL window key handler for designMode documents no matter where the focus is; r=Neil

This commit is contained in:
Ehsan Akhgari 2014-02-10 14:55:01 -05:00
Родитель c3a11f47df
Коммит 6af7e4ffa9
3 изменённых файлов: 56 добавлений и 0 удалений

Просмотреть файл

@ -29,6 +29,7 @@
#include "nsEventStateManager.h"
#include "nsIEditor.h"
#include "nsIHTMLEditor.h"
#include "nsIDOMDocument.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -359,6 +360,14 @@ nsXBLWindowKeyHandler::IsHTMLEditableFieldFocused()
return false;
}
nsCOMPtr<nsIDOMDocument> domDocument;
editor->GetDocument(getter_AddRefs(domDocument));
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDocument);
if (doc->HasFlag(NODE_IS_EDITABLE)) {
// Don't need to perform any checks in designMode documents.
return true;
}
nsCOMPtr<nsIDOMElement> focusedElement;
fm->GetFocusedElement(getter_AddRefs(focusedElement));
nsCOMPtr<nsINode> focusedNode = do_QueryInterface(focusedElement);

Просмотреть файл

@ -130,6 +130,8 @@ skip-if = os != "mac"
[test_bug796839.html]
[test_bug832025.html]
[test_bug857487.html]
[test_bug966552.html]
skip-if = os != "win"
[test_contenteditable_focus.html]
[test_dom_input_event_on_htmleditor.html]
[test_keypress_untrusted_event.html]

Просмотреть файл

@ -0,0 +1,45 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=966552
-->
<head>
<title>Test for Bug 966552</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=966552">Mozilla Bug 289384</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
var win = window.open("data:text/html,<body onload=\"document.designMode='on'\">test</body>", "", "test-966552");
win.addEventListener("load", function onLoad() {
win.removeEventListener("load", onLoad);
runTest(win);
}, false);
});
function runTest(win) {
SimpleTest.waitForFocus(function() {
var doc = win.document;
var sel = win.getSelection();
doc.body.focus();
sel.collapse(doc.body.firstChild, 2);
synthesizeKey("VK_BACK_SPACE", {ctrlKey: true}, win);
is(doc.body.textContent, "st");
win.close();
SimpleTest.finish();
}, win);
}
</script>
</pre>
</body>
</html>