| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 * Copyright 2014 The Chromium Authors. All rights reserved. Use of this | 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 | 3 * source code is governed by a BSD-style license that can be found in the |
| 4 * LICENSE file. | 4 * LICENSE file. |
| 5 --> | 5 --> |
| 6 <html> | 6 <html> |
| 7 <head> | 7 <head> |
| 8 <script type="text/javascript"> | 8 <script type="text/javascript"> |
| 9 // A guest that requests media sources, which in turn checks for media | 9 // A guest that requests media devices, which in turn checks for media |
| 10 // access permission. | 10 // access permission. |
| 11 // Notifies the embedder when done via post message. Note that the | 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 | 12 // embedder has to initiate a postMessage first so that guest has a |
| 13 // reference to the embedder's window. | 13 // reference to the embedder's window. |
| 14 | 14 |
| 15 // The window reference of the embedder to send post message reply. | 15 // The window reference of the embedder to send post message reply. |
| 16 var embedderWindowChannel = null; | 16 var embedderWindowChannel = null; |
| 17 | 17 |
| 18 var notifyEmbedder = function(msg) { | 18 var notifyEmbedder = function(msg) { |
| 19 embedderWindowChannel.postMessage(msg, '*'); | 19 embedderWindowChannel.postMessage(msg, '*'); |
| 20 }; | 20 }; |
| 21 | 21 |
| 22 var onSourceInfo = function(sources) { | 22 var onSourceInfo = function(sources) { |
| 23 notifyEmbedder(JSON.stringify(['got-sources'])); | 23 notifyEmbedder(JSON.stringify(['got-sources'])); |
| 24 }; | 24 }; |
| 25 var startTest = function() { | 25 var startTest = function() { |
| 26 MediaStreamTrack.getSources(onSourceInfo); | 26 navigator.mediaDevices.enumerateDevices().then(onSourceInfo); |
| 27 }; | 27 }; |
| 28 var onPostMessageReceived = function(e) { | 28 var onPostMessageReceived = function(e) { |
| 29 var data = JSON.parse(e.data); | 29 var data = JSON.parse(e.data); |
| 30 var testName = data[0]; | 30 var testName = data[0]; |
| 31 if (testName == 'get-sources-permission') { | 31 if (testName == 'get-sources-permission') { |
| 32 embedderWindowChannel = e.source; | 32 embedderWindowChannel = e.source; |
| 33 | 33 |
| 34 // Start the test once we have |embedderWindowChannel|. | 34 // Start the test once we have |embedderWindowChannel|. |
| 35 startTest(); | 35 startTest(); |
| 36 } | 36 } |
| 37 }; | 37 }; |
| 38 window.addEventListener('message', onPostMessageReceived, false); | 38 window.addEventListener('message', onPostMessageReceived, false); |
| 39 </script> | 39 </script> |
| 40 </head> | 40 </head> |
| 41 <body> | 41 <body> |
| 42 <div> | 42 <div> |
| 43 This is a guest requests media sources, which will check for media | 43 This is a guest requests media sources, which will check for media |
| 44 access permission. | 44 access permission. |
| 45 </div> | 45 </div> |
| 46 </body> | 46 </body> |
| 47 </html> | 47 </html> |
| OLD | NEW |