Index: chrome/test/data/extensions/platform_apps/web_view/filesystem/worker/embedder.js |
diff --git a/chrome/test/data/extensions/platform_apps/web_view/geolocation/embedder_has_permission/embedder.js b/chrome/test/data/extensions/platform_apps/web_view/filesystem/worker/embedder.js |
similarity index 69% |
copy from chrome/test/data/extensions/platform_apps/web_view/geolocation/embedder_has_permission/embedder.js |
copy to chrome/test/data/extensions/platform_apps/web_view/filesystem/worker/embedder.js |
index d2e6db94852dfe26f0f199c1d50d1b004c9fcdf7..5be4d3b8009799b3d08ba92725c8efe66f37026f 100644 |
--- a/chrome/test/data/extensions/platform_apps/web_view/geolocation/embedder_has_permission/embedder.js |
+++ b/chrome/test/data/extensions/platform_apps/web_view/filesystem/worker/embedder.js |
@@ -1,4 +1,4 @@ |
-// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
@@ -24,11 +24,8 @@ window.runTest = function(testName) { |
embedder.setUp_ = function(config) { |
embedder.baseGuestURL = 'http://localhost:' + config.testServer.port; |
embedder.guestURL = embedder.baseGuestURL + |
- '/extensions/platform_apps/web_view/geolocation' + |
- '/geolocation_access_guest.html'; |
- embedder.iframeURL = embedder.baseGuestURL + |
- '/extensions/platform_apps/web_view/geolocation' + |
- '/geolocation_access_iframe.html'; |
+ '/extensions/platform_apps/web_view/filesystem/worker' + |
+ '/guest_worker.html'; |
chrome.test.log('Guest url is: ' + embedder.guestURL); |
}; |
@@ -37,6 +34,7 @@ embedder.setUpGuest_ = function() { |
document.querySelector('#webview-tag-container').innerHTML = |
'<webview style="width: 100px; height: 100px;"' + |
' src="' + embedder.guestURL + '"' + |
+ ' partition = "persist:a"' + |
'></webview>'; |
var webview = document.querySelector('webview'); |
if (!webview) { |
@@ -75,15 +73,12 @@ embedder.test.assertFalse = function(condition) { |
}; |
/** @private */ |
-embedder.setUpLoadStop_ = function(webview, testName, opt_iframeURL) { |
+embedder.setUpLoadStop_ = function(webview, testName) { |
window.console.log('embedder.setUpLoadStop_'); |
var onWebViewLoadStop = function(e) { |
window.console.log('embedder.onWebViewLoadStop'); |
// Send post message to <webview> when it's ready to receive them. |
- var msgArray = ['check-geolocation-permission', '' + testName]; |
- if (opt_iframeURL) { |
- msgArray.push(opt_iframeURL); |
- } |
+ var msgArray = ['check-filesystem-permission', '' + testName]; |
window.console.log('embedder.webview.postMessage'); |
webview.contentWindow.postMessage(JSON.stringify(msgArray), '*'); |
}; |
@@ -109,28 +104,20 @@ embedder.registerAndWaitForPostMessage_ = function( |
/** @private */ |
embedder.assertCorrectEvent_ = function(e) { |
- embedder.test.assertEq('geolocation', e.permission); |
+ embedder.test.assertEq('filesystem', e.permission); |
embedder.test.assertTrue(!!e.url); |
embedder.test.assertTrue(e.url.indexOf(embedder.baseGuestURL) == 0); |
}; |
// Tests begin. |
-// Once the guest is allowed or denied geolocation, the guest notifies the |
+// Once the guest is allowed or denied filesystem, the guest notifies the |
// embedder about the fact via post message. |
// The embedder has to initiate a post message so that the guest can get a |
// reference to embedder to send the reply back. |
-// |
-// We have to run each test (from embedder.test.testList) in a separate platform |
-// app. Running multiple tests mocking geolocation in a single platform app is |
-// not reliable due to the nature of ui_test_utils::OverrideGeolocation(). |
-// Therefore we run this tests manually (a.k.a non-RunPlatformAppTest) so we do |
-// not have to copy the platform app n times for running n JavaScript tests. |
-// TODO(lazyboy): Look into implementing something similar to |
-// RunExtensionSubtest() for platform apps. |
- |
-// Loads a guest which requests geolocation. The embedder (platform app) has |
-// acccess to geolocation and allows geolocation for the guest. |
+ |
+// Loads a guest which create a worker to request filesystem. The embedder |
+// explicitly allows acccess to filesystem for the guest. |
function testAllow() { |
var webview = embedder.setUpGuest_(); |
@@ -142,13 +129,12 @@ function testAllow() { |
webview.addEventListener('permissionrequest', onPermissionRequest); |
embedder.setUpLoadStop_(webview, 'test1'); |
- // WebViewTest sets (mock) lat, lng to 10, 20. |
embedder.registerAndWaitForPostMessage_( |
- webview, ['test1', 'access-granted', 10, 20]); |
+ webview, ['test1', 'access-granted']); |
} |
-// Loads a guest which requests geolocation. The embedder (platform app) has |
-// acccess to geolocation, but denies geolocation for the guest. |
+// Loads a guest which creates a worker to request filesystem. The embedder |
+// explicitly denies access to filesystem for the guest. |
function testDeny() { |
var webview = embedder.setUpGuest_(); |
@@ -164,27 +150,26 @@ function testDeny() { |
webview, ['test2', 'access-denied']); |
} |
-// The guest opens an <iframe>. The <iframe> also requests geolocation. |
-// This results in geolocation requests go to a BrowserPluginGuest with |
-// different bridge_id-s. |
-function testMultipleBridgeIdAllow() { |
+// Loads a guest which creates a worker to request filesystem. The embedder |
+// does not perform an explicit action, and the default permission according |
+// to cookie setting is allowed. |
+function testDefaultAllow() { |
var webview = embedder.setUpGuest_(); |
var onPermissionRequest = function(e) { |
embedder.assertCorrectEvent_(e); |
- e.request.allow(); |
}; |
webview.addEventListener('permissionrequest', onPermissionRequest); |
- embedder.setUpLoadStop_(webview, 'test3', embedder.iframeURL); |
+ embedder.setUpLoadStop_(webview, 'test3'); |
embedder.registerAndWaitForPostMessage_( |
- webview, ['test3', 'access-granted', 10, 20]); |
+ webview, ['test3', 'access-granted']); |
} |
embedder.test.testList = { |
'testAllow': testAllow, |
'testDeny': testDeny, |
- 'testMultipleBridgeIdAllow': testMultipleBridgeIdAllow |
+ 'testDefaultAllow': testDefaultAllow |
}; |
onload = function() { |