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

Unified Diff: chrome/test/data/extensions/platform_apps/web_view/load_webview_accessible_resource/embedder.js

Issue 2768863003: Fix webview-accessible resource checks in AllowCrossRendererResourceLoadHelper (Closed)
Patch Set: Cleanup Created 3 years, 9 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
Index: chrome/test/data/extensions/platform_apps/web_view/load_webview_accessible_resource/embedder.js
diff --git a/chrome/test/data/extensions/platform_apps/web_view/load_webview_accessible_resource/embedder.js b/chrome/test/data/extensions/platform_apps/web_view/load_webview_accessible_resource/embedder.js
index 37d98e28a12283b3ae56f9f8934570b4e28361df..3bab93a4b1d0221cdeb64e40db999f5f8a331c37 100644
--- a/chrome/test/data/extensions/platform_apps/web_view/load_webview_accessible_resource/embedder.js
+++ b/chrome/test/data/extensions/platform_apps/web_view/load_webview_accessible_resource/embedder.js
@@ -10,6 +10,8 @@ window.runTest = function(testName) {
testLoadWebviewAccessibleResource();
} else if (testName == 'testReloadWebviewAccessibleResource') {
testReloadWebviewAccessibleResource();
+ } else if (testName == 'testLoadWebviewInaccessibleResource') {
+ testLoadWebviewInaccessibleResource();
} else {
window.console.log('Incorrect testName: ' + testName);
chrome.test.sendMessage('TEST_FAILED');
@@ -58,6 +60,43 @@ function testReloadWebviewAccessibleResource() {
webview.src = '/assets/foo.html';
}
+function testLoadWebviewInaccessibleResource() {
+ var webview = document.querySelector('webview');
+ var didNavigate = false;
+
+ // Once the webview loads /foo.html, instruct it to navigate to a
+ // non-webview-accessible resource.
+ webview.addEventListener('loadstop', function() {
+ if (didNavigate)
+ return;
+
+ var inaccessibleURL = document.origin + "/inaccessible.html";
+ webview.executeScript({code: 'location="' + inaccessibleURL + '";'});
+ didNavigate = true;
+ });
+
+ // The inaccessible URL should be blocked, and the webview should stay at
+ // foo.html.
+ webview.addEventListener('loadabort', function(e) {
+ if (e.reason != 'ERR_BLOCKED_BY_CLIENT') {
+ console.log("incorrect error reason in loadabort: " + e.reason);
+ chrome.test.sendMessage('TEST_FAILED');
+ }
+
+ // Check that the webview content hasn't changed.
+ webview.executeScript({code: 'document.body.innerText'}, function(result) {
+ if (result == 'Foo') {
+ chrome.test.sendMessage('TEST_PASSED');
+ } else {
+ console.log('webview content is incorrect: ' + result);
+ chrome.test.sendMessage('TEST_FAILED');
+ }
+ });
+ });
+
+ webview.src = '/assets/foo.html';
+}
+
onload = function() {
chrome.test.getConfig(function(config) {
embedder.guestURL =

Powered by Google App Engine
This is Rietveld 408576698