MozillaZine

Error "this.docShell is null" when opening my sidebar

Talk about add-ons and extension development.
rafaelfc1208

User avatar
 
Posts: 16
Joined: May 30th, 2008, 10:22 am

Post Posted July 8th, 2008, 1:12 pm

Hello all.

I'm getting this error "this.docShell is null" when opening my sidebar on Firefox 3.

my xul file:
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="chrome://mybar/content/mybar.css" type="text/css"?>
<!DOCTYPE dialog SYSTEM "chrome://mybar/content/mybar.dtd">
<overlay id="my_sidebar" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >
   <hbox flex="1">
      <vbox flex="1">
         <browser id="my_browser" flex="1" type="content" disablehistory="true" src="about:blank" />
      </vbox>
   </hbox>   
    <script type="application/x-javascript" src="chrome://mybar/content/my_sidebar.js"/>   

    <script>
       mySideBar_init();
    </script>   
</overlay>


my javascript file:
Code: Select all
const MY_PAGE_URL = "http://localhost/test.html";

var myBrowserListener =
{
   QueryInterface: function(aIID)
   {
      if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
            aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
            aIID.equals(Components.interfaces.nsISupports))
         return this;
      
      throw Components.results.NS_NOINTERFACE;
   },
   
   onStateChange: function(aProgress, aRequest, aFlag, aStatus)
   {
      return 0;
   },
   
   onLocationChange: function(aProgress, aRequest, aURI)
   {
      if (aRequest.name != MY_PAGE_URL)
      {
         var myBrowser = document.getElementById("my_browser");
         myBrowser.loadURI(MY_PAGE_URL, null, null);
      }
                  
      return 0;
   },
   
   onProgressChange: function(aProgress , aRequest , aCurSelfProgress , aMaxSelfProgress , aCurTotalProgress , aMaxTotalProgress)
   {
      return 0;
   },
   
   onStatusChange: function(aProgress , aRequest , aStatus , aMessage)
   {
      return 0;
   },
   
   onSecurityChange: function()
   {
      return 0;
   },
   
   onLinkIconAvailable: function()
   {
      return 0;
   }
}


function onMySideBarLoad()
{
   window.removeEventListener("load", onMySideBarLoad, true);
   var myBrowser = document.getElementById("my_browser");   
   if (myBrowser)
   {
      myBrowser.addProgressListener(myBrowserListener,
            Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
      
      myBrowser.setAttribute("src", MY_PAGE_URL);
   }
}

function mySideBar_init()
{
   window.addEventListener("load", onMySideBarLoad, true);
}


I get this error at this line:
Code: Select all
myBrowser.addProgressListener(myBrowserListener,
            Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);

and myBrowserListener is never hit.
This same code works on Firefox 2.
What could be wrong?

Please help me.

Thanks in advance.

Rafael.

rafaelfc1208

User avatar
 
Posts: 16
Joined: May 30th, 2008, 10:22 am

Post Posted July 10th, 2008, 11:29 am

I solved this problem with a simple change from <overlay to <page in my xul file.

Rafael.

Return to Extension Development


Who is online

Users browsing this forum: No registered users and 1 guest