Bug 620078 - Crash [@ nsAutoFocusEvent::Run] with autofocus attribute in frame with no window. r=smaug a=blocking-betaN

This commit is contained in:
Mounir Lamouri 2010-12-21 19:58:24 -05:00
Родитель 2db721d9de
Коммит 707e2d8fe9
4 изменённых файлов: 34 добавлений и 4 удалений

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

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<script>
function boom()
{
var frame = document.getElementById("f");
var frameRoot = frame.contentDocument.documentElement;
document.body.removeChild(frame);
var i = document.createElementNS("http://www.w3.org/1999/xhtml", "input");
i.setAttribute("autofocus", "true");
frameRoot.appendChild(i);
}
</script>
</head>
<body onload="boom();"><iframe id="f" src="data:text/html,"></iframe></body>
</html>

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

@ -0,0 +1,6 @@
<!DOCTYPE html>
<html>
<body onload='document.cloneNode(1)'>
<button autofocus></button>
</body>
</html>

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

@ -26,3 +26,5 @@ load 602117.html
load 613027.html
load 614279.html
load 614988-1.html
load 620078-1.html
load 620078-2.html

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

@ -198,8 +198,10 @@ public:
return NS_OK;
}
// Do not autofocus if an sub-window is focused.
nsPIDOMWindow* window = document->GetWindow();
if (!window) {
return NS_OK;
}
// Trying to found the top window (equivalent to window.top).
nsCOMPtr<nsIDOMWindow> top;
@ -208,12 +210,12 @@ public:
window = static_cast<nsPIDOMWindow*>(top.get());
}
nsCOMPtr<nsIDocument> topDoc = do_QueryInterface(window->GetExtantDocument());
if (topDoc && topDoc->GetReadyStateEnum() == nsIDocument::READYSTATE_COMPLETE) {
if (window->GetFocusedNode()) {
return NS_OK;
}
if (window && window->GetFocusedNode()) {
nsCOMPtr<nsIDocument> topDoc = do_QueryInterface(window->GetExtantDocument());
if (topDoc && topDoc->GetReadyStateEnum() == nsIDocument::READYSTATE_COMPLETE) {
return NS_OK;
}