OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 function CreateWebViewAndGuest(callback) { | 5 function CreateWebViewAndGuest() { |
6 var webview = document.createElement('webview'); | 6 var webview = document.createElement('webview'); |
| 7 webview.allowtransparency = true; |
| 8 webview.allowscaling = true; |
7 var onLoadStop = function(e) { | 9 var onLoadStop = function(e) { |
8 chrome.test.sendMessage('WebViewTest.LAUNCHED'); | 10 chrome.test.sendMessage('WebViewTest.LAUNCHED'); |
9 webview.removeEventListener('loadstop', onLoadStop); | 11 webview.removeEventListener('loadstop', onLoadStop); |
10 webview.removeEventListener('loadabort', onLoadAbort); | 12 webview.removeEventListener('loadabort', onLoadAbort); |
11 callback(); | |
12 }; | 13 }; |
13 webview.addEventListener('loadstop', onLoadStop); | 14 webview.addEventListener('loadstop', onLoadStop); |
14 | 15 |
15 var onLoadAbort = function(e) { | 16 var onLoadAbort = function(e) { |
16 chrome.test.sendMessage('WebViewTest.FAILURE'); | 17 chrome.test.sendMessage('WebViewTest.FAILURE'); |
17 webview.removeEventListener('loadstop', onLoadStop); | 18 webview.removeEventListener('loadstop', onLoadStop); |
18 webview.removeEventListener('loadabort', onLoadAbort); | 19 webview.removeEventListener('loadabort', onLoadAbort); |
19 }; | 20 }; |
20 webview.src = 'data:text/html,' + | 21 |
21 '<html><body><button>Guest button</button></body></html>'; | 22 webview.src = 'data:text/html,<!DOCTYPE html>\n' + |
| 23 '<style>\n' + |
| 24 'select {\n' + |
| 25 ' position: absolute;\n' + |
| 26 ' top: 9px;\n' + |
| 27 ' left: 9px;\n' + |
| 28 ' height: 25px;\n' + |
| 29 ' width: 80px;\n' + |
| 30 '}\n' + |
| 31 '</style>\n' + |
| 32 '<html>\n' + |
| 33 ' <body>\n' + |
| 34 ' <select>\n' + |
| 35 ' <option selected>Apple</option>\n' + |
| 36 ' <option>Orange</option>\n' + |
| 37 ' <option>Banana</option>\n' + |
| 38 ' </select>\n' + |
| 39 ' </body>\n' + |
| 40 '</html>\n'; |
| 41 |
22 return webview; | 42 return webview; |
23 } | 43 } |
24 | 44 |
25 onload = function() { | 45 onload = function() { |
26 var webview = CreateWebViewAndGuest(function() { | 46 var webview = CreateWebViewAndGuest(); |
27 webview.addEventListener('newwindow', function(e) { | |
28 var newwebview = document.createElement('webview'); | |
29 newwebview.addEventListener('loadstop', function(e) { | |
30 chrome.test.sendMessage('WebViewTest.NEWWINDOW'); | |
31 }); | |
32 e.window.attach(newwebview); | |
33 document.body.appendChild(newwebview); | |
34 }); | |
35 | |
36 webview.addEventListener('loadstop', function(e) { | |
37 chrome.test.sendMessage('WebViewTest.LOADSTOP'); | |
38 }); | |
39 }); | |
40 document.body.appendChild(webview); | 47 document.body.appendChild(webview); |
41 }; | 48 }; |
OLD | NEW |