Chromium Code Reviews| Index: chrome/test/data/extensions/platform_apps/web_view/simple/main.js |
| diff --git a/chrome/test/data/extensions/platform_apps/web_view/simple/main.js b/chrome/test/data/extensions/platform_apps/web_view/simple/main.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7e0648395a1d2d3db36a9b2bc03d581e8fe96823 |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/platform_apps/web_view/simple/main.js |
| @@ -0,0 +1,40 @@ |
| +// 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.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +function CreateWebViewAndGuest(callback) { |
| + var webview = document.createElement('webview'); |
| + var onLoadStop = function(e) { |
| + chrome.test.sendMessage('WebViewTest.LAUNCHED'); |
| + webview.removeEventListener('loadstop', onLoadStop); |
| + webview.removeEventListener('loadabort', onLoadAbort); |
| + callback(); |
| + }; |
| + webview.addEventListener('loadstop', onLoadStop); |
| + |
| + var onLoadAbort = function(e) { |
| + chrome.test.sendMessage('WebViewTest.FAILURE'); |
| + webview.removeEventListener('loadstop', onLoadStop); |
| + webview.removeEventListener('loadabort', onLoadAbort); |
| + }; |
| + webview.src = 'data:text/html,<html><body>simple test</body></html>'; |
| + return webview; |
| +} |
| + |
| +onload = function() { |
| + var webview = CreateWebViewAndGuest(function() { |
| + webview.addEventListener('newwindow', function(e) { |
| + var newwebview = document.createElement('webview'); |
| + newwebview.addEventListener('loadstop', function(e) { |
| + chrome.test.sendMessage('WebViewTest.NEWWINDOW'); |
| + }); |
| + e.window.attach(newwebview); |
| + document.body.appendChild(newwebview); |
| + }); |
| + |
| + webview.addEventListener('loadstop', function(e) { |
| + chrome.test.sendMessage('WebViewTest.LOADSTOP'); |
| + }); |
| + }); |
| + document.body.appendChild(webview); |
| +}; |