| 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 =
|
|
|