Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / tab_capture / constraints.js
blob757949dbbe83f2c88631f5694be65cbe383d1178
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 chrome.test.runTests([
6   function supportsMediaConstraints() {
7     chrome.tabCapture.capture({
8       video: true,
9       audio: true,
10       videoConstraints: {
11           mandatory: {
12             maxWidth: 1000,
13             minWidth: 300
14           }
15       }
16     }, function(stream) {
17       chrome.test.assertTrue(!!stream);
18       stream.getVideoTracks()[0].stop();
19       stream.getAudioTracks()[0].stop();
20       chrome.test.succeed();
21     });
22   },
24   function rejectsOptionalMediaConstraints() {
25     chrome.tabCapture.capture({
26       video: true,
27       audio: true,
28       videoConstraints: {
29         mandatory: {
30         },
31         optional: {
32           maxWidth: 1000,
33           minWidth: 300
34         }
35       }
36     }, function(stream) {
37       chrome.test.assertTrue(!stream);
38       chrome.test.succeed();
39     });
40   },
42   function rejectsInvalidConstraints() {
43     chrome.tabCapture.capture({
44       video: true,
45       audio: true,
46       videoConstraints: {
47         mandatory: {
48           notValid: '123'
49         }
50       }
51     }, function(stream) {
52       chrome.test.assertTrue(!stream);
54       chrome.tabCapture.capture({
55         audio: true,
56         audioConstraints: {
57           mandatory: {
58             notValid: '123'
59           }
60         }
61       }, function(stream) {
62         chrome.test.assertTrue(!stream);
63         chrome.test.succeed();
64       });
65     });
66   }
67 ]);