Bug 561664 - document.activeElement should never return native anonymous content, r=enndeakin

This commit is contained in:
Olli Pettay 2012-05-04 17:41:49 +03:00
Родитель 6656de0df2
Коммит 8b4500b2cc
3 изменённых файлов: 21 добавлений и 7 удалений

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

@ -2783,8 +2783,13 @@ nsDocument::GetActiveElement(nsIDOMElement **aElement)
getter_AddRefs(focusedWindow));
// be safe and make sure the element is from this document
if (focusedContent && focusedContent->OwnerDoc() == this) {
CallQueryInterface(focusedContent, aElement);
return NS_OK;
if (focusedContent->IsInNativeAnonymousSubtree()) {
focusedContent = focusedContent->FindFirstNonNativeAnonymous();
}
if (focusedContent) {
CallQueryInterface(focusedContent, aElement);
return NS_OK;
}
}
}

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

@ -61,6 +61,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=238987
expected + "], got [" + e.target.id + "]");
} else {
var expected = forwardFocusArray.shift();
is(e.target, document.activeElement, "Wrong activeElement!");
ok(expected == e.target.id,
"(focus) Forward tabbing, expected [" +
expected + "], got [" + e.target.id + "]");

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

@ -216,13 +216,8 @@ var nonFocusableElements = [
"<input type=\"checkbox\" tabindex=\"0\" disabled>",
"<input type=\"checkbox\" disabled>",
"<input type=\"file\">",
"<input type=\"file\" tabindex=\"-1\">",
"<input type=\"file\" tabindex=\"0\">",
"<input type=\"file\" tabindex=\"0\" disabled>",
"<input type=\"file\" tabindex=\"1\">",
"<input type=\"file\" disabled>",
"<input type=\"file\" contenteditable=\"true\">",
"<input type=\"hidden\">",
"<input type=\"hidden\" tabindex=\"-1\">",
@ -326,6 +321,12 @@ var focusableInContentEditable = [
"<input type=\"button\" tabindex=\"1\">",
"<input type=\"button\" contenteditable=\"true\">",
"<input type=\"file\">",
"<input type=\"file\" tabindex=\"-1\">",
"<input type=\"file\" tabindex=\"0\">",
"<input type=\"file\" tabindex=\"1\">",
"<input type=\"file\" contenteditable=\"true\">",
"<input type=\"checkbox\">",
"<input type=\"checkbox\" tabindex=\"-1\">",
"<input type=\"checkbox\" tabindex=\"0\">",
@ -456,6 +457,13 @@ function testElements(parent, tags, shouldBeFocusable)
var errorPrefix = serializer.serializeToString(element) + " in " +
serializer.serializeToString(parent);
try {
// Make sure activeElement doesn't point to a
// native anonymous element.
parent.ownerDocument.activeElement.localName;
} catch (ex) {
ok(false, ex + errorPrefix + errorSuffix);
}
if (focusable ? focusable.indexOf(tag) > -1 : shouldBeFocusable) {
is(parent.ownerDocument.activeElement, element,
errorPrefix + " should be focusable" + errorSuffix);