| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @fileoverview Support code for the Contextual Search unittests feature. |
| 7 * |
| 8 */ |
| 9 |
| 10 |
| 11 /** |
| 12 * Namespace for this file. Depends on __gCrWeb['contextualSearch'] having |
| 13 * already been injected. |
| 14 */ |
| 15 __gCrWeb['contextualSearch_unittest'] = {}; |
| 16 |
| 17 /* Anyonymizing block */ |
| 18 new function() { |
| 19 |
| 20 /** |
| 21 * Generate a tap event on an element. Remove the span arround the element. |
| 22 * @param {string} elementID The ID of the element to tap. |
| 23 * @return {object} Empty if element did not trigger CS. Else, the CS context. |
| 24 */ |
| 25 __gCrWeb['contextualSearch'].tapOnElement = function(elementID) { |
| 26 var element = document.getElementById(elementID); |
| 27 if (element) { |
| 28 var rect = element.getBoundingClientRect(); |
| 29 var relativeX = (rect.left + document.body.scrollLeft); |
| 30 var relativeY = (rect.top + document.body.scrollTop); |
| 31 var touch = document.createEvent('TouchEvent'); |
| 32 touch.initUIEvent('touchend', true, true); |
| 33 element.dispatchEvent(touch); |
| 34 return __gCrWeb.contextualSearch.handleTapAtPoint( |
| 35 (relativeX + rect.width / 2) / document.documentElement.scrollWidth, |
| 36 (relativeY + rect.height / 2) / document.documentElement.scrollHeight); |
| 37 } |
| 38 return null; |
| 39 }; |
| 40 |
| 41 /* Anyonymizing block end */ |
| 42 } |
| OLD | NEW |