Closed
Bug 935218
Opened 11 years ago
Closed 7 years ago
Add bookmark-menu / sidebar context support to a context-menu API
Categories
(Add-on SDK Graveyard :: General, defect, P3)
Add-on SDK Graveyard
General
Tracking
(Not tracked)
RESOLVED
INCOMPLETE
People
(Reporter: shweta.universidad, Unassigned)
References
Details
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:25.0) Gecko/20100101 Firefox/25.0 (Beta/Release)
Build ID: 20131028113246
Steps to reproduce:
I want to access the bookmark sidebar, so that I can put a menu item in the context menu in the bookmark sidebar and whenever my menu item is clicked, get the element that was clicked on but I am having a rough time trying to access the bookmark sidebar. I've tried a lot of different ways but I am not able to. Here is the basic idea I tried:
var mediator = Cc['@mozilla.org/appshell/window-mediator;1'].getService(Ci.nsIWindowMediator);
var window = mediator.getMostRecentWindow("navigator:browser");
var document = mediator.getMostRecentWindow("navigator:browser").document;
exports.main = function(options, callbacks) {
bookmarkWindow();
// other stuff
};
function bookmarkWindow(){
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
//Also tried with var sidebarWindow = document.getElementById("sidebar").contentDocument; doesn't work
if(sidebarWindow == null){
console.log("NULL");
}
else{
console.log("Sidebarwindow not null." +sidebarWindow.location.href);
}
});
bookmarkMenu.appendChild(observer);
}
Actual results:
When I click View->sidebar->bookmarks:
>console.log: clickme: Bookmark panel showing [object XULElement]
>console.log: clickme: Sidebarwindow not null. about:blank
Expected results:
Should print:
chrome://browser/content/bookmarks/bookmarksPanel.xul
Or if I try:
var bar = sidebarWindow.getElementById("placesContext");
Then shoudn't give me null value but it does!
Please help!!!! Is it so that there is no way I can do what I am trying to do?
Updated•11 years ago
|
Summary: Having big issue accessing the bookmark sidebar → Add bookmark-menu support to a context-menu
Updated•11 years ago
|
Summary: Add bookmark-menu support to a context-menu → Add bookmark-menu / sidebar context support to a context-menu API
Comment 1•11 years ago
|
||
Hi Shweta, I changed a bug description and put it into enhance context menu API with more contexts bucket. I believe just adding a `BookmarkMenuContext` that you can specify in your context menu should address your use case. As of your specific issue, problem is that when bookmark menu is shown it's document isn't loaded yet, that's why you see `about:blank`. Actual bookmark document `chrome://browser/content/bookmarks/bookmarksPanel.xul` will be loaded later in the process. Honestly I don't understand why are you trying to get access to a bookmark-menu contentWindow, having access to it won't help you either since our context-menu API does not has API that would let you pass a window as a context. The closest solution would be to use `URLContext("chrome://browser/content/bookmarks/bookmarksPanel.xul")` (see docs for detais: https://addons.mozilla.org/en-US/developers/docs/sdk/latest/modules/sdk/context-menu.html), although I'm afraid that's not going to work either since I don't beleieve context-menu API supports chrome documents (Cc-ing Mossop he knows this better). My impression is you're just trying to make an old school add-on, in which case this isn't a right component. That's a case, I think what you wanna do in your code is add an event listener on the sidebar to be notified on DOMContentLoaded check if document loaded is a bookmark bar, and if it then do whatever you're planning on doing.
Priority: -- → P3
Updated•11 years ago
|
Flags: needinfo?(dtownsend+bugmail)
Comment 2•11 years ago
|
||
(In reply to Irakli Gozalishvili [:irakli] [:gozala] [@gozala] from comment #1) > Hi Shweta, > > I changed a bug description and put it into enhance context menu API with > more contexts bucket. I believe > just adding a `BookmarkMenuContext` that you can specify in your context > menu should address your use case. > > As of your specific issue, problem is that when bookmark menu is shown it's > document isn't loaded yet, that's why you see `about:blank`. Actual bookmark > document `chrome://browser/content/bookmarks/bookmarksPanel.xul` will be > loaded later in the process. > > Honestly I don't understand why are you trying to get access to a > bookmark-menu contentWindow, having access > to it won't help you either since our context-menu API does not has API that > would let you pass a window > as a context. The closest solution would be to use > `URLContext("chrome://browser/content/bookmarks/bookmarksPanel.xul")` (see > docs for detais: > https://addons.mozilla.org/en-US/developers/docs/sdk/latest/modules/sdk/ > context-menu.html), although I'm afraid that's not going to work either > since I don't beleieve > context-menu API supports chrome documents (Cc-ing Mossop he knows this > better). I did add the beginnings of this when I rewrote context-menu and even had a simple demo of it working with say the tab context menu but it wasn't clear what to do about contexts so I didn't get around to implementing it.
Flags: needinfo?(dtownsend+bugmail)
Reporter | ||
Comment 3•11 years ago
|
||
Hello, I have the tab's context menu implemented because I can access al the firefox's browser.xul elements but with the sidebar is different because it's impossible to access the elements inside it. I was implementing a UI in which the user opens the bookmarks' sidebar and chooses a bookmark to be saved in my server but I found it impossible to implement so, I've implemented by own UI (something like the add-on page that firefox has....). I think that right now, the context menu doesn't work with the xul elements, just with the html document loaded in the page.
Comment 4•7 years ago
|
||
https://bugzilla.mozilla.org/show_bug.cgi?id=1399562
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → INCOMPLETE
You need to log in
before you can comment on or make changes to this bug.
Description
•