Closed Bug 433274 Opened 12 years ago Closed 10 months ago

opening a new window in an "oncontextmenu" handler is prevented by the popup blocker

Categories

(Core :: DOM: Core & HTML, defect, P5)

x86
Windows XP
defect

Tracking

()

RESOLVED FIXED
mozilla67
Tracking Status
firefox67 --- fixed

People

(Reporter: giliwala, Assigned: baku)

References

()

Details

Attachments

(3 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5

1、in "onclick" event of "<a>" tag, execute "window.open()" , then a new window will be opened.
2、in "oncontextmenu" event of "<a>" tag, execute "window.open()" , but no new window will be opened.

Reproducible: Always

Steps to Reproduce:
1.new a .html file.
2.input the source code as below: 

<p><a href="javascript:void 0" onclick="javascript:alert('it is ok here');window.open('','_blank','');alert('it is ok here too.');return(false);" oncontextmenu="javascript:alert('it is ok here');window.open('','_blank','');alert('it is not ok here.');return(false);">Test</a><br></p>

3.save it with any name.

Actual Results:  
1.load the page file into Firefox.
2.left click on the link "Test": a new window will be opened, it is ok.
3.right click on the link "Test": no new window will be opened, it is wrong.


Expected Results:  
when right click on the link "Test", it should open a new window.

the source code above looks fine in IE, but it is not fine in Firefox.
This isn't a security sensitive bug.

Your testcase works fine for me when I disabled the popup blocker.  "oncontextmenu" handlers are not considered explicit user actions.
Group: security
Component: General → DOM
Keywords: dom1
Product: Firefox → Core
QA Contact: general → general
Summary: it can't open a new window in "oncontextmenu" event of the "<a>" tag. → opening a new window in an "oncontextmenu" handler is prevented by the popup blocker
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046

Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5

(In reply to :Gavin Sharp [email: gavin@gavinsharp.com] from comment #2)

...
Your testcase works fine for me when I disabled the popup blocker.
"oncontextmenu" handlers are not considered explicit user actions.

WFM?

Flags: needinfo?(ryanvm)

Gijs, you might know better than I would?

Flags: needinfo?(ryanvm) → needinfo?(gijskruitbosch+bugs)

The complaint is that windows opened from contextmenu event handlers get blocked by the popup blocker, and windows opened from click event handlers don't, with the web developer expectation being that contextmenu windows also don't get blocked.

This report is still valid in the sense that that is still what happens today, in both Firefox and Chrome (haven't tested other browsers).

Users can work around locally by altering the hidden pref dom.popup_allowed_events to include contextmenu. I think a patch would be as simple as making that change in the default value of that pref.

We could mark it invalid/wontfix if we don't think contextmenu events should be handled the same as click events. I don't have a strong opinion either way. The decision is up to the DOM team, but if I'm right about how easy it is to fix, we should explicitly make the decision by either "just" fixing or by wontfixing, not leaving it open and ambiguous.

Hsin-Yi, can you ask the DOM team to make a decision? Thanks.

Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(htsai)

Thanks Gijs for the first investigation. I'll get back to here with the team's decision.

I don't see this happening in Chrome, on linux.

I think we should fix this.

Attached file cmenu.html

baku, do you have any opinion on this, given the recent popup blocking work you've been doing?

Flags: needinfo?(htsai) → needinfo?(amarchesini)
Flags: needinfo?(amarchesini)
Assignee: nobody → amarchesini
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Pushed by amarchesini@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/05ec02aaa6bb
Allow popups from context menu events, r=smaug
Pushed by amarchesini@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/571569056837
Allow popups from context menu events - part 2, r=smaug
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.