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

Unified Diff: chrome/test/data/extensions/platform_apps/web_view/shim/main.js

Issue 22793018: <webview>: Implement support for package-local chrome-extension:// URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a test to verify that a privileged partition can access a local resource Created 7 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
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 0498d026f337ddf64b5b56f5131fb3590e42c5b4..bb4fb37ae770747715e6192414894e8e9d5acf18 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
@@ -11,6 +11,7 @@ embedder.noReferrerGuestURL = '';
embedder.redirectGuestURL = '';
embedder.redirectGuestURLDest = '';
embedder.closeSocketURL = '';
+embedder.extensionId = '';
embedder.tests = {};
embedder.setUp_ = function(config) {
@@ -27,7 +28,8 @@ embedder.setUp_ = function(config) {
embedder.closeSocketURL = embedder.baseGuestURL + '/close-socket';
};
-window.runTest = function(testName) {
+window.runTest = function(testName, extensionId) {
+ embedder.extensionId = extensionId;
if (!embedder.test.testList[testName]) {
console.log('Incorrect testName: ' + testName);
embedder.test.fail();
@@ -299,6 +301,24 @@ function testAPIMethodExistence() {
document.body.appendChild(webview);
}
+// This test verifies that the loadstop event fires when loading a webview
+// accessible resource from a partition that is privileged.
+function testChromeExtensionURL() {
+ var localResource = 'chrome-extension://' + embedder.extensionId +
Matt Perry 2013/09/24 21:06:54 Does chrome.runtime.getURL() not work here?
Fady Samuel 2013/09/24 23:05:02 It does. I just didn't know it existed :P. Thanks!
+ '/guest.html';
+ var webview = document.createElement('webview');
+ // foobar is a privileged partition according to the manifest file.
+ webview.partition = 'foobar';
+ webview.addEventListener('loadabort', function(e) {
+ embedder.test.fail();
+ });
+ webview.addEventListener('loadstop', function(e) {
+ embedder.test.succeed();
+ });
+ webview.setAttribute('src', localResource);
+ document.body.appendChild(webview);
+}
+
function testWebRequestAPIExistence() {
var apiPropertiesToCheck = [
'onBeforeRequest',
@@ -882,6 +902,23 @@ function testLoadStartLoadRedirect() {
document.body.appendChild(webview);
}
+// 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-extension://' + embedder.extensionId +
+ '/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 and with the
// appropriate fields when an empty response is returned.
function testLoadAbortEmptyResponse() {
@@ -1055,6 +1092,7 @@ embedder.test.testList = {
'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes,
'testAutosizeWithPartialAttributes': testAutosizeWithPartialAttributes,
'testAPIMethodExistence': testAPIMethodExistence,
+ 'testChromeExtensionURL': testChromeExtensionURL,
'testWebRequestAPIExistence': testWebRequestAPIExistence,
'testEventName': testEventName,
'testOnEventProperties': testOnEventProperties,
@@ -1083,6 +1121,8 @@ embedder.test.testList = {
testWebRequestListenerSurvivesReparenting,
'testGetProcessId': testGetProcessId,
'testLoadStartLoadRedirect': testLoadStartLoadRedirect,
+ 'testLoadAbortChromeExtensionURLWrongPartition':
+ testLoadAbortChromeExtensionURLWrongPartition,
'testLoadAbortEmptyResponse': testLoadAbortEmptyResponse,
'testLoadAbortIllegalChromeURL': testLoadAbortIllegalChromeURL,
'testLoadAbortIllegalFileURL': testLoadAbortIllegalFileURL,

Powered by Google App Engine
This is Rietveld 408576698