mozilla / web-ext

A command line tool to help build, run, and test web extensions
Mozilla Public License 2.0
2.72k stars 341 forks source link

Popup blocker not working when Firefox is started with web-ext run (window.open has different behaviour) #1369

Open PikeUK opened 6 years ago

PikeUK commented 6 years ago

Is this a feature request or a bug?

Bug (not sure if web-ext or Firefox bug)

What is the current behavior?

When running Firefox from web-ext, window.open will immediately open the URL in a new window. When running Firefox without web-ext it will show the popup blocker, if you allow the popup it opens in a new tab.

Steps to reproduce:

  1. Create a new Firefox profile called test.
  2. Open the attached testcase in Firefox (running the test profile) (observe the popup blocker working as expected).
  3. At a terminal run: web-ext run -p test
  4. Open the testcase in the web-ext Firefox (observe Google immediately opens in a new window).

What is the expected or desired behavior?

Firefox should show the popup blocker, and if allowed by the user, open the url in a new tab not a new window.

Version information (for bug reports)

> node --version
v10.4.1
> npm --version
6.4.0
> web-ext --version
2.9.1
PikeUK commented 6 years ago

Sorry, I can't attach a HTML file, code below:

<!DOCTYPE html>
<html>
<head>
    <title>Window Open Test</title>
    <script>window.open("http://google.com/", "test");</script>
</head>
<body></body>
</html>
Rob--W commented 6 years ago

To enable the popup blocker, use web-ext run --pref=dom.disable_open_during_load=true

It seems that this non-default (well, compared to release versions) setting is set here: https://github.com/saadtazi/firefox-profile-js/blob/4973491648b2c0994277c64b6abf29ca79219d7e/lib/firefox_profile.js#L45

Does this solve your issue?

PikeUK commented 6 years ago

@Rob--W

Setting browser.link.open_newwindow=3 got the open in new tab behaviour I was looking for. Thanks.