Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / extensions / test / data / web_view / accept_touch_events / main.js
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 var LOG = function(msg) {
6   window.console.log(msg);
7 };
8
9 var startTest = function() {
10   var webview = document.querySelector('webview');
11   var onLoadStop = function(e) {
12     webview.contentWindow.postMessage(JSON.stringify(['connect']),'*');
13   };
14
15   webview.addEventListener('loadstop', onLoadStop);
16   webview.addEventListener('consolemessage', function(e) {
17     LOG('g: ' + e.message);
18   });
19   webview.partition = 'partition1';
20   webview.src = 'guest.html';
21 };
22
23 window.addEventListener('message', function(e) {
24   var data = JSON.parse(e.data);
25   LOG('data: ' + data);
26   switch (data[0]) {
27     case 'connected':
28       chrome.test.sendMessage('LAUNCHED');
29       break;
30     case 'installed-touch-handler':
31     case 'uninstalled-touch-handler':
32       chrome.test.sendMessage(data[0]);
33       break;
34   }
35 });
36
37 chrome.test.getConfig(function(config) {
38   var guestURL = 'data:text/html,<html><body>foo</body></html>';
39   document.querySelector('#webview-tag-container').innerHTML =
40       '<webview style="width: 10px; height: 10px; margin: 0; padding: 0;"' +
41       '></webview>';
42   startTest();
43 });