Bug 1208789, clear starting node before traversing backwards by document, r=smaug
authorNeil Deakin <neil@mozilla.com>
Tue, 29 Sep 2015 14:49:34 -0400
changeset 265006 8305fc7ffd1c2adc305f9047276dd2c1aed3c1c5
parent 265005 6fff7b56c8659f0ea90fefdb772095f633295723
child 265007 f11627daf10e34e4109e39dbb2d652bda412cc95
push id65820
push userneil@mozilla.com
push dateTue, 29 Sep 2015 18:49:54 +0000
treeherdermozilla-inbound@8305fc7ffd1c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1208789
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1208789, clear starting node before traversing backwards by document, r=smaug
browser/base/content/test/general/browser_documentnavigation.js
dom/base/nsFocusManager.cpp
--- a/browser/base/content/test/general/browser_documentnavigation.js
+++ b/browser/base/content/test/general/browser_documentnavigation.js
@@ -100,17 +100,17 @@ add_task(function* ()
   // When the content is focused, pressing F6 should focus the urlbar.
   yield* expectFocusOnF6(false, "main-window", gURLBar.inputField,
                                 false, "basic focus content page urlbar");
 
   // When a button in content is focused, pressing F6 should focus the urlbar.
   yield* expectFocusOnF6(false, "html1", "html1",
                                 true, "basic focus content page with button focused");
 
-  return ContentTask.spawn(gBrowser.selectedBrowser, { }, function* () {
+  yield ContentTask.spawn(gBrowser.selectedBrowser, { }, function* () {
     return content.document.getElementById("button1").focus();
   });
 
   yield* expectFocusOnF6(false, "main-window", gURLBar.inputField,
                                 false, "basic focus content page with button focused urlbar");
 
   // The document root should be focused, not the button
   yield* expectFocusOnF6(false, "html1", "html1",
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -2464,17 +2464,21 @@ nsFocusManager::DetermineElementToMoveFo
   nsCOMPtr<nsIContent> startContent = aStartContent;
   if (!startContent && aType != MOVEFOCUS_CARET) {
     if (aType == MOVEFOCUS_FORWARDDOC || aType == MOVEFOCUS_BACKWARDDOC) {
       // When moving between documents, make sure to get the right
       // starting content in a descendant.
       nsCOMPtr<nsPIDOMWindow> focusedWindow;
       startContent = GetFocusedDescendant(aWindow, true, getter_AddRefs(focusedWindow));
     }
-    else {
+    else if (aType != MOVEFOCUS_LASTDOC) {
+      // Otherwise, start at the focused node. If MOVEFOCUS_LASTDOC is used,
+      // then we are document-navigating backwards from chrome to the content
+      // process, and we don't want to use this so that we start from the end
+      // of the document.
       startContent = aWindow->GetFocusedNode();
     }
   }
 
   nsCOMPtr<nsIDocument> doc;
   if (startContent)
     doc = startContent->GetComposedDoc();
   else