Bug 973550 - "TypeError: webNavigation.document.body is null" in SessionHistory.jsm r=smacleod
authorTim Taubert <ttaubert@mozilla.com>
Mon, 17 Feb 2014 12:35:29 +0100
changeset 170119 db540bc426141aa5ca206c8da185f702fa4f8090
parent 170118 70df8261030ad1f018a4b1e880b1e0a1fd5bb182
child 170120 24adaa318267fe603df5ff59f288f6d5c3f1f8f0
push id26277
push userphilringnalda@gmail.com
push dateSun, 23 Feb 2014 17:00:29 +0000
treeherdermozilla-central@31113754db3b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmacleod
bugs973550
milestone30.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 973550 - "TypeError: webNavigation.document.body is null" in SessionHistory.jsm r=smacleod
browser/components/sessionstore/src/SessionHistory.jsm
--- a/browser/components/sessionstore/src/SessionHistory.jsm
+++ b/browser/components/sessionstore/src/SessionHistory.jsm
@@ -107,23 +107,24 @@ let SessionHistoryInternal = {
       // ensuring it isn't out of bounds if an exception was thrown above.
       data.index = Math.min(history.index - oldest + 1, data.entries.length);
     }
 
     // If either the session history isn't available yet or doesn't have any
     // valid entries, make sure we at least include the current page.
     if (data.entries.length == 0) {
       let uri = webNavigation.currentURI.spec;
+      let body = webNavigation.document.body;
       // We landed here because the history is inaccessible or there are no
       // history entries. In that case we should at least record the docShell's
       // current URL as a single history entry. If the URL is not about:blank
       // or it's a blank tab that was modified (like a custom newtab page),
       // record it. For about:blank we explicitly want an empty array without
       // an 'index' property to denote that there are no history entries.
-      if (uri != "about:blank" || webNavigation.document.body.hasChildNodes()) {
+      if (uri != "about:blank" || (body && body.hasChildNodes())) {
         data.entries.push({ url: uri });
         data.index = 1;
       }
     }
 
     return data;
   },