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

Unified Diff: chrome/test/data/extensions/platform_apps/web_view/filesystem/worker/guest_worker.html

Issue 306473012: Plumb file system permission into WebviewGuest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small changes are made. Created 6 years, 6 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/filesystem/worker/guest_worker.html
diff --git a/chrome/test/data/extensions/platform_apps/web_view/filesystem/worker/guest_worker.html b/chrome/test/data/extensions/platform_apps/web_view/filesystem/worker/guest_worker.html
new file mode 100644
index 0000000000000000000000000000000000000000..ef81acba03ccf8e039f139efd6c0c3f9872631ef
--- /dev/null
+++ b/chrome/test/data/extensions/platform_apps/web_view/filesystem/worker/guest_worker.html
@@ -0,0 +1,95 @@
+<!--
+ * 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.
+-->
+<html>
+ <head>
+ <script type="text/javascript">
+ // A guest that ceate a worker to request filesystem.
+ // Notifies the embedder about the result of the request (success/fail)
+ // via post message. Note that the embedder has to initiate a postMessage
+ // first so that guest has a reference to the embedder's window.
+
+ // The window reference of the embedder to send post message reply.
+ var embedderWindowChannel = null;
+
+ var expectedTotalCallbackCount;
+ var totalCallbackCount;
+ var successCallbackCount;
+ var testName = 'uninitialized';
+
+ var maybeNotifyEmbedder = function() {
+ window.console.log('maybeNotifyEmbedder' +
+ ', expectedTotalCallbackCount: ' +
+ expectedTotalCallbackCount +
+ ', successCallbackCount: ' +
+ successCallbackCount +
+ ', totalCallbackCount: ' +
+ totalCallbackCount);
+ if(expectedTotalCallbackCount == totalCallbackCount) {
+ var status = (expectedTotalCallbackCount == successCallbackCount) ?
+ 'access-granted' : 'access-denied';
+ var responseArray = [testName, status];
+ notifyEmbedder(responseArray);
+ }
+ };
+
+ var notifyEmbedder = function(msg_array) {
+ embedderWindowChannel.postMessage(JSON.stringify(msg_array), '*');
+ };
+
+ var startTest = function() {
+ expectedTotalCallbackCount = 1;
+ totalCallbackCount = 0;
+ successCallbackCount = 0;
+
+ window.console.log('Call initWorker');
+ initWorker();
+ };
+
+ var initWorker = function() {
+ window.worker = new Worker('worker.js');
+ worker.addEventListener('message', function(e) {
+ var data = e.data;
+ switch (data.type) {
+ case 'echo':
+ window.console.log('echo: ' + data.msg);
+ break;
+ case 'error':
+ window.console.log('error: ' + data.msg);
+ break;
+ case 'result':
+ window.console.log('result: ' + data.msg);
+ successCallbackCount += parseInt(data.msg);
+ ++totalCallbackCount;
+ maybeNotifyEmbedder();
+ break;
+ default:
+ window.console.log('UNKNOWN MESSAGE FROM WORKER');
+ break;
+ }
+ }, false);
+ worker.postMessage({'type': 'requestFileSystem'});
+ };
+
+ var onPostMessageReceived = function(e) {
+ window.console.log('guest.onPostMessageReceived');
+ var data = JSON.parse(e.data);
+ if (data[0] == 'check-filesystem-permission') {
+ testName = data[1];
+ embedderWindowChannel = e.source;
+ // Start the test once we have |embedderWindowChannel|.
+ startTest();
+ }
+ };
+ addEventListener('message', onPostMessageReceived, false);
+ </script>
+ </head>
+ <body>
+ <div>This is a guest that create a worker to request filesystem.</div>
+ <script>
+ window.console.log('Guest loaded');
+ </script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698