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

Unified Diff: chrome/test/data/extensions/platform_apps/web_view_media_access/embedder_has_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: Nit fix Created 8 years 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_permission/embedder.js
diff --git a/chrome/test/data/extensions/platform_apps/web_view_media_access/embedder_has_permission/embedder.js b/chrome/test/data/extensions/platform_apps/web_view_media_access/embedder_has_permission/embedder.js
new file mode 100644
index 0000000000000000000000000000000000000000..1fb1cb6247b924bc51680fc02c823136b0ca3b6e
--- /dev/null
+++ b/chrome/test/data/extensions/platform_apps/web_view_media_access/embedder_has_permission/embedder.js
@@ -0,0 +1,62 @@
+// 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) has
+// acccess to media. The embedder grants access to media to the guest.
+//
+// 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.
+embedder.tests.testMediaAccessPermission = function() {
+ document.querySelector('#webview-tag-container').innerHTML =
+ '<webview style="width: 100px; height: 100px;"' +
+ '></webview >';
+ var webview = document.querySelector('webview');
+ webview.setAttribute('src', embedder.guestURL);
Fady Samuel 2012/12/05 22:14:32 Out of curiosity, is there any reason why this is
lazyboy 2012/12/06 00:05:52 I think this was here because of the old way of do
+
+ // Timeout is required otherwise event registration on <webview> does not
+ // work.
Fady Samuel 2012/12/05 22:14:32 This timeout should no longer be required after Sa
lazyboy 2012/12/06 00:05:52 Done.
+ 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);
Fady Samuel 2012/12/05 22:14:32 Make this loadstop. I believe loadstop happens aft
lazyboy 2012/12/06 00:05:52 Done.
+
+ var onPostMessageReceived = function(e) {
+ chrome.test.assertEq('access-granted', 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