| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var LOG = function(msg) { | 5 var LOG = function(msg) { |
| 6 window.console.log(msg); | 6 window.console.log(msg); |
| 7 }; | 7 }; |
| 8 | 8 |
| 9 var startTest = function() { | 9 var startTest = function() { |
| 10 var webview = document.querySelector('webview'); | 10 var webview = document.querySelector('webview'); |
| 11 var onLoadStop = function(e) { | 11 var onLoadStop = function(e) { |
| 12 webview.contentWindow.postMessage(JSON.stringify(['connect']),'*'); | 12 webview.contentWindow.postMessage(JSON.stringify(['connect']),'*'); |
| 13 }; | 13 }; |
| 14 | 14 |
| 15 webview.addEventListener('loadstop', onLoadStop); | 15 webview.addEventListener('loadstop', onLoadStop); |
| 16 webview.addEventListener('consolemessage', function(e) { | 16 webview.addEventListener('consolemessage', function(e) { |
| 17 LOG('g: ' + e.message); | 17 LOG('g: ' + e.message); |
| 18 }); | 18 }); |
| 19 webview.partition = 'partition1'; | 19 webview.partition = 'partition1'; |
| 20 webview.src = 'guest.html'; | 20 webview.src = 'guest.html'; |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 window.addEventListener('message', function(e) { | 23 window.addEventListener('message', function(e) { |
| 24 var data = JSON.parse(e.data); | 24 var data = JSON.parse(e.data); |
| 25 LOG('data: ' + data); | 25 LOG('data: ' + data); |
| 26 switch (data[0]) { | 26 switch (data[0]) { |
| 27 case 'connected': | 27 case 'connected': |
| 28 chrome.test.sendMessage('WebViewTest.LAUNCHED'); | 28 chrome.test.sendMessage('LAUNCHED'); |
| 29 break; | 29 break; |
| 30 case 'installed-touch-handler': | 30 case 'installed-touch-handler': |
| 31 case 'uninstalled-touch-handler': | 31 case 'uninstalled-touch-handler': |
| 32 chrome.test.sendMessage(data[0]); | 32 chrome.test.sendMessage(data[0]); |
| 33 break; | 33 break; |
| 34 } | 34 } |
| 35 }); | 35 }); |
| 36 | 36 |
| 37 chrome.test.getConfig(function(config) { | 37 chrome.test.getConfig(function(config) { |
| 38 var guestURL = 'data:text/html,<html><body>foo</body></html>'; | 38 var guestURL = 'data:text/html,<html><body>foo</body></html>'; |
| 39 document.querySelector('#webview-tag-container').innerHTML = | 39 document.querySelector('#webview-tag-container').innerHTML = |
| 40 '<webview style="width: 10px; height: 10px; margin: 0; padding: 0;"' + | 40 '<webview style="width: 10px; height: 10px; margin: 0; padding: 0;"' + |
| 41 '></webview>'; | 41 '></webview>'; |
| 42 startTest(); | 42 startTest(); |
| 43 }); | 43 }); |
| OLD | NEW |