Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: chrome/test/data/extensions/platform_apps/web_view/shim/main.js

Issue 140073002: <webview>: navigating to WebStore should fire a loadabort instead of crashing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 }); 1255 });
1256 }); 1256 });
1257 1257
1258 webview.style.width = '100px'; 1258 webview.style.width = '100px';
1259 webview.style.height = '100px'; 1259 webview.style.height = '100px';
1260 webview.setAttribute('src', 1260 webview.setAttribute('src',
1261 'data:text/html,<body style="background-color: red"></body>'); 1261 'data:text/html,<body style="background-color: red"></body>');
1262 document.body.appendChild(webview); 1262 document.body.appendChild(webview);
1263 } 1263 }
1264 1264
1265 function testNavigateToWebStore() {
1266 var CHROME_WEB_STORE = 'https://chrome.google.com/webstore';
1267 var webview = new WebView();
1268 webview.src = 'about:blank';
1269 webview.addEventListener('loadstop', function(e) {
1270 webview.executeScript(
1271 {file: 'inject_comm_channel.js'},
1272 function(results) {
1273 window.console.log('The guest script for a two-way comm channel has ' +
1274 'been injected into webview.');
1275 // Establish a communication channel with the guest.
1276 var msg = ['connect'];
1277 webview.contentWindow.postMessage(JSON.stringify(msg), '*');
1278 }
1279 );
1280 webview.executeScript(
1281 {file: 'inject_webstore_nav_test.js'},
1282 function(results) {
1283 window.console.log(
1284 'The WebStore navigation test has been injected into webview.');
1285 }
1286 );
1287 });
1288
1289 webview.addEventListener('loadabort', function(e) {
1290 e.preventDefault();
1291 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
1292 embedder.test.assertEq('ERR_ABORTED', e.reason);
1293 embedder.test.assertEq(CHROME_WEB_STORE, e.url);
1294 // Ask the guest process if it's still alive. If the guest process has
1295 // crashed then this message will never be received.
1296 window.console.log('Checking if the guest process is still alive.');
1297 var msg = ['isalive'];
1298 webview.contentWindow.postMessage(JSON.stringify(msg), '*');
1299 //embedder.test.succeed();
sadrul 2014/01/16 21:43:55 remove?
Fady Samuel 2014/01/16 23:40:27 Done.
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];
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!
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 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.
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
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 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698