Index: chrome/test/data/extensions/platform_apps/web_view/shim/main.js |
diff --git a/chrome/test/data/extensions/platform_apps/web_view/shim/main.js b/chrome/test/data/extensions/platform_apps/web_view/shim/main.js |
index 928d440f5b4a8bf1f8da0fa749799972af7f0017..e3e1bd3bba9876460a488274950e6bf62849b03f 100644 |
--- a/chrome/test/data/extensions/platform_apps/web_view/shim/main.js |
+++ b/chrome/test/data/extensions/platform_apps/web_view/shim/main.js |
@@ -1262,6 +1262,79 @@ function testScreenshotCapture() { |
document.body.appendChild(webview); |
} |
+function testNavigateToWebStore() { |
+ var CHROME_WEB_STORE = 'https://chrome.google.com/webstore'; |
+ var webview = new WebView(); |
+ webview.src = 'about:blank'; |
+ webview.addEventListener('loadstop', function(e) { |
+ webview.executeScript( |
+ {file: 'inject_comm_channel.js'}, |
+ function(results) { |
+ window.console.log('The guest script for a two-way comm channel has ' + |
+ 'been injected into webview.'); |
+ // Establish a communication channel with the guest. |
+ var msg = ['connect']; |
+ webview.contentWindow.postMessage(JSON.stringify(msg), '*'); |
+ } |
+ ); |
+ webview.executeScript( |
+ {file: 'inject_webstore_nav_test.js'}, |
+ function(results) { |
+ window.console.log( |
+ 'The WebStore navigation test has been injected into webview.'); |
+ } |
+ ); |
+ }); |
+ |
+ webview.addEventListener('loadabort', function(e) { |
+ e.preventDefault(); |
+ window.console.log('Navigation to \'' + e.url + '\' has been aborted.'); |
sadrul
2014/01/16 21:43:55
Considering the console logs show up in the test-r
Fady Samuel
2014/01/16 23:40:27
I feel they are useful. If a test hangs in the fut
|
+ embedder.test.assertEq('ERR_ABORTED', e.reason); |
+ embedder.test.assertEq(CHROME_WEB_STORE, e.url); |
+ // Ask the guest process if it's still alive. If the guest process has |
+ // crashed then this message will never be received. |
+ window.console.log('Checking if the guest process is still alive.'); |
+ var msg = ['isalive']; |
+ webview.contentWindow.postMessage(JSON.stringify(msg), '*'); |
+ //embedder.test.succeed(); |
sadrul
2014/01/16 21:43:55
remove?
Fady Samuel
2014/01/16 23:40:27
Done.
|
+ }); |
+ |
+ webview.addEventListener('exit', function(e) { |
+ window.console.log('The guest process has crashed.'); |
+ embedder.test.fail(); |
+ }); |
+ |
+ window.addEventListener('message', function(e) { |
+ var data = JSON.parse(e.data); |
+ switch (data[0]) { |
+ case 'connected': { |
+ window.console.log( |
+ 'A communication channel has been established with webview.'); |
+ window.console.log('Requesting a guest-initiated navigation to \'' + |
+ CHROME_WEB_STORE + '\''); |
+ var msg = ['navigate', CHROME_WEB_STORE]; |
lazyboy
2014/01/16 22:31:24
The assumption here is that inject_webstore_nav_te
Fady Samuel
2014/01/16 23:40:27
Ohh, good catch! Fixed!
|
+ webview.contentWindow.postMessage(JSON.stringify(msg), '*'); |
+ return; |
+ } |
+ case 'alive': { |
+ window.console.log('The guest process is alive!'); |
+ embedder.test.succeed(); |
+ return; |
+ } |
+ case 'error': { |
+ window.console.log('The guest received an unexpected message: \'' + |
+ data[1] + '\''); |
+ embedder.test.fail(); |
+ return; |
+ } |
+ } |
+ console.log('Unexpected message: \'' + data[0] + '\''); |
lazyboy
2014/01/16 22:31:24
nit: try being consistent within the file, console
Fady Samuel
2014/01/16 23:40:27
Done.
|
+ embedder.test.fail(); |
+ }); |
+ |
+ document.body.appendChild(webview); |
+} |
+ |
embedder.test.testList = { |
'testAutosizeAfterNavigation': testAutosizeAfterNavigation, |
'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation, |
@@ -1313,7 +1386,8 @@ embedder.test.testList = { |
'testRemoveWebviewAfterNavigation': testRemoveWebviewAfterNavigation, |
'testResizeWebviewResizesContent': testResizeWebviewResizesContent, |
'testPostMessageCommChannel': testPostMessageCommChannel, |
- 'testScreenshotCapture' : testScreenshotCapture |
+ 'testScreenshotCapture' : testScreenshotCapture, |
+ 'testNavigateToWebStore' : testNavigateToWebStore |
}; |
onload = function() { |