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 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 // This test verifies that the loadabort event fires as expected when an illegal | 1040 // This test verifies that the loadabort event fires as expected when an illegal |
1041 // chrome URL is provided. | 1041 // chrome URL is provided. |
1042 function testLoadAbortIllegalChromeURL() { | 1042 function testLoadAbortIllegalChromeURL() { |
1043 var webview = document.createElement('webview'); | 1043 var webview = document.createElement('webview'); |
1044 var onFirstLoadStop = function(e) { | 1044 var onFirstLoadStop = function(e) { |
1045 webview.removeEventListener('loadstop', onFirstLoadStop); | 1045 webview.removeEventListener('loadstop', onFirstLoadStop); |
1046 webview.setAttribute('src', 'chrome://newtab'); | 1046 webview.setAttribute('src', 'chrome://newtab'); |
1047 }; | 1047 }; |
1048 webview.addEventListener('loadstop', onFirstLoadStop); | 1048 webview.addEventListener('loadstop', onFirstLoadStop); |
1049 webview.addEventListener('loadabort', function(e) { | 1049 webview.addEventListener('loadabort', function(e) { |
1050 embedder.test.assertEq('ERR_ABORTED', e.reason); | 1050 embedder.test.assertEq('ERR_DISALLOWED_URL_SCHEME', e.reason); |
1051 embedder.test.succeed(); | 1051 embedder.test.succeed(); |
1052 }); | 1052 }); |
1053 webview.setAttribute('src', 'about:blank'); | 1053 webview.setAttribute('src', 'about:blank'); |
1054 document.body.appendChild(webview); | 1054 document.body.appendChild(webview); |
1055 } | 1055 } |
1056 | 1056 |
1057 function testLoadAbortIllegalFileURL() { | 1057 function testLoadAbortIllegalFileURL() { |
1058 var webview = document.createElement('webview'); | 1058 var webview = document.createElement('webview'); |
1059 webview.addEventListener('loadabort', function(e) { | 1059 webview.addEventListener('loadabort', function(e) { |
1060 embedder.test.assertEq('ERR_ABORTED', e.reason); | 1060 embedder.test.assertEq('ERR_DISALLOWED_URL_SCHEME', e.reason); |
1061 embedder.test.succeed(); | 1061 embedder.test.succeed(); |
1062 }); | 1062 }); |
1063 webview.setAttribute('src', 'file://foo'); | 1063 webview.setAttribute('src', 'file://foo'); |
1064 document.body.appendChild(webview); | 1064 document.body.appendChild(webview); |
1065 } | 1065 } |
1066 | 1066 |
1067 function testLoadAbortIllegalJavaScriptURL() { | 1067 function testLoadAbortIllegalJavaScriptURL() { |
1068 var webview = document.createElement('webview'); | 1068 var webview = document.createElement('webview'); |
1069 webview.addEventListener('loadabort', function(e) { | 1069 webview.addEventListener('loadabort', function(e) { |
1070 embedder.test.assertEq('ERR_ABORTED', e.reason); | 1070 embedder.test.assertEq('ERR_DISALLOWED_URL_SCHEME', e.reason); |
1071 embedder.test.succeed(); | 1071 embedder.test.succeed(); |
1072 }); | 1072 }); |
1073 webview.setAttribute('src', 'javascript:void(document.bgColor="#0000FF")'); | 1073 webview.setAttribute('src', 'javascript:void(document.bgColor="#0000FF")'); |
1074 document.body.appendChild(webview); | 1074 document.body.appendChild(webview); |
1075 } | 1075 } |
1076 | 1076 |
1077 // This test verifies that the reload method on webview functions as expected. | 1077 // This test verifies that the reload method on webview functions as expected. |
1078 function testReload() { | 1078 function testReload() { |
1079 var triggerNavUrl = 'data:text/html,trigger navigation'; | 1079 var triggerNavUrl = 'data:text/html,trigger navigation'; |
1080 var webview = document.createElement('webview'); | 1080 var webview = document.createElement('webview'); |
(...skipping 56 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 // TODO(fsamuel): Change to ERR_UNKNOWN_URL_SCHEME. | 1147 embedder.test.assertEq('ERR_DISALLOWED_URL_SCHEME', e.reason); |
1148 embedder.test.assertEq('ERR_ABORTED', e.reason); | |
1149 embedder.test.succeed(); | 1148 embedder.test.succeed(); |
1150 }); | 1149 }); |
1151 webview.executeScript({ | 1150 webview.executeScript({ |
1152 code: 'window.location.href = "tel:+12223334444";' | 1151 code: 'window.location.href = "tel:+12223334444";' |
1153 }, function(results) {}); | 1152 }, function(results) {}); |
1154 }); | 1153 }); |
1155 webview.setAttribute('src', 'data:text/html,navigate to external protocol'); | 1154 webview.setAttribute('src', 'data:text/html,navigate to external protocol'); |
1156 document.body.appendChild(webview); | 1155 document.body.appendChild(webview); |
1157 } | 1156 } |
1158 | 1157 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 webview.contentWindow.postMessage(JSON.stringify(msg), '*'); | 1282 webview.contentWindow.postMessage(JSON.stringify(msg), '*'); |
1284 } | 1283 } |
1285 ); | 1284 ); |
1286 } | 1285 } |
1287 ); | 1286 ); |
1288 }); | 1287 }); |
1289 | 1288 |
1290 webview.addEventListener('loadabort', function(e) { | 1289 webview.addEventListener('loadabort', function(e) { |
1291 e.preventDefault(); | 1290 e.preventDefault(); |
1292 window.console.log('Navigation to \'' + e.url + '\' has been aborted.'); | 1291 window.console.log('Navigation to \'' + e.url + '\' has been aborted.'); |
1293 embedder.test.assertEq('ERR_ABORTED', e.reason); | 1292 embedder.test.assertEq('ERR_ACCESS_DENIED', e.reason); |
1294 embedder.test.assertEq(CHROME_WEB_STORE, e.url); | 1293 embedder.test.assertEq(CHROME_WEB_STORE, e.url); |
1295 // Ask the guest process if it's still alive. If the guest process has | 1294 // Ask the guest process if it's still alive. If the guest process has |
1296 // crashed then this message will never be received. | 1295 // crashed then this message will never be received. |
1297 window.console.log('Checking if the guest process is still alive.'); | 1296 window.console.log('Checking if the guest process is still alive.'); |
1298 var msg = ['isalive']; | 1297 var msg = ['isalive']; |
1299 webview.contentWindow.postMessage(JSON.stringify(msg), '*'); | 1298 webview.contentWindow.postMessage(JSON.stringify(msg), '*'); |
1300 }); | 1299 }); |
1301 | 1300 |
1302 webview.addEventListener('exit', function(e) { | 1301 webview.addEventListener('exit', function(e) { |
1303 window.console.log('The guest process has crashed.'); | 1302 window.console.log('The guest process has crashed.'); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 'testScreenshotCapture' : testScreenshotCapture, | 1388 'testScreenshotCapture' : testScreenshotCapture, |
1390 'testNavigateToWebStore' : testNavigateToWebStore | 1389 'testNavigateToWebStore' : testNavigateToWebStore |
1391 }; | 1390 }; |
1392 | 1391 |
1393 onload = function() { | 1392 onload = function() { |
1394 chrome.test.getConfig(function(config) { | 1393 chrome.test.getConfig(function(config) { |
1395 embedder.setUp_(config); | 1394 embedder.setUp_(config); |
1396 chrome.test.sendMessage("Launched"); | 1395 chrome.test.sendMessage("Launched"); |
1397 }); | 1396 }); |
1398 }; | 1397 }; |
OLD | NEW |