Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: LayoutTests/media/activation-behavior.html

Issue 249483002: Disable the activation behavior of media elements (click to play/pause) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/media/activation-behavior-accesskey.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!doctype html>
2 <title>activation behavior</title>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script src="media-file.js"></script>
6 <div id="log"></div>
7 <script>
8 var uniqueSrcCounter = 0;
9
10 function activation_behavior_test(tagName, src)
11 {
12 // FIXME: hack used to investigate http://crbug.com/355489
13 function uniqueSrc()
14 {
15 return src + '?activation-behavior-' + ++uniqueSrcCounter;
16 }
17
18 async_test(function(t)
19 {
20 var e = document.createElement(tagName);
21 e.controls = true;
22 e.src = uniqueSrc();
23 e.preload = 'auto';
24 e.oncanplay = t.step_func(function()
25 {
26 assert_greater_than(e.readyState, e.HAVE_CURRENT_DATA, 'element read yState');
27 e.controller = new MediaController();
28 assert_false(e.controller.paused, 'controller paused state before cl ick');
29 assert_true(e.paused, 'element paused state before click');
30 e.click();
31 assert_false(e.controller.paused, 'controller paused state after cli ck');
32 assert_false(e.paused, 'element paused state after click');
33 t.done();
34 });
35 }, tagName + ' activation behavior for restrained media controller');
36
37 async_test(function(t)
38 {
39 var e = document.createElement(tagName);
40 e.controls = true;
41 e.src = uniqueSrc();
42 e.preload = 'auto';
43 e.oncanplay = t.step_func(function()
44 {
45 e.pause(); // clears autoplaying flag
46 assert_greater_than(e.readyState, e.HAVE_CURRENT_DATA, 'element read yState');
47 e.controller = new MediaController();
48 assert_false(e.controller.paused, 'controller paused state before cl ick');
49 assert_true(e.paused, 'element paused state before click');
50 e.click();
51 assert_false(e.controller.paused, 'controller paused state after cli ck');
52 assert_false(e.paused, 'element paused state after click');
53 t.done();
54 });
55 }, tagName + ' activation behavior for restrained media controller (with non -autoplaying paused slave)');
56
57 async_test(function(t)
58 {
59 var e1 = document.createElement(tagName);
60 var e2 = document.createElement(tagName);
61 e1.controls = true;
62 e1.src = uniqueSrc();
63 e2.src = uniqueSrc();
64 e1.preload = e2.preload = 'auto';
65 var canplaycount = 0;
66 e1.oncanplay = e2.oncanplay = t.step_func(function()
67 {
68 if (++canplaycount != 2) {
69 return;
70 }
71 e1.play();
72 assert_greater_than(e1.readyState, e1.HAVE_CURRENT_DATA, 'element 1 readyState');
73 assert_greater_than(e2.readyState, e2.HAVE_CURRENT_DATA, 'element 2 readyState');
74 e1.controller = new MediaController();
75 e2.controller = e1.controller;
76 assert_false(e1.controller.paused, 'controller paused state before c lick');
77 assert_false(e1.paused, 'element 1 paused state before click');
78 assert_true(e2.paused, 'element 2 paused state before click');
79 e1.click();
80 assert_false(e1.controller.paused, 'controller paused state after cl ick');
81 assert_false(e1.paused, 'element 1 paused state after click');
82 assert_false(e2.paused, 'element 2 paused state after click');
83 t.done();
84 });
85 }, tagName + ' activation behavior for restrained media controller (with non -blocked playing and autoplaying-and-paused slaves)');
86
87 test(function()
88 {
89 var e = document.createElement(tagName);
90 e.controls = true;
91 e.controller = new MediaController();
92 e.controller.pause();
93 assert_true(e.controller.paused, 'controller paused state before click') ;
94 assert_true(e.paused, 'element paused state before click');
95 e.click();
96 assert_false(e.controller.paused, 'controller paused state after click') ;
97 assert_true(e.paused, 'element paused state after click');
98 }, tagName + ' activation behavior for paused media controller');
99
100 async_test(function(t)
101 {
102 var e = document.createElement(tagName);
103 e.controls = true;
104 e.src = uniqueSrc();
105 e.preload = 'auto';
106 e.oncanplay = t.step_func(function()
107 {
108 assert_greater_than(e.readyState, e.HAVE_CURRENT_DATA, 'element read yState');
109 e.controller = new MediaController();
110 e.controller.pause();
111 assert_true(e.controller.paused, 'controller paused state before cli ck');
112 assert_true(e.paused, 'element paused state before click');
113 e.click();
114 assert_false(e.controller.paused, 'controller paused state after cli ck');
115 assert_true(e.paused, 'element paused state after click');
116 t.done();
117 });
118 }, tagName + ' activation behavior for paused media controller (with non-blo cked paused slave)');
119
120 test(function()
121 {
122 var e = document.createElement(tagName);
123 e.controls = true;
124 e.controller = new MediaController();
125 e.controller.play();
126 assert_false(e.controller.paused, 'controller paused state before click' );
127 assert_false(e.paused, 'element paused state before click');
128 e.click();
129 assert_true(e.controller.paused, 'controller paused state after click');
130 assert_false(e.paused, 'element paused state after click');
131 }, tagName + ' activation behavior for playing media controller');
132
133 async_test(function(t)
134 {
135 var e = document.createElement(tagName);
136 e.controls = true;
137 e.src = uniqueSrc();
138 e.preload = 'auto';
139 e.oncanplay = t.step_func(function()
140 {
141 e.play();
142 assert_greater_than(e.readyState, e.HAVE_CURRENT_DATA, 'element read yState');
143 e.controller = new MediaController();
144 assert_false(e.controller.paused, 'controller paused state before cl ick');
145 assert_false(e.paused, 'element paused state before click');
146 e.click();
147 assert_true(e.controller.paused, 'controller paused state after clic k');
148 assert_false(e.paused, 'element paused state after click');
149 t.done();
150 });
151 }, tagName + ' activation behavior for playing media controller (with non-bl ocked playing slave)');
152
153 async_test(function(t)
154 {
155 var e1 = document.createElement(tagName);
156 var e2 = document.createElement(tagName);
157 e1.controls = true;
158 e1.src = uniqueSrc();
159 e1.preload = 'auto';
160 e1.oncanplay = t.step_func(function()
161 {
162 assert_greater_than(e1.readyState, e1.HAVE_CURRENT_DATA, 'element 1 readyState');
163 assert_equals(e2.readyState, e2.HAVE_NOTHING, 'element 2 readyState' );
164 e1.controller = new MediaController();
165 e2.controller = e1.controller;
166 assert_false(e1.controller.paused, 'controller paused state before c lick');
167 assert_true(e1.paused, 'element 1 paused state before click');
168 assert_true(e2.paused, 'element 2 paused state before click');
169 e1.click();
170 assert_true(e1.controller.paused, 'controller paused state after cli ck');
171 assert_true(e1.paused, 'element 1 paused state after click');
172 assert_true(e2.paused, 'element 2 paused state after click');
173 t.done();
174 });
175 }, tagName + ' activation behavior for playing media controller (with non-bl ocked autoplaying-and-paused and blocked paused slaves)');
176
177 test(function()
178 {
179 var e = document.createElement(tagName);
180 e.controls = true;
181 assert_true(e.paused, 'paused state before click()');
182 e.click();
183 assert_false(e.paused, 'paused state after click()');
184 }, tagName + ' activation behavior for paused media element');
185
186 test(function()
187 {
188 var e = document.createElement(tagName);
189 e.controls = true;
190 e.play();
191 assert_false(e.paused, 'paused state before click()');
192 e.click();
193 assert_true(e.paused, 'paused state after click()');
194 }, tagName + ' activation behavior for playing media element');
195
196 test(function()
197 {
198 var e = document.createElement(tagName);
199 e.controls = true;
200 e.onclick = function(ev) { ev.preventDefault(); };
201 assert_true(e.paused, 'paused state before click()');
202 e.click();
203 assert_true(e.paused, 'paused state after click()');
204 }, tagName + ' activation behavior for canceled event');
205
206 test(function()
207 {
208 var e = document.createElement(tagName);
209 assert_true(e.paused, 'paused state before click()');
210 e.click();
211 assert_true(e.paused, 'paused state after click()');
212 }, tagName + ' activation behavior without controls');
213 }
214
215 activation_behavior_test('audio', findMediaFile('audio', 'content/test'));
216 activation_behavior_test('video', findMediaFile('video', 'content/test'));
217 </script>
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/media/activation-behavior-accesskey.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698