2 * Copyright 2014 The Chromium Authors. All rights reserved. Use of this
3 * source code is governed by a BSD-style license that can be found in the
8 <script type=
"text/javascript">
9 // A guest that requests media sources, which in turn checks for media
11 // Notifies the embedder when done via post message. Note that the
12 // embedder has to initiate a postMessage first so that guest has a
13 // reference to the embedder's window.
15 // The window reference of the embedder to send post message reply.
16 var embedderWindowChannel
= null;
18 var notifyEmbedder = function(msg
) {
19 embedderWindowChannel
.postMessage(msg
, '*');
22 var onSourceInfo = function(sources
) {
23 notifyEmbedder(JSON
.stringify(['got-sources']));
25 var startTest = function() {
26 MediaStreamTrack
.getSources(onSourceInfo
);
28 var onPostMessageReceived = function(e
) {
29 var data
= JSON
.parse(e
.data
);
30 var testName
= data
[0];
31 if (testName
== 'get-sources-permission') {
32 embedderWindowChannel
= e
.source
;
34 // Start the test once we have |embedderWindowChannel|.
38 window
.addEventListener('message', onPostMessageReceived
, false);
43 This is a guest requests media sources, which will check for media