Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
|
Charlie Reis
2015/02/19 22:56:28
nit: 2015
(Or is this just a move?)
Fady Samuel
2015/02/20 00:33:06
This is a move. from teardown.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 function CreateWebViewAndGuest(callback) { | |
| 6 var webview = document.createElement('webview'); | |
| 7 var onLoadStop = function(e) { | |
| 8 chrome.test.sendMessage('WebViewTest.LAUNCHED'); | |
| 9 webview.removeEventListener('loadstop', onLoadStop); | |
| 10 webview.removeEventListener('loadabort', onLoadAbort); | |
| 11 callback(); | |
| 12 }; | |
| 13 webview.addEventListener('loadstop', onLoadStop); | |
| 14 | |
| 15 var onLoadAbort = function(e) { | |
| 16 chrome.test.sendMessage('WebViewTest.FAILURE'); | |
| 17 webview.removeEventListener('loadstop', onLoadStop); | |
| 18 webview.removeEventListener('loadabort', onLoadAbort); | |
| 19 }; | |
| 20 webview.src = 'data:text/html,<html><body>simple test</body></html>'; | |
| 21 return webview; | |
| 22 } | |
| 23 | |
| 24 onload = function() { | |
| 25 var webview = CreateWebViewAndGuest(function() { | |
| 26 webview.addEventListener('newwindow', function(e) { | |
| 27 var newwebview = document.createElement('webview'); | |
| 28 newwebview.addEventListener('loadstop', function(e) { | |
| 29 chrome.test.sendMessage('WebViewTest.NEWWINDOW'); | |
| 30 }); | |
| 31 e.window.attach(newwebview); | |
| 32 document.body.appendChild(newwebview); | |
| 33 }); | |
| 34 | |
| 35 webview.addEventListener('loadstop', function(e) { | |
| 36 chrome.test.sendMessage('WebViewTest.LOADSTOP'); | |
| 37 }); | |
| 38 }); | |
| 39 document.body.appendChild(webview); | |
| 40 }; | |
| OLD | NEW |