Bug 499912, crash activating window with no root element, r+sr=smaug

This commit is contained in:
Neil Deakin 2009-06-24 13:12:37 -04:00
parent 65d8462672
commit 29905dad37
2 changed files with 23 additions and 5 deletions

View File

@ -6654,11 +6654,13 @@ nsGlobalWindow::ActivateOrDeactivate(PRBool aActivate)
nsCOMPtr<nsIDOMChromeWindow> chromeWin = do_QueryInterface(topLevelWindow); nsCOMPtr<nsIDOMChromeWindow> chromeWin = do_QueryInterface(topLevelWindow);
if (xulDoc && chromeWin) { if (xulDoc && chromeWin) {
nsCOMPtr<nsIContent> rootElem = doc->GetRootContent(); nsCOMPtr<nsIContent> rootElem = doc->GetRootContent();
if (aActivate) if (rootElem) {
rootElem->SetAttr(kNameSpaceID_None, nsGkAtoms::active, if (aActivate)
NS_LITERAL_STRING("true"), PR_TRUE); rootElem->SetAttr(kNameSpaceID_None, nsGkAtoms::active,
else NS_LITERAL_STRING("true"), PR_TRUE);
rootElem->UnsetAttr(kNameSpaceID_None, nsGkAtoms::active, PR_TRUE); else
rootElem->UnsetAttr(kNameSpaceID_None, nsGkAtoms::active, PR_TRUE);
}
} }
} }
} }

View File

@ -1119,13 +1119,29 @@ function switchWindowTest(otherWindow, framesetWindow)
otherWindow.close(); otherWindow.close();
framesetWindow.close(); framesetWindow.close();
gRefocusCallback = doWindowNoRootTest;
}
// open a window with no root element
var noRootWindow = null;
function doWindowNoRootTest()
{
var data = "data:application/vnd.mozilla.xul+xml," + unescape(
"<window onfocus='dostuff()' xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
" style='-moz-user-focus: normal;'>" +
"<script>function dostuff() { setTimeout(function() { " +
"document.documentElement.focus(); document.removeChild(document.documentElement);" +
"window.opener.focus(); }, 100); }</script></window>");
gRefocusCallback = doFrameSwitchingTests; gRefocusCallback = doFrameSwitchingTests;
noRootWindow = window.open(data, "_blank", "chrome,width=100,height=100");
} }
// these tests check when focus is moved between a tree of frames to ensure // these tests check when focus is moved between a tree of frames to ensure
// that the focus is in the right place at each event step. // that the focus is in the right place at each event step.
function doFrameSwitchingTests() function doFrameSwitchingTests()
{ {
noRootWindow.close();
gRefocusCallback = null; gRefocusCallback = null;
var framea = document.getElementById("ifa"); var framea = document.getElementById("ifa");