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 var LOG = function(msg) { | |
6 window.console.log(msg); | |
7 }; | |
8 | |
9 var failTest = function() { | |
10 chrome.test.sendMessage('WebViewTest.FAILURE'); | |
11 }; | |
12 | |
13 var firstTime = true; | |
14 | |
15 var startTest = function() { | |
16 document.querySelector('#webview-tag-container').innerHTML = | |
17 '<webview style="width: 10px; height: 10px; margin: 0; padding: 0;"' + | |
18 '></webview>'; | |
19 | |
20 var webview = document.querySelector('webview'); | |
21 var onLoadStop = function(e) { | |
22 if (firstTime) { | |
23 firstTime = false; | |
24 chrome.test.sendMessage('WebViewTest.LAUNCHED'); | |
25 } else { | |
26 chrome.test.sendMessage('WebViewTest.PASSED'); | |
27 } | |
28 }; | |
29 | |
30 webview.addEventListener('loadstop', onLoadStop); | |
31 webview.src = 'data:text/html,<body>Guest</body>'; | |
32 }; | |
33 | |
34 window.onAppCommand = function(command) { | |
35 LOG('onAppCommand: ' + command); | |
36 switch (command) { | |
37 case 'hide-guest': | |
38 document.querySelector('webview').style.display = 'none'; | |
39 break; | |
40 case 'show-guest': | |
41 document.querySelector('webview').style.display = ''; | |
42 break; | |
43 default: | |
44 failTest(); | |
45 break; | |
46 } | |
47 }; | |
48 | |
49 window.onload = startTest; | |
OLD | NEW |