Open Bug 1296882 Opened 4 years ago Updated Last year

WebExtensions should not be subject to the popup blocker

Categories

(WebExtensions :: General, defect, P3)

50 Branch
defect

Tracking

(Not tracked)

REOPENED

People

(Reporter: dteviot, Unassigned)

References

Details

(Whiteboard: [design-decision-approved]triaged)

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36

Steps to reproduce:

I have a Web Extension.
If I call Window.open() in response to a user clicking a button, it works.
If I call Window.open() in the callback to, say, chrome.tabs.query() no window opens.

Example code
```javascript
    function onOpenWindowWithClickButton() {
        let url = chrome.extension.getURL("tab.html");
        window.open(url, "_blank");
    }

    function onOpenWindowWithCallbackButton() {
        chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) { 
            onOpenWindowWithClickButton();
        });
    }

    // actions to do when window opened
    window.onload = function () {
        // add onClick event handlers
        document.getElementById("openWindowWithClickButton").onclick = onOpenWindowWithClickButton;
        document.getElementById("openWindowWithCallbackButton").onclick = onOpenWindowWithCallbackButton;
    }
```

Attached is minimal extension to demonstrate behaviour.
Problem occurs on both Firefox 48 and 50.



Actual results:

No window appears when call Window.open in callback.


Expected results:

Window should be created
Component: Untriaged → WebExtensions
Product: Firefox → Toolkit
This is because the popup blocker only allows window.open to be called in direct response to user interaction. If you want to open a window asynchronously, you can use browser.windows.create or browser.tabs.create.
Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Resolution: --- → INVALID
Status: RESOLVED → REOPENED
Component: WebExtensions → WebExtensions: General
Ever confirmed: true
Resolution: INVALID → ---
Summary: Window.open() does not work from callback in WebExtension. → WebExtensions should not be subject to the popup blocker
Whiteboard: [design-decision-needed]
Priority: -- → P2
Whiteboard: [design-decision-needed] → [design-decision-approved]triaged
Duplicate of this bug: 1307503
Priority: P2 → P3
Duplicate of this bug: 1466347
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.