Closed Bug 410559 Opened 17 years ago Closed 17 years ago

contentDocument of 'sidebar' appears to be corrupted

Categories

(Firefox :: Bookmarks & History, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED DUPLICATE of bug 406697

People

(Reporter: mr_wgee, Unassigned)

Details

(Keywords: regression)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b2) Gecko/2007121120 Firefox/3.0b2
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b2) Gecko/2007121120 Firefox/3.0b2

With the bookmarks sidebar visible, Firefox throws an exception when I try to access the contentDocument of the 'sidebar' element. E.g.:

top.document.getElementById('sidebar').contentDocument

This does not happen with FF3.0b1.

Reproducible: Always

Steps to Reproduce:
1. Install my demo extension per instructions in "Additional Information" below
2. Start Firefox 3.0b2
3. Make sure the bookmarks sidebar is visible
4. Restart Firefox
5. Hide bookmarks sidebar
6. Show bookmarks sidebar
7. Select "Pick ME" from the bottom of the View menu
8. Click through alerts() to see exception
Actual Results:  
EXCEPTION: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIWebNavigation.document]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: chrome://global/content/bindings/browser.xml :: get_contentDocument :: line 0"  data: no]

Expected Results:  
I should get a valid contentDocument so my demo extension should say "try is SUCCESSFUL".

To make my demo extension follow these instructions.
Get and install the sample status bar from here:

http://developer.mozilla.org/samples/extension-samples/status-bar-sample-1.zip

REPLACE chrome/content/status-bar-sample-1.xul with this:
----------------------------------------------------------START
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE overlay >
<overlay id="status-bar-sample-1-overlay"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<!-- Firefox -->

<script type="application/x-javascript" src="chrome:/content/pickme.js"/>

<menubar id="main-menubar">
  <menu id="view-menu" >
    <menupopup id="menu_viewPopup">
      <menuseparator/>
      <menuitem id="myMenuItem" label="Pick ME" oncommand="pickme();" />
    </menupopup>
  </menu>
</menubar>

</overlay>
----------------------------------------------------------END

SAVE this JS code block to chrome/content/pickme.js
----------------------------------------------------------START
function pickme ()
{
  var sidbarDoc = null;

  alert ("pickme() called");
  try
  {
      var sidebar = top.document.getElementById('sidebar');
      if (sidebar.contentDocument == null)
      {
        alert ("contentDocument is NULL");
      }
      else
      {
        alert ("contentDocument is GOOD");
        sidebarDoc = sidebar.contentDocument;
        alert ("try is SUCCESSFUL");
      }
  }
  catch(e)
  {
    alert ("EXCEPTION: " + e);
  }
}
----------------------------------------------------------END
I have witnessed this behavior as well with the Mahalo Follow extension ( http://follow.mahalo.com/ ).  It will work fine (showing new results in the sidebar as you surf) unless you close and open the sidebar again, at which point the contentDocument of the sidebar cannot be accessed and the sidebar will just show a "loading" graphic indefinitely.
This behavior appears to not be compatible with Fx2.

Another case: http://groups.google.com/group/mozilla.dev.extensions/browse_frm/thread/96b6fea25918d4f0/472c4b38777ac833?
Flags: blocking-firefox3?
Also, possibly related to this bug, is if you restart the browser and Firefox tries to restore the sidebar from a previous session, I get this error in 3b2:

Error: [Exception... "Component returned failure code: 0x80004005
(NS_ERROR_FAILURE) [nsIWebNavigation.sessionHistory]"  nsresult:
"0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame ::
chrome://global/content/bindings/browser.xml ::  :: line 582"  data:
no] Source File: chrome://global/content/bindings/browser.xml Line: 588 
(In reply to comment #0)
> EXCEPTION: [Exception... "Component returned failure code: 0x80004005
> (NS_ERROR_FAILURE) [nsIWebNavigation.document]"  nsresult: "0x80004005
> (NS_ERROR_FAILURE)"  location: "JS frame ::
> chrome://global/content/bindings/browser.xml :: get_contentDocument :: line 0" 
> data: no]

See bug 406340 (and bug 406697).

(In reply to comment #3)
> Error: [Exception... "Component returned failure code: 0x80004005
> (NS_ERROR_FAILURE) [nsIWebNavigation.sessionHistory]"  nsresult:
> "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame ::
> chrome://global/content/bindings/browser.xml ::  :: line 582"  data:
> no] Source File: chrome://global/content/bindings/browser.xml Line: 588 

Maybe that should be filled as a separate (dependent) bug ?
Blocks: 406340
Status: UNCONFIRMED → NEW
Depends on: 406697
Ever confirmed: true
Version: unspecified → Trunk
(In reply to comment #0)
> This does not happen with FF3.0b1.

Could you/someone look for a narrower regression timeframe ?

> 1. Install my demo extension per instructions in "Additional Information" below

Would it be possible for you to prepare a testcase, without having to install an extension ?
Keywords: regression
> Would it be possible for you to prepare a testcase, without having to 
> install an extension ?

You can just poke document.getElementById('sidebar').contentDocument using the extension developer's extension.

For automated testing purposes one could write a page that uses this code to access the browser.xul window from content:
http://developer.mozilla.org/en/docs/Working_with_windows_in_chrome_code#Accessing_the_elements_of_the_top-level_document_from_a_child_window - then poke the sidebar's document using that window.
> Would it be possible for you to prepare a testcase, without having to install
> an extension ?

I'm still new to the Mozilla world so I wouldn't know how to find a simplier testcase. Try Nickolay's suggestion.

> Could you/someone look for a narrower regression timeframe ?

I tried my testcase with builds from https://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/2007/11/

It works for build 2007112505 but fails (with the exception in comment #0) with build 2007112605. Also fails for 2007120105 and 2007112705.
(In reply to comment #8)
> This looks very much like bug 406697 comment 3 !
> Let's wait for that bug to be fixed ;-)
> 
It is the same.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → DUPLICATE
Flags: blocking-firefox3?
No longer blocks: 385224, 406340
No longer depends on: 406697
Target Milestone: Firefox 3 beta3 → ---
(In reply to comment #4)
> (In reply to comment #3)
> > Error: [Exception... "Component returned failure code: 0x80004005
> > (NS_ERROR_FAILURE) [nsIWebNavigation.sessionHistory]"  nsresult:
> > "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame ::
> > chrome://global/content/bindings/browser.xml ::  :: line 582"  data:
> > no] Source File: chrome://global/content/bindings/browser.xml Line: 588 
> 
> Maybe that should be filled as a separate (dependent) bug ?

This other exception is bug 408668.
You need to log in before you can comment on or make changes to this bug.