Chromium Code Reviews| Index: chrome/browser/resources/ntp4/synthetic_middleclick.js |
| diff --git a/chrome/browser/resources/ntp4/synthetic_middleclick.js b/chrome/browser/resources/ntp4/synthetic_middleclick.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..80e15598b8825bdc99e42647607c715205167218 |
| --- /dev/null |
| +++ b/chrome/browser/resources/ntp4/synthetic_middleclick.js |
| @@ -0,0 +1,24 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +(function() { |
| + |
| +var middleButtonMouseDownTarget = null; |
| + |
| +document.addEventListener('mousedown', function(e) { |
| + if (e.button == 1) |
| + middleButtonMouseDownTarget = e.path[0]; |
| +}, true); |
| + |
| +document.addEventListener('mouseup', function(e) { |
| + if (e.button != 1) |
| + return; |
| + |
| + if (e.path[0] == middleButtonMouseDownTarget) |
|
Dan Beam
2016/05/24 18:48:00
btw, it probably doesn't matter, but if e.path.len
Navid Zolghadr
2016/05/24 19:22:30
I added the length check as well. I guess that wou
|
| + middleButtonMouseDownTarget.dispatchEvent(new MouseEvent('click', e)); |
| + |
| + middleButtonMouseDownTarget = null; |
| +}, true); |
| + |
| +})(); |