title: How to access the bookmark panel using javascript in firefox?
body: <p>I am developing a firefox addon and I have to access the bookmark panel (to see it go to View->Sidebar->Bookmarks) and add a menu item to its context menu and when the menu item is clicked, get the item it was clicked on.</p>
  
  <p>Por example:
  You open the bookmark panel and right click on Most Visited item and click on my menu item, then I want to know that the Most Visited item was clicked.</p>
  
  <p>I tried the following code but with no success:</p>
  
  <pre><code>var bookmarkMenu = document.getElementById('menu_bookmarksSidebar');
  var observer = document.createElement('observes'); //Observe when the bookmark panel shows
  observer.setAttribute('element','viewBookmarksSidebar');
  observer.setAttribute('attribute','checked');
  observer.addEventListener('broadcast',function(event){
  console.log("Bookmark panel showing " + event.target);
  
  var sidebarWindow = document.getElementById("sidebar").contentWindow;//Try to get the sidebar window
  if(sidebarWindow == null){
  console.log("NULL");
  }
  var bar = sidebarWindow.getElementById("placesContext");
  if (bar == null){
  console.log("NO Sidebar window");
   }
  
  
  });
  bookmarkMenu.appendChild(observer);
  </code></pre>
  
  <p>I know how to access the browser window but I am unable to access the sidebar window.
  According to bookmarkPanel.xul, the id of context menu of that panel is "placeContext" but I can't access it. How I can I access the right-clicked bookmark/element?</p>
  
  <p>event.target always gives me [object xulElement], how can I see what element it is?</p>
  
  <p>I tried this:</p>
  
  <pre><code>var sXML = new XMLSerializer().serializeToString(event.target);
  </code></pre>
  
  <p>But doesn't seem to work</p>
  
  <p>Thanks</p>