impossible to open small dialog window from addon



Add-on SDK
5 years ago
4 years ago


(Reporter: johannes, Unassigned)


Firefox Tracking Flags

(Not tracked)




5 years ago
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:23.0) Gecko/20100101 Firefox/23.0 (Beta/Release)
Build ID: 20130803193142

Steps to reproduce:

I spent the last 10 hours (sic!) trying to open a small dialog window from my addon with which I can communicate from the addon (via postMessage, addEventListener, port, window.arguments, etc.).

- sdk/tabs open inNewWindow. Did not manage to change the size of the resulting window.

- sdk/windows open. did not manage to set size.

- window/utils open. Was unable to inject code with page-mod into the window with a data.url(...) url. tried attaching a worker by hand to the resulting window but did not succeed. tried sending a message with document.defaultView.postMessage, but without an injected content-script this does not seem to work.

- tried opening a window with nsiWindowWatcher openWindow, but again did not manage to inject a script and/or to communicate with the window.

- tried passing arguments to window.openDialog, but did not manage to pass objects like "var args = {...}" and use them in the window as window.arguments[0]. arrays and functions worked though. tried building an XPCOM instance of nsiSupports with wrappedJSObject but also did not succeed.

- the only thing I have shied away from so far is to build my own XPCOM service for communicating between the window and the addon.

I would be grateful if you could tell me that I wasted my last 10 hours, because there is a simple solution ;)


Actual results:


Expected results:

It would be great if one could do sth like:

var win = require('sdk/windows');
  url: ...
  features: {
    width: 300, 
    height: 300,
    dialog: true,
  contentScriptFile: [...],
  contentScriptWhen: "ready",


Johannes, have you tried the panel module?

This provides a 'pop up' with the ability to provide HTML content and communicate with main code via port events. That being said, I'm going to check out making a third party lib for simple modal options (Twitter Bootstrap style), this seems like it could be of use.

Let me know if Panel does what you're looking for!
Flags: needinfo?(johannes)

Comment 2

5 years ago

thank you for your reply.
I am aware of panel, but I am looking for something more persistent. I'd like users to be able to Alt-Tab to another window and copy-paste something. With panel it closes as soon as another window is focussed or one clicks into the main window.

Another option behavior-wise would be if panel only closed on a specific click into the main window, and not on Alt-Tab, window losing focus, etc.
Flags: needinfo?(johannes)
If it's specific to the page/tab that it's on, and should persist to live there, then something like a page-mod modal should do that, as it can inject a modal window into the DOM for that tab, and can communicate back to your main code. 

Panels are not tab/page specific, unless you want to monitor displaying that panel only on the triggered tab, and reshow it if no action was taken when returning to that tab, for example, but these are all work arounds for something the panel was not intended to do, which leads me to believe that the page-mod may be your best bet!

Comment 4

5 years ago
I looked at the documentation for page-mod and at its source code and could not find anything about a page-mod modal. Is this what you were talking of possibly adding?

Yes, I would love to have a page-specific overlay that is not part of the page's dom-tree. and I think many other extensions might need this for dialogs as well.


5 years ago
Priority: -- → P2

unfortunately there is no easy way to open a dialog from SDK, especially if you want to attach content scripts. I'm not also sure if we want to include such feature in the SDK itself, especially because we're probably going to change how to deal with messages between components (see `sdk/ui/frame`, for example).

However, I made a small 3rd party module that should solve your use case, and added to the 3rd party modules list of Add-on SDK:

Let me know if you have any issue.
Irakli, do you have any opinion about this bug?
Flags: needinfo?(rFobic)
(In reply to Matteo Ferretti [:matteo] [:zer0] from comment #6)
> Irakli, do you have any opinion about this bug?

I think third party module for now is a good option! If such API will end up on our road map I will have nothing against it, but weather it will it's more of a Jeff's call.

I can also imagine that we'll be open for contributions
Flags: needinfo?(rFobic)
Jeff, what do you think?
Flags: needinfo?(jgriffiths)
Like some work I'm doing right now with indexedDB sugar, I think these sorts of things should be 3rd party until we have a sense of how much community interest there is in them

Johannes: within the next few months we will be changing the SDK to support dependencies installed via npm. I suspect if this module was available via npm and it's existence documented and findable via google, you would have found it and been much happier. I apologize for the frustration in the meantime.
Flags: needinfo?(jgriffiths)
This should be a 3rd party module released on npm until it is evident that this is a worth while use case to support within the sdk.
Last Resolved: 4 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.