From c9cedd05330a096e487d654960ab86f91cab4245 Mon Sep 17 00:00:00 2001 From: Neil Rashbrook Date: Fri, 10 Oct 2008 10:36:41 +0100 Subject: [PATCH] Bug 365467 Focus contollers initial window and element can get out of sync r+sr=jst Reordering tests to see if that can make the change stick --HG-- rename : browser/base/content/test/browser_autodiscovery.js => browser/base/content/test/browser_discovery.js rename : browser/base/content/test/autodiscovery.html => browser/base/content/test/discovery.html --- browser/base/content/test/Makefile.in | 12 +++------- ..._autodiscovery.js => browser_discovery.js} | 2 +- .../{autodiscovery.html => discovery.html} | 0 layout/base/nsPresShell.cpp | 22 +++++++++---------- 4 files changed, 14 insertions(+), 22 deletions(-) rename browser/base/content/test/{browser_autodiscovery.js => browser_discovery.js} (99%) rename browser/base/content/test/{autodiscovery.html => discovery.html} (100%) diff --git a/browser/base/content/test/Makefile.in b/browser/base/content/test/Makefile.in index ece0d498725..1074d4435b1 100644 --- a/browser/base/content/test/Makefile.in +++ b/browser/base/content/test/Makefile.in @@ -55,10 +55,11 @@ _BROWSER_FILES = browser_bug321000.js \ browser_bug405137.js \ browser_bug409481.js \ browser_bug413915.js \ - browser_autodiscovery.js \ browser_bug420160.js \ + browser_bug427559.js \ browser_bug441778.js \ - autodiscovery.html \ + browser_discovery.js \ + discovery.html \ moz.png \ browser_getshortcutoruri.js \ browser_page_style_menu.js \ @@ -72,13 +73,6 @@ _BROWSER_FILES += browser_customize.js \ $(NULL) endif -# disable tests on linux for now.. -ifneq ($(OS_ARCH),Linux) -_BROWSER_FILES += \ - browser_bug427559.js \ - $(NULL) -endif - libs:: $(_TEST_FILES) $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir) diff --git a/browser/base/content/test/browser_autodiscovery.js b/browser/base/content/test/browser_discovery.js similarity index 99% rename from browser/base/content/test/browser_autodiscovery.js rename to browser/base/content/test/browser_discovery.js index 9eacf8a7a4a..f5351cd0c41 100644 --- a/browser/base/content/test/browser_autodiscovery.js +++ b/browser/base/content/test/browser_discovery.js @@ -20,7 +20,7 @@ function test() { waitForExplicitFinish(); var activeWin = Application.activeWindow; - gTestPage = activeWin.open(url("chrome://mochikit/content/browser/browser/base/content/test/autodiscovery.html")); + gTestPage = activeWin.open(url("chrome://mochikit/content/browser/browser/base/content/test/discovery.html")); gTestPage.focus(); setTimeout(iconDiscovery, 1000); } diff --git a/browser/base/content/test/autodiscovery.html b/browser/base/content/test/discovery.html similarity index 100% rename from browser/base/content/test/autodiscovery.html rename to browser/base/content/test/discovery.html diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 8f4f626567d..db14ef0f945 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -2293,19 +2293,17 @@ static void CheckForFocus(nsPIDOMWindow* aOurWindow, if (!aFocusController) return; - nsCOMPtr ourWin = do_QueryInterface(aOurWindow); - nsCOMPtr focusedWindow; aFocusController->GetFocusedWindow(getter_AddRefs(focusedWindow)); if (!focusedWindow) { - // This should never really happen, but if it does, assume - // we can focus ourself to keep the window from being keydead. - focusedWindow = ourWin; + // This happens if the window has not been shown yet. We don't need to + // focus anything now because showing the window will set the focus. + return; } // Walk up the document chain, starting with focusedWindow's document. // We stop walking when we find a document that has a null DOMWindow - // (meaning that the DOMWindow has a new document now) or find ourWin + // (meaning that the DOMWindow has a new document now) or find aOurWindow // as the document's window. We also stop if we hit aDocument, since // that means there is a child document which loaded before us that's // already been given focus. @@ -2328,7 +2326,7 @@ static void CheckForFocus(nsPIDOMWindow* aOurWindow, while (curDoc) { nsPIDOMWindow *curWin = curDoc->GetWindow(); - if (!curWin || curWin == ourWin) + if (!curWin || curWin == aOurWindow) break; curDoc = curDoc->GetParentDocument(); @@ -2337,20 +2335,20 @@ static void CheckForFocus(nsPIDOMWindow* aOurWindow, } if (!curDoc) { - // We reached the top of the document chain, and did not encounter ourWin - // or a windowless document. So, focus should be unaffected by this - // document load. + // We reached the top of the document chain, and did not encounter + // aOurWindow or a windowless document. So, focus should be unaffected + // by this document load. return; } PRBool active; aFocusController->GetActive(&active); if (active) - ourWin->Focus(); + aOurWindow->Focus(); // We need to ensure that the focus controller is updated, since it may be // suppressed when this function is called. - aFocusController->SetFocusedWindow(ourWin); + aFocusController->SetFocusedWindow(aOurWindow); } NS_IMETHODIMP