Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / desktop_capture_delegate / example.com.html
blob0737f4ef2bee5274f2727e36441309f295b042b4
1 <!--
2 Copyright 2013 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
5 -->
6 <script>
8 var extensionId = "knldjmfmopnpolahpmmgbagdohdnhkik";
10 function sendToBrowser(msg) {
11 domAutomationController.send(msg);
14 function requestStreamId(callback) {
15 function onResponse(response) {
16 if (chrome.runtime.lastError) {
17 sendToBrowser(false);
18 return;
20 id = response["id"];
21 callback(id);
24 chrome.runtime.sendMessage(
25 extensionId, ["getStream"], onResponse);
28 function getStream() {
29 function onStreamId(id) {
30 if (!id) {
31 sendToBrowser(false);
32 return;
34 navigator.webkitGetUserMedia({
35 audio:false,
36 video: { mandatory: { chromeMediaSource: "desktop",
37 chromeMediaSourceId: id } }
38 }, sendToBrowser.bind(null, true), sendToBrowser.bind(null, false));
40 requestStreamId(onStreamId);
43 function getStreamWithInvalidId() {
44 function onStreamId(id) {
45 if (!id) {
46 sendToBrowser(false);
47 return;
49 navigator.webkitGetUserMedia({
50 audio:false,
51 video: { mandatory: { chromeMediaSource: "desktop",
52 chromeMediaSourceId: id + "x" } }
53 }, sendToBrowser.bind(null, false), sendToBrowser.bind(null, true));
55 requestStreamId(onStreamId);
58 function openPickerDialogAndReturn() {
59 chrome.runtime.sendMessage(
60 extensionId, ["getStreamNoWait"], function(message) {
61 // Once the picker is shown request to close the tab. The picker should
62 // be destroyed as result.
63 sendToBrowser(true);
64 });
67 </script>