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

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

Issue 2702503002: Block renderer-initiated main frame navigations to data URLs (Closed)
Patch Set: Fix Android PDF tests where PDFs should be downloaded Created 3 years, 8 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
« no previous file with comments | « chrome/test/data/android/popup_test.html ('k') | content/browser/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 webview.addEventListener('loadabort', function(e) { 423 webview.addEventListener('loadabort', function(e) {
424 embedder.test.fail(); 424 embedder.test.fail();
425 }); 425 });
426 webview.addEventListener('loadstop', function(e) { 426 webview.addEventListener('loadstop', function(e) {
427 embedder.test.succeed(); 427 embedder.test.succeed();
428 }); 428 });
429 webview.setAttribute('src', 'guest_with_inline_script.html'); 429 webview.setAttribute('src', 'guest_with_inline_script.html');
430 document.body.appendChild(webview); 430 document.body.appendChild(webview);
431 } 431 }
432 432
433 // This test verifies that guests are blocked from navigating the webview to a
434 // data URL.
435 function testContentInitiatedNavigationToDataUrlBlocked() {
436 var navUrl = "data:text/html,foo";
437 var webview = document.createElement('webview');
438 webview.addEventListener('consolemessage', function(e) {
439 if (e.message.startsWith(
440 'Not allowed to navigate top frame to data URL:')) {
441 embedder.test.succeed();
442 }
443 });
444 webview.addEventListener('loadstop', function(e) {
445 if (webview.getAttribute('src') == navUrl) {
446 embedder.test.fail();
447 }
448 });
449 webview.setAttribute('src',
450 'data:text/html,<script>window.location.href = "' + navUrl +
451 '";</scr' + 'ipt>');
452 document.body.appendChild(webview);
453 }
454
433 // Tests that a <webview> that starts with "display: none" style loads 455 // Tests that a <webview> that starts with "display: none" style loads
434 // properly. 456 // properly.
435 function testDisplayNoneWebviewLoad() { 457 function testDisplayNoneWebviewLoad() {
436 var webview = document.createElement('webview'); 458 var webview = document.createElement('webview');
437 var visible = false; 459 var visible = false;
438 webview.style.display = 'none'; 460 webview.style.display = 'none';
439 // foobar is a privileged partition according to the manifest file. 461 // foobar is a privileged partition according to the manifest file.
440 webview.partition = 'foobar'; 462 webview.partition = 'foobar';
441 webview.addEventListener('loadabort', function(e) { 463 webview.addEventListener('loadabort', function(e) {
442 embedder.test.fail(); 464 embedder.test.fail();
(...skipping 2626 matching lines...) Expand 10 before | Expand all | Expand 10 after
3069 testPartitionRemovalAfterNavigationFails, 3091 testPartitionRemovalAfterNavigationFails,
3070 'testAddContentScript': testAddContentScript, 3092 'testAddContentScript': testAddContentScript,
3071 'testAddMultipleContentScripts': testAddMultipleContentScripts, 3093 'testAddMultipleContentScripts': testAddMultipleContentScripts,
3072 'testAddContentScriptWithSameNameShouldOverwriteTheExistingOne': 3094 'testAddContentScriptWithSameNameShouldOverwriteTheExistingOne':
3073 testAddContentScriptWithSameNameShouldOverwriteTheExistingOne, 3095 testAddContentScriptWithSameNameShouldOverwriteTheExistingOne,
3074 'testAddContentScriptToOneWebViewShouldNotInjectToTheOtherWebView': 3096 'testAddContentScriptToOneWebViewShouldNotInjectToTheOtherWebView':
3075 testAddContentScriptToOneWebViewShouldNotInjectToTheOtherWebView, 3097 testAddContentScriptToOneWebViewShouldNotInjectToTheOtherWebView,
3076 'testAddAndRemoveContentScripts': testAddAndRemoveContentScripts, 3098 'testAddAndRemoveContentScripts': testAddAndRemoveContentScripts,
3077 'testAddContentScriptsWithNewWindowAPI': 3099 'testAddContentScriptsWithNewWindowAPI':
3078 testAddContentScriptsWithNewWindowAPI, 3100 testAddContentScriptsWithNewWindowAPI,
3101 'testContentInitiatedNavigationToDataUrlBlocked':
3102 testContentInitiatedNavigationToDataUrlBlocked,
3079 'testContentScriptIsInjectedAfterTerminateAndReloadWebView': 3103 'testContentScriptIsInjectedAfterTerminateAndReloadWebView':
3080 testContentScriptIsInjectedAfterTerminateAndReloadWebView, 3104 testContentScriptIsInjectedAfterTerminateAndReloadWebView,
3081 'testContentScriptExistsAsLongAsWebViewTagExists': 3105 'testContentScriptExistsAsLongAsWebViewTagExists':
3082 testContentScriptExistsAsLongAsWebViewTagExists, 3106 testContentScriptExistsAsLongAsWebViewTagExists,
3083 'testAddContentScriptWithCode': testAddContentScriptWithCode, 3107 'testAddContentScriptWithCode': testAddContentScriptWithCode,
3084 'testAddMultipleContentScriptsWithCodeAndCheckGeneratedScriptUrl': 3108 'testAddMultipleContentScriptsWithCodeAndCheckGeneratedScriptUrl':
3085 testAddMultipleContentScriptsWithCodeAndCheckGeneratedScriptUrl, 3109 testAddMultipleContentScriptsWithCodeAndCheckGeneratedScriptUrl,
3086 'testExecuteScriptFail': testExecuteScriptFail, 3110 'testExecuteScriptFail': testExecuteScriptFail,
3087 'testExecuteScript': testExecuteScript, 3111 'testExecuteScript': testExecuteScript,
3088 'testExecuteScriptIsAbortedWhenWebViewSourceIsChanged': 3112 'testExecuteScriptIsAbortedWhenWebViewSourceIsChanged':
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
3158 testRendererNavigationRedirectWhileUnattached, 3182 testRendererNavigationRedirectWhileUnattached,
3159 'testBlobURL': testBlobURL 3183 'testBlobURL': testBlobURL
3160 }; 3184 };
3161 3185
3162 onload = function() { 3186 onload = function() {
3163 chrome.test.getConfig(function(config) { 3187 chrome.test.getConfig(function(config) {
3164 embedder.setUp_(config); 3188 embedder.setUp_(config);
3165 chrome.test.sendMessage("Launched"); 3189 chrome.test.sendMessage("Launched");
3166 }); 3190 });
3167 }; 3191 };
OLDNEW
« no previous file with comments | « chrome/test/data/android/popup_test.html ('k') | content/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698