[Webkit-unassigned] [Bug 70070] Middle click on some links opens link in current tab

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Oct 15 19:11:14 PDT 2011


https://bugs.webkit.org/show_bug.cgi?id=70070


Daniel Bates <dbates at webkit.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dbates at webkit.org




--- Comment #2 from Daniel Bates <dbates at webkit.org>  2011-10-15 19:11:15 PST ---
>From observation and briefly looking at the source code for the page in Web Inspector, this BBC News page captures mouse click events and selectively overrides the default browser behavior using document.location.href.

I don't have a mouse with a middle mouse button. So, I programmatically generated a DOM Click event for the middle mouse button and dispatched it at the example hyperlink using Web Inspector and the following script (*):

var link = document.querySelector("a[href='http://www.nti.org/e_research/e3_88.html']");
var mouseEvent = document.createEvent("MouseEvents");
mouseEvent.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 1, null);
link.dispatchEvent(mouseEvent);

Using Xcode's debugger (**) and middle clicking on the example hyperlink mentioned in the bug description (comment 0) we see that Location::setHref(), <http://trac.webkit.org/browser/trunk/Source/WebCore/page/Location.cpp?rev=96779#L155>, is ultimately called; => BBC News captures the DOM Click event and ultimately overrides the value of document.location.href with <http://www.nti.org/e_research/e3_88.html> (the URL associated with this hyperlink). Hence, we navigate the current page to this new URL instead of opening a new tab (the default browser behavior).

Consistent with the bug description, middle clicking on a non-external hyperlink, say for the article "Do we understand 'risk' of mobile phone use?", doesn't override the value of document.location.href and the article opens in a new tab.

(*) See <https://developer.mozilla.org/en/DOM/event.initMouseEvent>/<http://www.w3.org/TR/DOM-Level-3-Events/#events-event-type-initMouseEvent> for a composite breakdown of the arguments to initMouseEvent().

(**) The page at <http://www.bbc.co.uk/news/magazine-15288975> loads many obfuscated JavaScript scripts. These obfuscated script make it difficult to identify the script or snippet that is responsible for this behavior. If I have additional time, I'll try to identify the script or snippet that is responsible for the observed behavior.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list