|
7 | 7 | 'use strict';
|
8 | 8 |
|
9 | 9 | promise_test(async t => {
|
10 |
| - assert_idl_attribute(navigator, 'getDisplayMedia'); |
11 |
| - const stream = await navigator.getDisplayMedia({video: true}); |
| 10 | + assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia'); |
| 11 | + const stream = await navigator.mediaDevices.getDisplayMedia({video: true}); |
12 | 12 | const [track] = stream.getTracks();
|
13 | 13 | t.add_cleanup(() => track.stop());
|
14 | 14 | assert_equals(stream.getTracks().length, 1);
|
|
22 | 22 | // Note that this results in some non-intuitive cases returning a video track,
|
23 | 23 | // i.e. {video: false}.
|
24 | 24 | promise_test(async t => {
|
25 |
| - assert_idl_attribute(navigator, 'getDisplayMedia'); |
26 |
| - const stream = await navigator.getDisplayMedia(); |
| 25 | + assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia'); |
| 26 | + const stream = await navigator.mediaDevices.getDisplayMedia(); |
27 | 27 | const [track] = stream.getTracks();
|
28 | 28 | t.add_cleanup(() => track.stop());
|
29 | 29 | assert_equals(stream.getTracks().length, 1);
|
|
32 | 32 | }, 'getDisplayMedia() with no constraints');
|
33 | 33 |
|
34 | 34 | promise_test(async t => {
|
35 |
| - assert_idl_attribute(navigator, 'getDisplayMedia'); |
36 |
| - const stream = await navigator.getDisplayMedia({video: false}); |
| 35 | + assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia'); |
| 36 | + const stream = await navigator.mediaDevices.getDisplayMedia({video: false}); |
37 | 37 | const [track] = stream.getTracks();
|
38 | 38 | t.add_cleanup(() => track.stop());
|
39 | 39 | assert_equals(stream.getTracks().length, 1);
|
|
42 | 42 | }, 'getDisplayMedia() with video false');
|
43 | 43 |
|
44 | 44 | promise_test(async t => {
|
45 |
| - assert_idl_attribute(navigator, 'getDisplayMedia'); |
46 |
| - const stream = await navigator.getDisplayMedia({audio: false}); |
| 45 | + assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia'); |
| 46 | + const stream = await navigator.mediaDevices.getDisplayMedia({audio: false}); |
47 | 47 | const [track] = stream.getTracks();
|
48 | 48 | t.add_cleanup(() => track.stop());
|
49 | 49 | assert_equals(stream.getTracks().length, 1);
|
|
52 | 52 | }, 'getDisplayMedia() with audio false');
|
53 | 53 |
|
54 | 54 | promise_test(async t => {
|
55 |
| - assert_idl_attribute(navigator, 'getDisplayMedia'); |
56 |
| - const stream = await navigator.getDisplayMedia({audio: true}); |
| 55 | + assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia'); |
| 56 | + const stream = await navigator.mediaDevices.getDisplayMedia({audio: true}); |
57 | 57 | const [track] = stream.getTracks();
|
58 | 58 | t.add_cleanup(() => track.stop());
|
59 | 59 | assert_equals(stream.getTracks().length, 1);
|
|
62 | 62 | }, 'getDisplayMedia() with audio true');
|
63 | 63 |
|
64 | 64 | promise_test(async t => {
|
65 |
| - assert_idl_attribute(navigator, 'getDisplayMedia'); |
| 65 | + assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia'); |
66 | 66 | try {
|
67 |
| - const stream = |
68 |
| - await navigator.getDisplayMedia({video: {advanced: [{zoom: 1}]}}); |
| 67 | + const stream = await navigator.mediaDevices.getDisplayMedia( |
| 68 | + {video: {advanced: [{zoom: 1}]}}); |
69 | 69 | } catch (err) {
|
70 | 70 | assert_equals(err.name, 'TypeError');
|
71 | 71 | return;
|
|
74 | 74 | }, 'getDisplayMedia() with advanced constraint');
|
75 | 75 |
|
76 | 76 | promise_test(async t => {
|
77 |
| - assert_idl_attribute(navigator, 'getDisplayMedia'); |
| 77 | + assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia'); |
78 | 78 | try {
|
79 |
| - const stream = |
80 |
| - await navigator.getDisplayMedia({video: {width: {min: 360}}}); |
| 79 | + const stream = await navigator.mediaDevices.getDisplayMedia( |
| 80 | + {video: {width: {min: 360}}}); |
81 | 81 | } catch (err) {
|
82 | 82 | assert_equals(err.name, 'TypeError');
|
83 | 83 | return;
|
|
86 | 86 | }, 'getDisplayMedia() with min constraint');
|
87 | 87 |
|
88 | 88 | promise_test(async t => {
|
89 |
| - assert_idl_attribute(navigator, 'getDisplayMedia'); |
| 89 | + assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia'); |
90 | 90 | try {
|
91 |
| - const stream = |
92 |
| - await navigator.getDisplayMedia({video: {width: {exact: 360}}}); |
| 91 | + const stream = await navigator.mediaDevices.getDisplayMedia( |
| 92 | + {video: {width: {exact: 360}}}); |
93 | 93 | } catch (err) {
|
94 | 94 | assert_equals(err.name, 'TypeError');
|
95 | 95 | return;
|
|
98 | 98 | }, 'getDisplayMedia() with exact constraint');
|
99 | 99 |
|
100 | 100 | promise_test(async t => {
|
101 |
| - assert_idl_attribute(navigator, 'getDisplayMedia'); |
| 101 | + assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia'); |
102 | 102 | const maxWidth = 360;
|
103 |
| - const stream = |
104 |
| - await navigator.getDisplayMedia({video: {width: {max: maxWidth}}}); |
| 103 | + const stream = await navigator.mediaDevices.getDisplayMedia( |
| 104 | + {video: {width: {max: maxWidth}}}); |
105 | 105 | const [track] = stream.getTracks();
|
106 | 106 | t.add_cleanup(() => track.stop());
|
107 | 107 | assert_equals(stream.getVideoTracks().length, 1);
|
|
111 | 111 | }, 'getDisplayMedia() with max constraint');
|
112 | 112 |
|
113 | 113 | promise_test(async t => {
|
114 |
| - assert_idl_attribute(navigator, 'getDisplayMedia'); |
| 114 | + assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia'); |
115 | 115 | const maxWidth = 360;
|
116 | 116 | const maxFrameRate = 4;
|
117 |
| - const stream = await navigator.getDisplayMedia( |
| 117 | + const stream = await navigator.mediaDevices.getDisplayMedia( |
118 | 118 | {video: {width: {max: maxWidth}, frameRate: {max: maxFrameRate}}});
|
119 | 119 | const [track] = stream.getTracks();
|
120 | 120 | t.add_cleanup(() => track.stop());
|
|
126 | 126 | }, 'getDisplayMedia() with constraints applied');
|
127 | 127 |
|
128 | 128 | promise_test(async t => {
|
129 |
| - assert_idl_attribute(navigator, 'getDisplayMedia'); |
| 129 | + assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia'); |
130 | 130 | try {
|
131 |
| - const stream = await navigator.getDisplayMedia({video: {width: {max: 0}}}); |
| 131 | + const stream = await navigator.mediaDevices.getDisplayMedia( |
| 132 | + {video: {width: {max: 0}}}); |
132 | 133 | } catch (err) {
|
133 | 134 | assert_equals(err.name, 'OverconstrainedError');
|
134 | 135 | return;
|
|
138 | 139 |
|
139 | 140 | // Content shell picks a fake desktop device by default.
|
140 | 141 | promise_test(async t => {
|
141 |
| - assert_idl_attribute(navigator, 'getDisplayMedia'); |
142 |
| - const stream = await navigator.getDisplayMedia({video: true}); |
| 142 | + assert_idl_attribute(navigator.mediaDevices, 'getDisplayMedia'); |
| 143 | + const stream = await navigator.mediaDevices.getDisplayMedia({video: true}); |
143 | 144 | const [track] = stream.getTracks();
|
144 | 145 | t.add_cleanup(() => track.stop());
|
145 | 146 | assert_equals(stream.getVideoTracks().length, 1);
|
|
0 commit comments