OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 var util = {}; | 5 var util = {}; |
6 var embedder = {}; | 6 var embedder = {}; |
7 embedder.baseGuestURL = ''; | 7 embedder.baseGuestURL = ''; |
8 embedder.emptyGuestURL = ''; | 8 embedder.emptyGuestURL = ''; |
9 embedder.windowOpenGuestURL = ''; | 9 embedder.windowOpenGuestURL = ''; |
10 embedder.noReferrerGuestURL = ''; | 10 embedder.noReferrerGuestURL = ''; |
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 document.body.removeChild(webview); | 1137 document.body.removeChild(webview); |
1138 setTimeout(function() { | 1138 setTimeout(function() { |
1139 embedder.test.succeed(); | 1139 embedder.test.succeed(); |
1140 }, 0); | 1140 }, 0); |
1141 } | 1141 } |
1142 | 1142 |
1143 function testNavigationToExternalProtocol() { | 1143 function testNavigationToExternalProtocol() { |
1144 var webview = document.createElement('webview'); | 1144 var webview = document.createElement('webview'); |
1145 webview.addEventListener('loadstop', function(e) { | 1145 webview.addEventListener('loadstop', function(e) { |
1146 webview.addEventListener('loadabort', function(e) { | 1146 webview.addEventListener('loadabort', function(e) { |
1147 embedder.test.assertEq('ERR_UNKNOWN_URL_SCHEME', e.reason); | 1147 // TODO(fsamuel): Change to ERR_UNKNOWN_URL_SCHEME. |
| 1148 embedder.test.assertEq('ERR_ABORTED', e.reason); |
1148 embedder.test.succeed(); | 1149 embedder.test.succeed(); |
1149 }); | 1150 }); |
1150 webview.executeScript({ | 1151 webview.executeScript({ |
1151 code: 'window.location.href = "tel:+12223334444";' | 1152 code: 'window.location.href = "tel:+12223334444";' |
1152 }, function(results) {}); | 1153 }, function(results) {}); |
1153 }); | 1154 }); |
1154 webview.setAttribute('src', 'data:text/html,navigate to external protocol'); | 1155 webview.setAttribute('src', 'data:text/html,navigate to external protocol'); |
1155 document.body.appendChild(webview); | 1156 document.body.appendChild(webview); |
1156 } | 1157 } |
1157 | 1158 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 }); | 1256 }); |
1256 }); | 1257 }); |
1257 | 1258 |
1258 webview.style.width = '100px'; | 1259 webview.style.width = '100px'; |
1259 webview.style.height = '100px'; | 1260 webview.style.height = '100px'; |
1260 webview.setAttribute('src', | 1261 webview.setAttribute('src', |
1261 'data:text/html,<body style="background-color: red"></body>'); | 1262 'data:text/html,<body style="background-color: red"></body>'); |
1262 document.body.appendChild(webview); | 1263 document.body.appendChild(webview); |
1263 } | 1264 } |
1264 | 1265 |
| 1266 function testNavigateToWebStore() { |
| 1267 var CHROME_WEB_STORE = 'https://chrome.google.com/webstore'; |
| 1268 var webview = new WebView(); |
| 1269 webview.src = 'about:blank'; |
| 1270 webview.addEventListener('loadstop', function(e) { |
| 1271 webview.executeScript( |
| 1272 {file: 'inject_comm_channel.js'}, |
| 1273 function(results) { |
| 1274 window.console.log('The guest script for a two-way comm channel has ' + |
| 1275 'been injected into webview.'); |
| 1276 webview.executeScript( |
| 1277 {file: 'inject_webstore_nav_test.js'}, |
| 1278 function(results) { |
| 1279 window.console.log( |
| 1280 'The WebStore navigation test has been injected into webview.'); |
| 1281 // Establish a communication channel with the guest. |
| 1282 var msg = ['connect']; |
| 1283 webview.contentWindow.postMessage(JSON.stringify(msg), '*'); |
| 1284 } |
| 1285 ); |
| 1286 } |
| 1287 ); |
| 1288 }); |
| 1289 |
| 1290 webview.addEventListener('loadabort', function(e) { |
| 1291 e.preventDefault(); |
| 1292 window.console.log('Navigation to \'' + e.url + '\' has been aborted.'); |
| 1293 embedder.test.assertEq('ERR_ABORTED', e.reason); |
| 1294 embedder.test.assertEq(CHROME_WEB_STORE, e.url); |
| 1295 // Ask the guest process if it's still alive. If the guest process has |
| 1296 // crashed then this message will never be received. |
| 1297 window.console.log('Checking if the guest process is still alive.'); |
| 1298 var msg = ['isalive']; |
| 1299 webview.contentWindow.postMessage(JSON.stringify(msg), '*'); |
| 1300 }); |
| 1301 |
| 1302 webview.addEventListener('exit', function(e) { |
| 1303 window.console.log('The guest process has crashed.'); |
| 1304 embedder.test.fail(); |
| 1305 }); |
| 1306 |
| 1307 window.addEventListener('message', function(e) { |
| 1308 var data = JSON.parse(e.data); |
| 1309 switch (data[0]) { |
| 1310 case 'connected': { |
| 1311 window.console.log( |
| 1312 'A communication channel has been established with webview.'); |
| 1313 window.console.log('Requesting a guest-initiated navigation to \'' + |
| 1314 CHROME_WEB_STORE + '\''); |
| 1315 var msg = ['navigate', CHROME_WEB_STORE]; |
| 1316 webview.contentWindow.postMessage(JSON.stringify(msg), '*'); |
| 1317 return; |
| 1318 } |
| 1319 case 'alive': { |
| 1320 window.console.log('The guest process is alive!'); |
| 1321 embedder.test.succeed(); |
| 1322 return; |
| 1323 } |
| 1324 case 'error': { |
| 1325 window.console.log('The guest received an unexpected message: \'' + |
| 1326 data[1] + '\''); |
| 1327 embedder.test.fail(); |
| 1328 return; |
| 1329 } |
| 1330 } |
| 1331 window.console.log('Unexpected message: \'' + data[0] + '\''); |
| 1332 embedder.test.fail(); |
| 1333 }); |
| 1334 |
| 1335 document.body.appendChild(webview); |
| 1336 } |
| 1337 |
1265 embedder.test.testList = { | 1338 embedder.test.testList = { |
1266 'testAutosizeAfterNavigation': testAutosizeAfterNavigation, | 1339 'testAutosizeAfterNavigation': testAutosizeAfterNavigation, |
1267 'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation, | 1340 'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation, |
1268 'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes, | 1341 'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes, |
1269 'testAutosizeWithPartialAttributes': testAutosizeWithPartialAttributes, | 1342 'testAutosizeWithPartialAttributes': testAutosizeWithPartialAttributes, |
1270 'testAPIMethodExistence': testAPIMethodExistence, | 1343 'testAPIMethodExistence': testAPIMethodExistence, |
1271 'testChromeExtensionURL': testChromeExtensionURL, | 1344 'testChromeExtensionURL': testChromeExtensionURL, |
1272 'testChromeExtensionRelativePath': testChromeExtensionRelativePath, | 1345 'testChromeExtensionRelativePath': testChromeExtensionRelativePath, |
1273 'testInvalidChromeExtensionURL': testInvalidChromeExtensionURL, | 1346 'testInvalidChromeExtensionURL': testInvalidChromeExtensionURL, |
1274 'testWebRequestAPIExistence': testWebRequestAPIExistence, | 1347 'testWebRequestAPIExistence': testWebRequestAPIExistence, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1306 'testLoadAbortEmptyResponse': testLoadAbortEmptyResponse, | 1379 'testLoadAbortEmptyResponse': testLoadAbortEmptyResponse, |
1307 'testLoadAbortIllegalChromeURL': testLoadAbortIllegalChromeURL, | 1380 'testLoadAbortIllegalChromeURL': testLoadAbortIllegalChromeURL, |
1308 'testLoadAbortIllegalFileURL': testLoadAbortIllegalFileURL, | 1381 'testLoadAbortIllegalFileURL': testLoadAbortIllegalFileURL, |
1309 'testLoadAbortIllegalJavaScriptURL': testLoadAbortIllegalJavaScriptURL, | 1382 'testLoadAbortIllegalJavaScriptURL': testLoadAbortIllegalJavaScriptURL, |
1310 'testNavigationToExternalProtocol': testNavigationToExternalProtocol, | 1383 'testNavigationToExternalProtocol': testNavigationToExternalProtocol, |
1311 'testReload': testReload, | 1384 'testReload': testReload, |
1312 'testRemoveWebviewOnExit': testRemoveWebviewOnExit, | 1385 'testRemoveWebviewOnExit': testRemoveWebviewOnExit, |
1313 'testRemoveWebviewAfterNavigation': testRemoveWebviewAfterNavigation, | 1386 'testRemoveWebviewAfterNavigation': testRemoveWebviewAfterNavigation, |
1314 'testResizeWebviewResizesContent': testResizeWebviewResizesContent, | 1387 'testResizeWebviewResizesContent': testResizeWebviewResizesContent, |
1315 'testPostMessageCommChannel': testPostMessageCommChannel, | 1388 'testPostMessageCommChannel': testPostMessageCommChannel, |
1316 'testScreenshotCapture' : testScreenshotCapture | 1389 'testScreenshotCapture' : testScreenshotCapture, |
| 1390 'testNavigateToWebStore' : testNavigateToWebStore |
1317 }; | 1391 }; |
1318 | 1392 |
1319 onload = function() { | 1393 onload = function() { |
1320 chrome.test.getConfig(function(config) { | 1394 chrome.test.getConfig(function(config) { |
1321 embedder.setUp_(config); | 1395 embedder.setUp_(config); |
1322 chrome.test.sendMessage("Launched"); | 1396 chrome.test.sendMessage("Launched"); |
1323 }); | 1397 }); |
1324 }; | 1398 }; |
OLD | NEW |