Bug 803112 - Handle AccessFu startup when there is no current browser yet. r=davidb
authorEitan Isaacson <eitan@monotonous.org>
Fri, 19 Oct 2012 10:06:07 -0700
changeset 110921 85425f2440b1e0fa0ad58a5b01a5518ad0a57b42
parent 110920 2bea5e6ee825249aaf1c881e289b680035283710
child 110922 c8286a2f35ab0cbd6b6818b6b9a8cd018f5414c0
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersdavidb
bugs803112
milestone19.0a1
Bug 803112 - Handle AccessFu startup when there is no current browser yet. r=davidb
accessible/src/jsat/Utils.jsm
--- a/accessible/src/jsat/Utils.jsm
+++ b/accessible/src/jsat/Utils.jsm
@@ -84,17 +84,18 @@ var Utils = {
 
   getCurrentBrowser: function getCurrentBrowser(aWindow) {
     if (this.MozBuildApp == 'b2g')
       return this.getBrowserApp(aWindow).contentBrowser;
     return this.getBrowserApp(aWindow).selectedBrowser;
   },
 
   getCurrentContentDoc: function getCurrentContentDoc(aWindow) {
-    return this.getCurrentBrowser(aWindow).contentDocument;
+    let browser = this.getCurrentBrowser(aWindow);
+    return browser ? browser.contentDocument : null;
   },
 
   getMessageManager: function getMessageManager(aBrowser) {
     try {
       return aBrowser.QueryInterface(Ci.nsIFrameLoaderOwner).
          frameLoader.messageManager;
     } catch (x) {
       Logger.error(x);
@@ -103,23 +104,24 @@ var Utils = {
   },
 
   getAllMessageManagers: function getAllMessageManagers(aWindow) {
     let messageManagers = [];
 
     for (let i = 0; i < aWindow.messageManager.childCount; i++)
       messageManagers.push(aWindow.messageManager.getChildAt(i));
 
-    let remoteframes = this.getCurrentContentDoc(aWindow).
-      querySelectorAll('iframe[remote=true]');
+    let document = this.getCurrentContentDoc(aWindow);
 
-    for (let i = 0; i < remoteframes.length; ++i)
-      messageManagers.push(this.getMessageManager(remoteframes[i]));
+    if (document) {
+      let remoteframes = document.querySelectorAll('iframe[remote=true]');
 
-    Logger.info(messageManagers.length);
+      for (let i = 0; i < remoteframes.length; ++i)
+        messageManagers.push(this.getMessageManager(remoteframes[i]));
+    }
 
     return messageManagers;
   },
 
   getViewport: function getViewport(aWindow) {
     switch (this.MozBuildApp) {
       case 'mobile/android':
         return aWindow.BrowserApp.selectedTab.getViewport();