Open Bug 1296882 Opened 8 years ago Updated 9 months ago

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: 8 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
Priority: P2 → P3
Product: Toolkit → WebExtensions
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: