alert/confirm/prompt from background page



2 years ago
6 months ago


(Reporter: eros_uk, Unassigned)


53 Branch

Firefox Tracking Flags

(Not tracked)




2 years ago
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
Build ID: 20170307064827

Steps to reproduce:

As stated in (
> Firefox does not support using alert(), confirm(), or prompt() from background pages.

As I haven't seen any development on the 2-year-old general issue (Ref: bug 1214174), although it is marked as fixed, I have started this topic specific to alert/confirm/prompt.

There are occasions that alert/confirm/prompt are needed from the background script. In fact, I have one addon that does not have any content script whatsoever.

Creating a content script just for alert/confirm/prompt and/or passing messages to and fro just for alert/confirm/prompt is yet another hacking-way of accessing alert/confirm/prompt.

Furthermore, bearing in mind that tabs.executeScript is prevented by Firefox on some tabs, many functions unrelated to the contents (blocked or otherwise) run into difficulty due to not having access to alert/confirm/prompt.
See the discussion in bug 1203394.
Last Resolved: 2 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1203394

Comment 2

2 years ago
Why was the bug closed?

Bug 1203394 Status (bug has been fixed and VERIFIED for Firefox 49) 

> alert() is not supported in background windows; please use console.log instead.   ext-c-backgroundPage.js:15:7

> NS_ERROR_NOT_AVAILABLE: Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIDOMWindowUtils.isParentWindowMainWidgetVisible]  nsPrompter.js:350
> [Exception... "Unexpected error"  nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)"  location: "JS frame :: moz-extension://6715edd4-5ec9-42c7-adea-daa9e297c57c/content/background.js :: process :: line 20"  data: no]

The purpose of this bug was to state why it is needed to have alert/confirm/prompt from background script, like other browsers such as Chrome. In other words, why it is necessary to change the status que.

The other referenced bug does not answer this question. Instead it states that it is how Firefox is dong it at the moment.

The status of "bug has been fixed and VERIFIED for Firefox 49" does not reflect accurately.

Alert() bug was not fixed. It was decided to output a log instead of alert() which is not what alert() is for.
If the desired effect was to output to the console, developers would have used the console.log and not alert()


6 months ago
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.