Index: src/orca/Gecko.py
===================================================================
--- src/orca/Gecko.py	(revision 3457)
+++ src/orca/Gecko.py	(working copy)
@@ -8016,12 +8016,8 @@
             [obj, characterOffset] = self.getCaretContext()
 
         if not obj:
-            obj = self.getLastObject()
-            [obj, characterOffset] = self.findPreviousCaretInOrder(obj, 0)
+            return self.getTopOfFile()
 
-        if not obj:
-            return [None, -1]
-
         currentLine = self._currentLineContents
         index = self.findObjectOnLine(obj, characterOffset, currentLine)
         if index < 0:
@@ -8243,12 +8239,8 @@
             [obj, characterOffset] = self.getCaretContext()
 
         if not obj:
-            obj = self.getDocumentFrame()
-            [obj, characterOffset] = self.findFirstCaretContext(obj, -1)
+            return self.getBottomOfFile()
 
-        if not obj:
-            return [None, -1]
-
         currentLine = self._currentLineContents
         index = self.findObjectOnLine(obj, characterOffset, currentLine)
         if index < 0:
@@ -8409,6 +8401,9 @@
         [obj, characterOffset] = self.getCaretContext()
         [previousObj, previousCharOffset] = \
                                    self.findPreviousLine(obj, characterOffset)
+        if not previousObj:
+            return
+
         self.setCaretPosition(previousObj, previousCharOffset)
         self.presentLine(previousObj, previousCharOffset)
 
@@ -8422,8 +8417,13 @@
         """Positions the caret offset at the next line in the document
         window, attempting to preserve horizontal caret position.
         """
+
         [obj, characterOffset] = self.getCaretContext()
         [nextObj, nextCharOffset] = self.findNextLine(obj, characterOffset)
+
+        if not nextObj:
+            return
+
         self.setCaretPosition(nextObj, nextCharOffset)
         self.presentLine(nextObj, nextCharOffset)
 
