зеркало из https://github.com/mozilla/pjs.git
Bug 561664 - document.activeElement should never return native anonymous content, r=enndeakin
This commit is contained in:
Родитель
6656de0df2
Коммит
8b4500b2cc
|
@ -2783,10 +2783,15 @@ nsDocument::GetActiveElement(nsIDOMElement **aElement)
|
|||
getter_AddRefs(focusedWindow));
|
||||
// be safe and make sure the element is from this document
|
||||
if (focusedContent && focusedContent->OwnerDoc() == this) {
|
||||
if (focusedContent->IsInNativeAnonymousSubtree()) {
|
||||
focusedContent = focusedContent->FindFirstNonNativeAnonymous();
|
||||
}
|
||||
if (focusedContent) {
|
||||
CallQueryInterface(focusedContent, aElement);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No focused element anywhere in this document. Try to get the BODY.
|
||||
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryObject(this);
|
||||
|
|
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче