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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/platform_apps/web_view/shim/main.js
diff --git a/chrome/test/data/extensions/platform_apps/web_view/shim/main.js b/chrome/test/data/extensions/platform_apps/web_view/shim/main.js
index ddabbcd9030fb80066bfd819e024afe440da5e38..6aceb590e1fb07e66d12b5fb3b30c52b710846c0 100644
--- a/chrome/test/data/extensions/platform_apps/web_view/shim/main.js
+++ b/chrome/test/data/extensions/platform_apps/web_view/shim/main.js
@@ -430,6 +430,28 @@ function testChromeExtensionRelativePath() {
document.body.appendChild(webview);
}
+// This test verifies that guests are blocked from navigating the webview to a
+// data URL.
+function testContentInitiatedNavigationToDataUrlBlocked() {
+ var navUrl = "data:text/html,foo";
+ var webview = document.createElement('webview');
+ webview.addEventListener('consolemessage', function(e) {
+ if (e.message.startsWith(
+ 'Not allowed to navigate top frame to data URL:')) {
+ embedder.test.succeed();
+ }
+ });
+ webview.addEventListener('loadstop', function(e) {
+ if (webview.getAttribute('src') == navUrl) {
+ embedder.test.fail();
+ }
+ });
+ webview.setAttribute('src',
+ 'data:text/html,<script>window.location.href = "' + navUrl +
+ '";</scr' + 'ipt>');
+ document.body.appendChild(webview);
+}
+
// Tests that a <webview> that starts with "display: none" style loads
// properly.
function testDisplayNoneWebviewLoad() {
@@ -3076,6 +3098,8 @@ embedder.test.testList = {
'testAddAndRemoveContentScripts': testAddAndRemoveContentScripts,
'testAddContentScriptsWithNewWindowAPI':
testAddContentScriptsWithNewWindowAPI,
+ 'testContentInitiatedNavigationToDataUrlBlocked':
+ testContentInitiatedNavigationToDataUrlBlocked,
'testContentScriptIsInjectedAfterTerminateAndReloadWebView':
testContentScriptIsInjectedAfterTerminateAndReloadWebView,
'testContentScriptExistsAsLongAsWebViewTagExists':
« 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