Open Bug 1074602 Opened 10 years ago Updated 2 years ago

Allow pop-ups from mousedown/touchstart event

Categories

(Firefox :: General, defect)

32 Branch
defect

Tracking

()

UNCONFIRMED

People

(Reporter: maherrj, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0
Build ID: 20140911151253

Steps to reproduce:

Tell FF to block pop-ups
Visit a page that calls woindow.open() from mousedown/touchstart handler
FireFox is *THE ONLY* browser desktop or mobile to block the pop-up.

(Slight exaggeration IE11 Windows Phone 8 won't honour the call for separate reasons)



Actual results:

FireFox bloxks the window.open


Expected results:

The new window should open.

Last bugs I've seen on this with lengthy discussion are in 2004, After 10 years and the advent of touchstart etc is it not time to swallow your pride and get in line with all other browsers?

FYI. My open() comes from a second mousedown in dblclick sequence check which could be more grist for the "What you're doing is ****" mill.
OS: Windows 7 → All
Hardware: x86_64 → All
Old quote:
"popups are now allowed from mousedown events, see bug 258499."
A marginally more recent quote from the same bug: -

"Reopening as this is now backed out and we've decided to not fix this problem.
Gmail etc will follow with a fix, I'm sure, since it's now broken in both
Firefox and IE on WinXP SP2."

So, congratulations, FireFox is in-step with IE yet poured scorn on by Chrome, Safari, Opera. Android browser desktop and mobile. You must feel very clever :-(

Look I've opted to replace the window name with "_self" to get around FireFox and IE being rediculously retentive. (Furthermore, I'd love to see your click followed by click-and-hold delivery) but feel free to close this and concentrate on not delivering emulated mouse events after a a touchend!
Sorry that was meant to be ". . . after a touchend that calls preventDefault()".
Hi Richard,

I get that this is frustrating, but the vitriol doesn't help. Please try to tone it down.

The current default list of allowed events is:

change click dblclick mouseup reset submit touchend

(this is stored in the dom.popup_allowed_events pref)

Of course, requesting inclusion of mousedown/touchstart is valid. However, I'm not sure what the pros and cons are, besides "browser interop/compat" - where we do also have other bugs on file that say we are too lenient in allowing popups, as compared with e.g. IE11. It would be helpful if you gave describing the pros and cons an honest shot.
Component: Untriaged → General
Summary: Post Touch era - Allow pop-ups from onmousedown event re-visited → Allow pop-ups from mousedown/touchstart event
(In reply to Richard Maher from comment #2)
> ... feel free to close this
> and concentrate on not delivering emulated mouse events after a a touchend!

If this hasn't been filed yet, please file a separate bug for this issue.
(In reply to :Gijs Kruitbosch from comment #5)
> (In reply to Richard Maher from comment #2)
> > ... feel free to close this
> > and concentrate on not delivering emulated mouse events after a a touchend!
> 
> If this hasn't been filed yet, please file a separate bug for this issue.

https://bugzilla.mozilla.org/show_bug.cgi?id=1016480
(In reply to :Gijs Kruitbosch from comment #4)
> Hi Richard,
> 
> I get that this is frustrating, but the vitriol doesn't help. Please try to
> tone it down.
> 

Sorry. It's just that I looked through the history and see comments from Mozilla people like "beginner programmers" from University of Idaho (or Omaha can't remember). Especially anything from Boris after his diatribes on Applets! Condescending is a two way street but I promise to try to wind my neck in.

> The current default list of allowed events is:
> 
> change click dblclick mouseup reset submit touchend
> 
> (this is stored in the dom.popup_allowed_events pref)

What about "contextmenu"?

> 
> Of course, requesting inclusion of mousedown/touchstart is valid. However,
> I'm not sure what the pros and cons are, besides "browser interop/compat" -
> where we do also have other bugs on file that say we are too lenient in
> allowing popups, as compared with e.g. IE11. It would be helpful if you gave
> describing the pros and cons an honest shot.

Look the truth is out there, the arguments have come and gone and personalities prevail. I have moved on and really should change the below code to incorporate contextmenu and dblclick rather than as it is. This is not because of pop-ups but more the invocation of the virtual keyboard. This problem is small beer for me and smaller beer for you. Let's leave it at won't fix and move on?

	ToolboxUWA.prototype.tapDance =
		function(tapTarget,tapOptions) 
			{
				if (arguments.length < 1) throw new Error("Insufficient call arguments");
				
				var SOLOCLICK    = 140;
				var CLICKHOLD    = 600;	
				var clickCount   = 0;
				var touchActive  = false;
				var options      = tapOptions || {};
				var moveTarget   = tapTarget;
				var mouseTimer, soloClick, originEvent, digitId;
				
				var holdDetent = options.holdDetent || CLICKHOLD;
				var tapDetent  = options.tapDetent  || SOLOCLICK;
				
				if (!options.dbltap) tapDetent = 0;
						
				var checkTapAndHold = function() {
					mouseTimer = null;
					if (clickCount == 1) {
						clickCount = 0;
						touchActive = false;
						options.tapandhold.call(originEvent);
					}
				}
				
				var dblClick = function(evt) {
					clickCount = 0;
					touchActive = false;
					if (options.dbltap) options.dbltap.call(originEvent);

					evt.stopImmediatePropagation();
				}
				
				var singleClick = function() {
					soloClick = null;
					if (clickCount == 1) {
						touchActive = false;
						if (options.tap) options.tap.call(originEvent);
					}
					clickCount = 0;
				}
				
				var touchDown = function(evt)
				{
					if (touchActive) return stopEvent(evt);
					touchActive = true;
					
					if (soloClick) { 
						clearTimeout(soloClick);
						soloClick = null;
					}
					
					if (++clickCount > 1) {
						dblClick(evt);
						return true;
					}
					originEvent = evt;
					if (options.tapandhold) mouseTimer = setTimeout(checkTapAndHold,holdDetent);

					if (!(evt.targetTouches == undefined)) {
						digitId = evt.targetTouches.item(0).identifier;
						moveTarget.addEventListener("touchmove", touchOut, false);
					}

					evt.stopImmediatePropagation();
					
					return true;
				}

				var touchUp = function(evt){
					if (!touchActive) return stopEvent(evt);
					cleanUp(evt);
					soloClick  = setTimeout(singleClick,tapDetent);	
					return false;
				}	

				var touchCancel = function(evt){		
					if (!touchActive) return stopEvent(evt);
				
					cleanUp(evt);
					clickCount = 0;
					return true;
				}

				var touchOut = function(evt){		
					if (!touchActive) return stopEvent(evt);
					var touchPoint = evt.touches[digitId];
					if (document.elementFromPoint(touchPoint.clientX, touchPoint.clientY) != moveTarget) {
						return touchCancel(evt);
					}
					return true;
				}
				
				function cleanUp(evt) 
				{
					touchActive = false;
					
					if (mouseTimer) {
						clearTimeout(mouseTimer);
						mouseTimer = null;
					}
					stopEvent(evt);
				}
				
				function addListeners()
				{
					tapTarget.addEventListener(startEvent,  touchDown,   false)
					tapTarget.addEventListener(endEvent,    touchUp,     false)
					tapTarget.addEventListener(cancelEvent, touchCancel, false)
				}
				
				function stopEvent(evt) 
				{
					if (evt.preventDefault && evt.cancelable) evt.preventDefault();
					if (evt.stopPropagation) evt.stopPropagation();
					return false;
				}
					
				tapTarget.addEventListener('MSHoldVisual', stopEvent, false);
				tapTarget.addEventListener('contextmenu',  stopEvent, false);
				tapTarget.addEventListener('selectstart',  stopEvent, false);
				tapTarget.addEventListener('click',        stopEvent, false);
				tapTarget.addEventListener('dblclick',     stopEvent, false);
				
				if (window.PointerEvent) {
					startEvent  = "pointerdown"
					endEvent    = "pointerup"
					cancelEvent = "pointerout"
					addListeners();
				} else {	
					if ('ontouchstart' in window)  {
						startEvent  = "touchstart"
						endEvent    = "touchend"
						cancelEvent = "touchcancel"
						addListeners();
					} else { // Remove ELSE after FireFox fixes bug
					if ('onmousedown' in window)  {
						startEvent  = "mousedown"
						endEvent    = "mouseup"
						cancelEvent = "mouseout"
						addListeners();
					}
					}
				}
				
				return this;
			}
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.