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..dfab8b9877ae4f55b3df9df78114624268c72d3a 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 top-level navigate to resource:')) { |
+ 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() { |
@@ -1313,7 +1335,7 @@ function testExecuteScriptIsAbortedWhenWebViewSourceIsChanged() { |
webview.addEventListener('loadstop', function onLoadStop(e) { |
window.console.log('2. Inject script to trigger a guest-initiated ' + |
'navigation.'); |
- var navUrl = 'data:text/html,trigger nav'; |
+ var navUrl = embedder.baseGuestURL + "/empty.html"; |
webview.executeScript({ |
code: 'window.location.href = "' + navUrl + '";' |
}); |
@@ -3052,6 +3074,8 @@ embedder.test.testList = { |
'testAPIMethodExistence': testAPIMethodExistence, |
'testChromeExtensionURL': testChromeExtensionURL, |
'testChromeExtensionRelativePath': testChromeExtensionRelativePath, |
+ 'testContentInitiatedNavigationToDataUrlBlocked': |
+ testContentInitiatedNavigationToDataUrlBlocked, |
'testDisplayNoneWebviewLoad': testDisplayNoneWebviewLoad, |
'testDisplayNoneWebviewRemoveChild': testDisplayNoneWebviewRemoveChild, |
'testInlineScriptFromAccessibleResources': |