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

Unified Diff: extensions/test/data/web_view/apitest/main.js

Issue 601553005: Adding webview tests to app_shell_browsertests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing Created 6 years, 3 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 | « extensions/test/data/web_view/apitest/guest.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/test/data/web_view/apitest/main.js
diff --git a/extensions/test/data/web_view/apitest/main.js b/extensions/test/data/web_view/apitest/main.js
index 16c713998d598a177b89fe220979f74c72e41e18..176b70d2543a742e761cf4548e51e312ca774e62 100644
--- a/extensions/test/data/web_view/apitest/main.js
+++ b/extensions/test/data/web_view/apitest/main.js
@@ -537,6 +537,111 @@ function testExecuteScriptFail() {
}
}
+// This test verifies that the loadabort event fires when loading a webview
+// accessible resource from a partition that is not privileged.
+function testLoadAbortChromeExtensionURLWrongPartition() {
+ var localResource = chrome.runtime.getURL('guest.html');
+ var webview = document.createElement('webview');
+ webview.addEventListener('loadabort', function(e) {
+ embedder.test.assertEq('ERR_ADDRESS_UNREACHABLE', e.reason);
+ embedder.test.succeed();
+ });
+ webview.addEventListener('loadstop', function(e) {
+ embedder.test.fail();
+ });
+ webview.setAttribute('src', localResource);
+ document.body.appendChild(webview);
+}
+
+// This test verifies that the loadabort event fires as expected when an illegal
+// chrome URL is provided.
+function testLoadAbortIllegalChromeURL() {
+ var webview = document.createElement('webview');
+ var onFirstLoadStop = function(e) {
+ webview.removeEventListener('loadstop', onFirstLoadStop);
+ webview.setAttribute('src', 'chrome://newtab');
+ };
+ webview.addEventListener('loadstop', onFirstLoadStop);
+ webview.addEventListener('loadabort', function(e) {
+ embedder.test.assertEq('ERR_ABORTED', e.reason);
+ embedder.test.succeed();
+ });
+ webview.setAttribute('src', 'about:blank');
+ document.body.appendChild(webview);
+}
+
+function testLoadAbortIllegalFileURL() {
+ var webview = document.createElement('webview');
+ webview.addEventListener('loadabort', function(e) {
+ embedder.test.assertEq('ERR_ABORTED', e.reason);
+ embedder.test.succeed();
+ });
+ webview.setAttribute('src', 'file://foo');
+ document.body.appendChild(webview);
+}
+
+function testLoadAbortIllegalJavaScriptURL() {
+ var webview = document.createElement('webview');
+ webview.addEventListener('loadabort', function(e) {
+ embedder.test.assertEq('ERR_ABORTED', e.reason);
+ embedder.test.succeed();
+ });
+ webview.setAttribute('src', 'javascript:void(document.bgColor="#0000FF")');
+ document.body.appendChild(webview);
+}
+
+// Verifies that navigating to invalid URL (e.g. 'http:') doesn't cause a crash.
+function testLoadAbortInvalidNavigation() {
+ var webview = document.createElement('webview');
+ var validSchemeWithEmptyURL = 'http:';
+ webview.addEventListener('loadabort', function(e) {
+ embedder.test.assertEq('ERR_ABORTED', e.reason);
+ embedder.test.assertEq('', e.url);
+ embedder.test.succeed();
+ });
+ webview.addEventListener('exit', function(e) {
+ // We should not crash.
+ embedder.test.fail();
+ });
+ webview.setAttribute('src', validSchemeWithEmptyURL);
+ document.body.appendChild(webview);
+}
+
+// Verifies that navigation to a URL that is valid but not web-safe or
+// pseudo-scheme fires loadabort and doesn't cause a crash.
+function testLoadAbortNonWebSafeScheme() {
+ var webview = document.createElement('webview');
+ var chromeGuestURL = 'chrome-guest://abc123';
+ webview.addEventListener('loadabort', function(e) {
+ embedder.test.assertEq('ERR_ABORTED', e.reason);
+ embedder.test.assertEq('chrome-guest://abc123/', e.url);
+ embedder.test.succeed();
+ });
+ webview.addEventListener('exit', function(e) {
+ // We should not crash.
+ embedder.test.fail();
+ });
+ webview.setAttribute('src', chromeGuestURL);
+ document.body.appendChild(webview);
+};
+
+// Tests that the 'loadprogress' event is triggered correctly.
+function testLoadProgressEvent() {
+ var webview = document.createElement('webview');
+ var progress = 0;
+
+ webview.addEventListener('loadstop', function(evt) {
+ embedder.test.assertEq(1, progress);
+ embedder.test.succeed();
+ });
+
+ webview.addEventListener('loadprogress', function(evt) {
+ progress = evt.progress;
+ });
+
+ webview.setAttribute('src', 'data:text/html,trigger navigation');
+ document.body.appendChild(webview);
+}
// Tests end.
@@ -556,7 +661,15 @@ embedder.test.testList = {
'testDisplayNoneWebviewLoad': testDisplayNoneWebviewLoad,
'testDisplayNoneWebviewRemoveChild': testDisplayNoneWebviewRemoveChild,
'testExecuteScript': testExecuteScript,
- 'testExecuteScriptFail': testExecuteScriptFail
+ 'testExecuteScriptFail': testExecuteScriptFail,
+ 'testLoadAbortChromeExtensionURLWrongPartition':
+ testLoadAbortChromeExtensionURLWrongPartition,
+ 'testLoadAbortIllegalChromeURL': testLoadAbortIllegalChromeURL,
+ 'testLoadAbortIllegalFileURL': testLoadAbortIllegalFileURL,
+ 'testLoadAbortIllegalJavaScriptURL': testLoadAbortIllegalJavaScriptURL,
+ 'testLoadAbortInvalidNavigation': testLoadAbortInvalidNavigation,
+ 'testLoadAbortNonWebSafeScheme': testLoadAbortNonWebSafeScheme,
+ 'testLoadProgressEvent': testLoadProgressEvent
};
onload = function() {
« no previous file with comments | « extensions/test/data/web_view/apitest/guest.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698