Index: chrome/test/data/extensions/platform_apps/web_view/accept_touch_events/guest.js |
diff --git a/chrome/test/data/extensions/platform_apps/web_view/accept_touch_events/guest.js b/chrome/test/data/extensions/platform_apps/web_view/accept_touch_events/guest.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bc3597e745c138964f553651a4568ec2fb38e5df |
--- /dev/null |
+++ b/chrome/test/data/extensions/platform_apps/web_view/accept_touch_events/guest.js |
@@ -0,0 +1,51 @@ |
+// 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. |
+ |
+var LOG = function(msg) { |
+ window.console.log(msg); |
+}; |
+ |
+var touchDiv; |
+var embedder; |
+ |
+function init() { |
+ touchDiv = document.createElement('div'); |
+ touchDiv.innerText = 'With touch'; |
+ document.body.appendChild(touchDiv); |
+} |
+ |
+function handler() {} |
+ |
+function onAppCommand(command) { |
+ LOG('onAppCommand, command = ' + command); |
+ switch (command) { |
+ case 'install-touch-handler': |
+ touchDiv.addEventListener('touchstart', handler); |
+ sendMessageToEmbedder('installed-touch-handler'); |
+ break; |
+ case 'uninstall-touch-handler': |
+ touchDiv.removeEventListener('touchstart', handler); |
+ sendMessageToEmbedder('uninstalled-touch-handler'); |
+ break; |
+ } |
+}; |
+ |
+function sendMessageToEmbedder(message) { |
+ if (!embedder) { |
+ LOG('no embedder channel to send postMessage'); |
+ return; |
+ } |
+ |
+ embedder.postMessage(JSON.stringify([message]), '*'); |
+} |
+ |
+window.addEventListener('message', function(e) { |
+ embedder = e.source; |
+ var data = JSON.parse(e.data); |
+ if (data[0] == 'connect') { |
+ sendMessageToEmbedder('connected'); |
+ } |
+}); |
+ |
+window.onload = init; |