Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: ios/chrome/browser/ui/contextual_search/resources/contextualsearch_unittest.js

Issue 2553563004: [ios] Adds JS resources for various features. (Closed)
Patch Set: Upload. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/contextual_search/resources/contextualsearch_unittest.js
diff --git a/ios/chrome/browser/ui/contextual_search/resources/contextualsearch_unittest.js b/ios/chrome/browser/ui/contextual_search/resources/contextualsearch_unittest.js
new file mode 100644
index 0000000000000000000000000000000000000000..763fa55058fdd35cf3ef63b1b4108f1d772285be
--- /dev/null
+++ b/ios/chrome/browser/ui/contextual_search/resources/contextualsearch_unittest.js
@@ -0,0 +1,42 @@
+// Copyright 2014 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.
+
+/**
+ * @fileoverview Support code for the Contextual Search unittests feature.
+ *
+ */
+
+
+/**
+ * Namespace for this file. Depends on __gCrWeb['contextualSearch'] having
+ * already been injected.
+ */
+__gCrWeb['contextualSearch_unittest'] = {};
+
+/* Anyonymizing block */
+new function() {
+
+/**
+ * Generate a tap event on an element. Remove the span arround the element.
+ * @param {string} elementID The ID of the element to tap.
+ * @return {object} Empty if element did not trigger CS. Else, the CS context.
+ */
+__gCrWeb['contextualSearch'].tapOnElement = function(elementID) {
+ var element = document.getElementById(elementID);
+ if (element) {
+ var rect = element.getBoundingClientRect();
+ var relativeX = (rect.left + document.body.scrollLeft);
+ var relativeY = (rect.top + document.body.scrollTop);
+ var touch = document.createEvent('TouchEvent');
+ touch.initUIEvent('touchend', true, true);
+ element.dispatchEvent(touch);
+ return __gCrWeb.contextualSearch.handleTapAtPoint(
+ (relativeX + rect.width / 2) / document.documentElement.scrollWidth,
+ (relativeY + rect.height / 2) / document.documentElement.scrollHeight);
+ }
+ return null;
+};
+
+/* Anyonymizing block end */
+}
« no previous file with comments | « ios/chrome/browser/ui/contextual_search/resources/contextualsearch.js ('k') | ios/chrome/browser/ui/downloads/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698