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

Unified Diff: chrome/test/data/extensions/platform_apps/web_view_media_access/embedder_has_no_permission/embedder.js

Issue 11093080: <webview>: First stab at implementing media permission request for guests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and reup patch for review. Created 8 years, 1 month 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_media_access/embedder_has_no_permission/embedder.js
diff --git a/chrome/test/data/extensions/platform_apps/web_view_media_access/embedder_has_no_permission/embedder.js b/chrome/test/data/extensions/platform_apps/web_view_media_access/embedder_has_no_permission/embedder.js
new file mode 100644
index 0000000000000000000000000000000000000000..0d1ff3b8b9a62c116f946f309239f802914451ab
--- /dev/null
+++ b/chrome/test/data/extensions/platform_apps/web_view_media_access/embedder_has_no_permission/embedder.js
@@ -0,0 +1,71 @@
+// Copyright (c) 2012 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.
+
+var embedder = {};
+embedder.tests = {};
+embedder.guestURL = '';
+
+chrome.test.getConfig(function(config) {
+ embedder.guestURL = 'http://localhost:' + config.testServer.port +
+ '/files/extensions/platform_apps/web_view_media_access' +
+ '/media_access_guest.html';
+ chrome.test.log('Guest url is: ' + embedder.guestURL);
+});
+
+// Loads a guest which requests media access. The embedder (platform app) does
+// not have acccess to media. Permission is denied until we expose js API to
Charlie Reis 2012/11/20 01:54:00 I don't understand this part: "Permission is denie
lazyboy 2012/11/20 02:55:20 Yes it is. The comments are stale from previous ro
+// let embedder allow/deny such requests. Even if we had the API to let embedder
+// allow the request, the guest won't have access to media since the embedder
+// itself does not have permission for media.
+//
+// Once the guest is allowed or denied media access, 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.
+//
+// This test is essentially same as
+// chrome/test/.../platform_apps/web_view_media_access/embedder_has_no_access
+// at this point, but will change once permission API is implmented.
Charlie Reis 2012/11/20 01:54:00 nit: implemented Again, aren't we implementing the
lazyboy 2012/11/20 02:55:20 Removed, same as above.
+embedder.tests.testMediaAccessPermission = function() {
+ document.querySelector('#webview-tag-container').innerHTML =
+ '<webview style="width: 100px; height: 100px;"' +
+ //' src="' + embedder.guestURL + '"' +
Charlie Reis 2012/11/20 01:54:00 Commented out?
lazyboy 2012/11/20 02:55:20 Removed.
+ '></webview>';
+ var webview = document.querySelector('webview');
+ webview.setAttribute('src', embedder.guestURL);
+
+ // Timeout is required otherwise event registration on <webview> does not
+ // work.
+ setTimeout(function() {
+ var onPermissionRequest = function(e) {
+ chrome.test.log('Embedder notified on permissionRequest');
+ e.allow();
+ };
+ webview.addEventListener('permissionrequest', onPermissionRequest);
+
+ var onWebViewLoadCommit = function(e) {
+ // Send post message to <webview> when it's ready to receive them.
+ webview.contentWindow.frames.postMessage(
+ 'check-media-permission', '*');
+ };
+ webview.addEventListener('loadcommit', onWebViewLoadCommit);
+
+
Charlie Reis 2012/11/20 01:54:00 nit: Remove extra line.
lazyboy 2012/11/20 02:55:20 Done.
+ var onPostMessageReceived = function(e) {
+ chrome.test.assertEq('access-denied', e.data);
+ chrome.test.succeed();
+ };
+ window.addEventListener('message', onPostMessageReceived);
+ }, 0);
+};
+
+onload = function() {
+ chrome.test.runTests([
+ function testMediaAccessPermission() {
+ chrome.test.getConfig(function(config) {
+ embedder.tests.testMediaAccessPermission();
+ });
+ }
+ ]);
+};

Powered by Google App Engine
This is Rietveld 408576698