Open a new window if shift key is held on window.open call
Categories
(Core :: DOM: Core & HTML, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox123 | --- | fixed |
People
(Reporter: phpcoder2022, Assigned: arai)
References
Details
(Keywords: parity-chrome, parity-safari)
Attachments
(8 files)
5.51 KB,
text/html
|
Details | |
5.51 KB,
text/html
|
Details | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0
Steps to reproduce:
- Open attached page
- Press
Ctrl
and click on chart histogram - See that new tab was opened
- Press
Shift
and click on chart histogram
Actual results:
New tab was opened
Expected results:
New window was opened
Chromium has so behavior and MDN reference says:
Note: Specifying any features in the windowFeatures parameter, other than noopener or noreferrer, also has the effect of requesting a popup.
Note
I need card with link, but user must can copy y
-labels and view histogram title
attribute in this chart. Than I putted link before elements, for that behavior. But script should have identical behavior as native link.
Reporter | ||
Comment 1•10 months ago
|
||
Sorry, I forgot wrote else
in first file. Need use this file
Comment 2•10 months ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Widget: Gtk' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Assignee | ||
Comment 3•10 months ago
|
||
In short:
- the testcase does not request a popup
- chromium opens a new window if shift key is held. it's unrelated to your code
- Safari matches to chromium on this behavior, and Firefox should follow it
- webpage doesn't have an ability to request a new window
The testcase does not request a popup, because of the following section in the spec:
https://html.spec.whatwg.org/multipage/nav-history-apis.html#popup-window-is-requested
The section's behavior is only for backward compatibility. It's not documented on MDN simply because the condition is too complicated and people aren't supposed to use the features like toolbar
or rely on the condition (Safari doesn't follow it).
Webpage does not have an ability to control visibility of UI parts, and features
like toolbar
etc are used only as a condition for requesting popup or not.
Also, it's just a request for the user agent, and the user agent is allowed to do whatever the user want (whether to use tab or not, what UI to show), regardless of the request.
And also, there's no spec-ed way to request a new regular window. It's just "popup or not".
On usual desktop browsers, if popup is requested, they open a popup window with minimal UI (no toolbar, no menu, etc), and if popup is not requested, a new tab is opened. but again, this is not spec-ed and people shouldn't rely on it. for example, it's completely different on mobile browsers.
Then, the behavior difference is unrelated to features
parameter.
The difference can be reproduced with the following testcase:
data:text/html,<div onclick="window.open('about:blank', '_blank')">click me</div>
Chromium opens a new window for window.open
call if shift key is held.
This is not a spec-ed behavior, and it's totally up to user agent what UI to use.
Then, Safari also opens a new window if I shift-click on the above minimal testcase,
so I think Firefox should follow the behavior.
Assignee | ||
Comment 4•10 months ago
•
|
||
here's the result with window.open
+ modifiers:
Chromium | Safari | Firefox | |
---|---|---|---|
no feature + click | foreground tab | foreground tab | foreground tab |
no feature + shift-click | window | window | foreground tab |
no feature + meta-click | background tab | background tab | foreground tab |
no feature + shift-meta-click | foreground tab | foreground tab | foreground tab |
features="foo" + click | popup | window | popup |
features="foo" + shift-click | popup | window | popup |
features="foo" + meta-click | background tab | background tab | popup |
features="foo" + shift-meta-click | foreground tab | foreground tab | popup |
and the result with HTML anchor + modifiers:
Chromium | Safari | Firefox | |
---|---|---|---|
no target + click | current tab | current tab | current tab |
no target + shift-click | window | (save to reading list) | window |
no target + meta-click | background tab | background tab | background tab |
no target + shift-meta-click | foreground tab | foreground tab | foreground tab |
target="_blank" + click | foreground tab | foreground tab | foreground tab |
target="_blank" + shift-click | window | (save to reading list) | window |
target="_blank" + meta-click | background tab | background tab | background tab |
target="_blank" + shift-meta-click | foreground tab | foreground tab | foreground tab |
For HTML anchor, it's controlled by BrowserUtils.whereToOpenLink on Firefox.
we can appy the same for window.open
.
Reporter | ||
Comment 5•10 months ago
|
||
(In reply to Tooru Fujisawa [:arai] from comment #3)
Thanks. You understandly explained all info. Ok, I will wait Firefox enhancement with hope.
Assignee | ||
Updated•10 months ago
|
Assignee | ||
Comment 6•10 months ago
|
||
This could be an alternative to bug 1714939, given users can now control where the popup being opened by modifier keys.
Assignee | ||
Updated•10 months ago
|
Assignee | ||
Comment 7•10 months ago
|
||
In order to achieve "load in a new background tab" operation in window.open
,
add OPEN_NEWTAB_BACKGROUND which is equivalent to OPEN_NEWTAB except for
flipping "load in background" flag.
Assignee | ||
Comment 8•10 months ago
|
||
Associate modifier keys to user activation, in order to use the modifiers
in window.open
initiated by the user activation.
Depends on D197859
Assignee | ||
Comment 9•10 months ago
|
||
Depends on D197860
Assignee | ||
Comment 10•10 months ago
|
||
Depends on D197861
Assignee | ||
Comment 11•10 months ago
|
||
Pass UserActivation::Modifiers from nsGlobalWindowOuter::OpenInternal
to nsPIWindowWatcher.openWindowWithRemoteTab, through the following interfaces
and protocol:
- nsPIWindowWatcher.openWindow2
- nsIWindowProvider.provideWindow
- PContent.CreateWindow or PContent.CreateWindowInDifferentProcess
- nsPIWindowWatcher.openWindowWithRemoteTab
Depends on D197862
Assignee | ||
Comment 12•10 months ago
|
||
Reflect modifiers to chromeFlags and nsIBrowserDOMWindow::OPEN_* location,
to perform the equivalent of BrowserUtils.whereToOpenLink in window.open with
modifier keys.
Depends on D197863
Comment 13•10 months ago
|
||
Comment 14•10 months ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/52ea5f001411
https://hg.mozilla.org/mozilla-central/rev/9fca9bd73923
https://hg.mozilla.org/mozilla-central/rev/cd1f6085cd88
https://hg.mozilla.org/mozilla-central/rev/66b12e633c3e
https://hg.mozilla.org/mozilla-central/rev/2a11630b1ba7
https://hg.mozilla.org/mozilla-central/rev/c968fa42e944
Updated•10 months ago
|
Comment 15•9 months ago
|
||
I would like to understand how this intersects with bug 1081542 and bug 935191 and the prefs mentioned there. Could you elaborate? It doesn't look like comment 4 considered this.
Assignee | ||
Comment 16•9 months ago
|
||
Good point.
The newly added code doesn't take any pref (browser.tabs.loadDivertedInBackground
nor browser.tabs.loadInBackground
) into account and let shift key control whether to activate the tab or not.
This doesn't match existing behavior for links.
here's Firefox behavior for (browser.tabs.loadInBackground
, browser.tabs.loadDivertedInBackground
) pref combinations:
(false ,false ) |
(false ,true ) |
(true ,false ) |
(true ,true ) |
|
---|---|---|---|---|
no target + click | current tab | current tab | current tab | current tab |
no target + shift-click | window | window | window | window |
no target + meta-click | foreground tab | foreground tab | background tab | background tab |
no target + shift-meta-click | background tab | background tab | foreground tab | foreground tab |
no target + middle-click | foreground tab | foreground tab | background tab | background tab |
no target + shift-middle-click | background tab | background tab | foreground tab | foreground tab |
target="_blank" + click | foreground tab | background tab | foreground tab | background tab |
target="_blank" + shift-click | window | window | window | window |
target="_blank" + meta-click | foreground tab | foreground tab | background tab | background tab |
target="_blank" + shift-meta-click | background tab | background tab | foreground tab | foreground tab |
target="_blank" + middle-click | foreground tab | foreground tab | background tab | background tab |
target="_blank" + shift-middle-click | background tab | background tab | foreground tab | foreground tab |
so, browser.tabs.loadInBackground
controls the behavior for meta-click and middle-click,
and window.open
should also reflect it.
then, about bug 935191, it would depend on the definition of "diverted" in term of window.open
,
but it needs to be defined for regular links first in the bug.
Assignee | ||
Updated•6 months ago
|
Description
•