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

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

Issue 22793018: <webview>: Implement support for package-local chrome-extension:// URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test that broken Created 7 years, 2 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // Check contentWindow. 292 // Check contentWindow.
293 embedder.test.assertEq('object', typeof webview.contentWindow); 293 embedder.test.assertEq('object', typeof webview.contentWindow);
294 embedder.test.assertEq('function', 294 embedder.test.assertEq('function',
295 typeof webview.contentWindow.postMessage); 295 typeof webview.contentWindow.postMessage);
296 embedder.test.succeed(); 296 embedder.test.succeed();
297 }); 297 });
298 webview.setAttribute('src', 'data:text/html,webview check api'); 298 webview.setAttribute('src', 'data:text/html,webview check api');
299 document.body.appendChild(webview); 299 document.body.appendChild(webview);
300 } 300 }
301 301
302 // This test verifies that the loadstop event fires when loading a webview
303 // accessible resource from a partition that is privileged.
304 function testChromeExtensionURL() {
305 var localResource = chrome.runtime.getURL('guest.html');
306 var webview = document.createElement('webview');
307 // foobar is a privileged partition according to the manifest file.
308 webview.partition = 'foobar';
309 webview.addEventListener('loadabort', function(e) {
310 embedder.test.fail();
311 });
312 webview.addEventListener('loadstop', function(e) {
313 embedder.test.succeed();
314 });
315 webview.setAttribute('src', localResource);
316 document.body.appendChild(webview);
317 }
318
302 function testWebRequestAPIExistence() { 319 function testWebRequestAPIExistence() {
303 var apiPropertiesToCheck = [ 320 var apiPropertiesToCheck = [
304 'onBeforeRequest', 321 'onBeforeRequest',
305 'onBeforeSendHeaders', 322 'onBeforeSendHeaders',
306 'onSendHeaders', 323 'onSendHeaders',
307 'onHeadersReceived', 324 'onHeadersReceived',
308 'onAuthRequired', 325 'onAuthRequired',
309 'onBeforeRedirect', 326 'onBeforeRedirect',
310 'onResponseStarted', 327 'onResponseStarted',
311 'onCompleted', 328 'onCompleted',
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 e.newUrl.replace('127.0.0.1', 'localhost')); 892 e.newUrl.replace('127.0.0.1', 'localhost'));
876 if (loadstartCalled) { 893 if (loadstartCalled) {
877 embedder.test.succeed(); 894 embedder.test.succeed();
878 } else { 895 } else {
879 embedder.test.fail(); 896 embedder.test.fail();
880 } 897 }
881 }); 898 });
882 document.body.appendChild(webview); 899 document.body.appendChild(webview);
883 } 900 }
884 901
902 // This test verifies that the loadabort event fires when loading a webview
903 // accessible resource from a partition that is not privileged.
904 function testLoadAbortChromeExtensionURLWrongPartition() {
905 var localResource = chrome.runtime.getURL('guest.html');
906 var webview = document.createElement('webview');
907 webview.addEventListener('loadabort', function(e) {
908 embedder.test.assertEq('ERR_ADDRESS_UNREACHABLE', e.reason);
909 embedder.test.succeed();
910 });
911 webview.addEventListener('loadstop', function(e) {
912 embedder.test.fail();
913 });
914 webview.setAttribute('src', localResource);
915 document.body.appendChild(webview);
916 }
917
885 // This test verifies that the loadabort event fires as expected and with the 918 // This test verifies that the loadabort event fires as expected and with the
886 // appropriate fields when an empty response is returned. 919 // appropriate fields when an empty response is returned.
887 function testLoadAbortEmptyResponse() { 920 function testLoadAbortEmptyResponse() {
888 var webview = document.createElement('webview'); 921 var webview = document.createElement('webview');
889 webview.addEventListener('loadabort', function(e) { 922 webview.addEventListener('loadabort', function(e) {
890 embedder.test.assertEq('ERR_EMPTY_RESPONSE', e.reason); 923 embedder.test.assertEq('ERR_EMPTY_RESPONSE', e.reason);
891 embedder.test.succeed(); 924 embedder.test.succeed();
892 }); 925 });
893 webview.setAttribute('src', embedder.closeSocketURL); 926 webview.setAttribute('src', embedder.closeSocketURL);
894 document.body.appendChild(webview); 927 document.body.appendChild(webview);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 }); 1081 });
1049 document.body.appendChild(webview); 1082 document.body.appendChild(webview);
1050 } 1083 }
1051 1084
1052 embedder.test.testList = { 1085 embedder.test.testList = {
1053 'testAutosizeAfterNavigation': testAutosizeAfterNavigation, 1086 'testAutosizeAfterNavigation': testAutosizeAfterNavigation,
1054 'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation, 1087 'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation,
1055 'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes, 1088 'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes,
1056 'testAutosizeWithPartialAttributes': testAutosizeWithPartialAttributes, 1089 'testAutosizeWithPartialAttributes': testAutosizeWithPartialAttributes,
1057 'testAPIMethodExistence': testAPIMethodExistence, 1090 'testAPIMethodExistence': testAPIMethodExistence,
1091 'testChromeExtensionURL': testChromeExtensionURL,
1058 'testWebRequestAPIExistence': testWebRequestAPIExistence, 1092 'testWebRequestAPIExistence': testWebRequestAPIExistence,
1059 'testEventName': testEventName, 1093 'testEventName': testEventName,
1060 'testOnEventProperties': testOnEventProperties, 1094 'testOnEventProperties': testOnEventProperties,
1061 'testLoadProgressEvent': testLoadProgressEvent, 1095 'testLoadProgressEvent': testLoadProgressEvent,
1062 'testDestroyOnEventListener': testDestroyOnEventListener, 1096 'testDestroyOnEventListener': testDestroyOnEventListener,
1063 'testCannotMutateEventName': testCannotMutateEventName, 1097 'testCannotMutateEventName': testCannotMutateEventName,
1064 'testPartitionRaisesException': testPartitionRaisesException, 1098 'testPartitionRaisesException': testPartitionRaisesException,
1065 'testExecuteScriptFail': testExecuteScriptFail, 1099 'testExecuteScriptFail': testExecuteScriptFail,
1066 'testExecuteScript': testExecuteScript, 1100 'testExecuteScript': testExecuteScript,
1067 'testTerminateAfterExit': testTerminateAfterExit, 1101 'testTerminateAfterExit': testTerminateAfterExit,
1068 'testAssignSrcAfterCrash': testAssignSrcAfterCrash, 1102 'testAssignSrcAfterCrash': testAssignSrcAfterCrash,
1069 'testNavOnConsecutiveSrcAttributeChanges': 1103 'testNavOnConsecutiveSrcAttributeChanges':
1070 testNavOnConsecutiveSrcAttributeChanges, 1104 testNavOnConsecutiveSrcAttributeChanges,
1071 'testNavOnSrcAttributeChange': testNavOnSrcAttributeChange, 1105 'testNavOnSrcAttributeChange': testNavOnSrcAttributeChange,
1072 'testReassignSrcAttribute': testReassignSrcAttribute, 1106 'testReassignSrcAttribute': testReassignSrcAttribute,
1073 'testRemoveSrcAttribute': testRemoveSrcAttribute, 1107 'testRemoveSrcAttribute': testRemoveSrcAttribute,
1074 'testBrowserPluginNotAllowed': testBrowserPluginNotAllowed, 1108 'testBrowserPluginNotAllowed': testBrowserPluginNotAllowed,
1075 'testNewWindow': testNewWindow, 1109 'testNewWindow': testNewWindow,
1076 'testNewWindowTwoListeners': testNewWindowTwoListeners, 1110 'testNewWindowTwoListeners': testNewWindowTwoListeners,
1077 'testNewWindowNoPreventDefault': testNewWindowNoPreventDefault, 1111 'testNewWindowNoPreventDefault': testNewWindowNoPreventDefault,
1078 'testNewWindowNoReferrerLink': testNewWindowNoReferrerLink, 1112 'testNewWindowNoReferrerLink': testNewWindowNoReferrerLink,
1079 'testContentLoadEvent': testContentLoadEvent, 1113 'testContentLoadEvent': testContentLoadEvent,
1080 'testWebRequestAPI': testWebRequestAPI, 1114 'testWebRequestAPI': testWebRequestAPI,
1081 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty, 1115 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty,
1082 'testWebRequestListenerSurvivesReparenting': 1116 'testWebRequestListenerSurvivesReparenting':
1083 testWebRequestListenerSurvivesReparenting, 1117 testWebRequestListenerSurvivesReparenting,
1084 'testGetProcessId': testGetProcessId, 1118 'testGetProcessId': testGetProcessId,
1085 'testLoadStartLoadRedirect': testLoadStartLoadRedirect, 1119 'testLoadStartLoadRedirect': testLoadStartLoadRedirect,
1120 'testLoadAbortChromeExtensionURLWrongPartition':
1121 testLoadAbortChromeExtensionURLWrongPartition,
1086 'testLoadAbortEmptyResponse': testLoadAbortEmptyResponse, 1122 'testLoadAbortEmptyResponse': testLoadAbortEmptyResponse,
1087 'testLoadAbortIllegalChromeURL': testLoadAbortIllegalChromeURL, 1123 'testLoadAbortIllegalChromeURL': testLoadAbortIllegalChromeURL,
1088 'testLoadAbortIllegalFileURL': testLoadAbortIllegalFileURL, 1124 'testLoadAbortIllegalFileURL': testLoadAbortIllegalFileURL,
1089 'testLoadAbortIllegalJavaScriptURL': testLoadAbortIllegalJavaScriptURL, 1125 'testLoadAbortIllegalJavaScriptURL': testLoadAbortIllegalJavaScriptURL,
1090 'testNavigationToExternalProtocol': testNavigationToExternalProtocol, 1126 'testNavigationToExternalProtocol': testNavigationToExternalProtocol,
1091 'testReload': testReload, 1127 'testReload': testReload,
1092 'testRemoveWebviewOnExit': testRemoveWebviewOnExit, 1128 'testRemoveWebviewOnExit': testRemoveWebviewOnExit,
1093 'testRemoveWebviewAfterNavigation': testRemoveWebviewAfterNavigation, 1129 'testRemoveWebviewAfterNavigation': testRemoveWebviewAfterNavigation,
1094 'testResizeWebviewResizesContent': testResizeWebviewResizesContent 1130 'testResizeWebviewResizesContent': testResizeWebviewResizesContent
1095 }; 1131 };
1096 1132
1097 onload = function() { 1133 onload = function() {
1098 chrome.test.getConfig(function(config) { 1134 chrome.test.getConfig(function(config) {
1099 embedder.setUp_(config); 1135 embedder.setUp_(config);
1100 chrome.test.sendMessage("Launched"); 1136 chrome.test.sendMessage("Launched");
1101 }); 1137 });
1102 }; 1138 };
OLDNEW
« no previous file with comments | « chrome/common/extensions/webview_handler.cc ('k') | chrome/test/data/extensions/platform_apps/web_view/shim/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698