OLD | NEW |
(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 function activation_behavior_test(tagName, src) |
| 9 { |
| 10 async_test(function(t) |
| 11 { |
| 12 var e = document.createElement(tagName); |
| 13 e.controls = true; |
| 14 e.src = src; |
| 15 e.preload = 'auto'; |
| 16 e.oncanplay = t.step_func(function() |
| 17 { |
| 18 assert_greater_than(e.readyState, e.HAVE_CURRENT_DATA, 'element read
yState'); |
| 19 e.controller = new MediaController(); |
| 20 assert_false(e.controller.paused, 'controller paused state before cl
ick'); |
| 21 assert_true(e.paused, 'element paused state before click'); |
| 22 e.click(); |
| 23 assert_false(e.controller.paused, 'controller paused state after cli
ck'); |
| 24 assert_false(e.paused, 'element paused state after click'); |
| 25 t.done(); |
| 26 }); |
| 27 }, tagName + ' activation behavior for restrained media controller'); |
| 28 |
| 29 async_test(function(t) |
| 30 { |
| 31 var e = document.createElement(tagName); |
| 32 e.controls = true; |
| 33 e.src = src; |
| 34 e.preload = 'auto'; |
| 35 e.oncanplay = t.step_func(function() |
| 36 { |
| 37 e.pause(); // clears autoplaying flag |
| 38 assert_greater_than(e.readyState, e.HAVE_CURRENT_DATA, 'element read
yState'); |
| 39 e.controller = new MediaController(); |
| 40 assert_false(e.controller.paused, 'controller paused state before cl
ick'); |
| 41 assert_true(e.paused, 'element paused state before click'); |
| 42 e.click(); |
| 43 assert_false(e.controller.paused, 'controller paused state after cli
ck'); |
| 44 assert_false(e.paused, 'element paused state after click'); |
| 45 t.done(); |
| 46 }); |
| 47 }, tagName + ' activation behavior for restrained media controller (with non
-autoplaying paused slave)'); |
| 48 |
| 49 async_test(function(t) |
| 50 { |
| 51 var e1 = document.createElement(tagName); |
| 52 var e2 = document.createElement(tagName); |
| 53 e1.controls = true; |
| 54 e1.src = e2.src = src; |
| 55 e1.preload = e2.preload = 'auto'; |
| 56 var canplaycount = 0; |
| 57 e1.oncanplay = e2.oncanplay = t.step_func(function() |
| 58 { |
| 59 if (++canplaycount != 2) { |
| 60 return; |
| 61 } |
| 62 e1.play(); |
| 63 assert_greater_than(e1.readyState, e1.HAVE_CURRENT_DATA, 'element 1
readyState'); |
| 64 assert_greater_than(e2.readyState, e2.HAVE_CURRENT_DATA, 'element 2
readyState'); |
| 65 e1.controller = new MediaController(); |
| 66 e2.controller = e1.controller; |
| 67 assert_false(e1.controller.paused, 'controller paused state before c
lick'); |
| 68 assert_false(e1.paused, 'element 1 paused state before click'); |
| 69 assert_true(e2.paused, 'element 2 paused state before click'); |
| 70 e1.click(); |
| 71 assert_false(e1.controller.paused, 'controller paused state after cl
ick'); |
| 72 assert_false(e1.paused, 'element 1 paused state after click'); |
| 73 assert_false(e2.paused, 'element 2 paused state after click'); |
| 74 t.done(); |
| 75 }); |
| 76 }, tagName + ' activation behavior for restrained media controller (with non
-blocked playing and autoplaying-and-paused slaves)'); |
| 77 |
| 78 test(function() |
| 79 { |
| 80 var e = document.createElement(tagName); |
| 81 e.controls = true; |
| 82 e.controller = new MediaController(); |
| 83 e.controller.pause(); |
| 84 assert_true(e.controller.paused, 'controller paused state before click')
; |
| 85 assert_true(e.paused, 'element paused state before click'); |
| 86 e.click(); |
| 87 assert_false(e.controller.paused, 'controller paused state after click')
; |
| 88 assert_true(e.paused, 'element paused state after click'); |
| 89 }, tagName + ' activation behavior for paused media controller'); |
| 90 |
| 91 async_test(function(t) |
| 92 { |
| 93 var e = document.createElement(tagName); |
| 94 e.controls = true; |
| 95 e.src = src; |
| 96 e.preload = 'auto'; |
| 97 e.oncanplay = t.step_func(function() |
| 98 { |
| 99 assert_greater_than(e.readyState, e.HAVE_CURRENT_DATA, 'element read
yState'); |
| 100 e.controller = new MediaController(); |
| 101 e.controller.pause(); |
| 102 assert_true(e.controller.paused, 'controller paused state before cli
ck'); |
| 103 assert_true(e.paused, 'element paused state before click'); |
| 104 e.click(); |
| 105 assert_false(e.controller.paused, 'controller paused state after cli
ck'); |
| 106 assert_true(e.paused, 'element paused state after click'); |
| 107 t.done(); |
| 108 }); |
| 109 }, tagName + ' activation behavior for paused media controller (with non-blo
cked paused slave)'); |
| 110 |
| 111 test(function() |
| 112 { |
| 113 var e = document.createElement(tagName); |
| 114 e.controls = true; |
| 115 e.controller = new MediaController(); |
| 116 e.controller.play(); |
| 117 assert_false(e.controller.paused, 'controller paused state before click'
); |
| 118 assert_false(e.paused, 'element paused state before click'); |
| 119 e.click(); |
| 120 assert_true(e.controller.paused, 'controller paused state after click'); |
| 121 assert_false(e.paused, 'element paused state after click'); |
| 122 }, tagName + ' activation behavior for playing media controller'); |
| 123 |
| 124 async_test(function(t) |
| 125 { |
| 126 var e = document.createElement(tagName); |
| 127 e.controls = true; |
| 128 e.src = src; |
| 129 e.preload = 'auto'; |
| 130 e.oncanplay = t.step_func(function() |
| 131 { |
| 132 e.play(); |
| 133 assert_greater_than(e.readyState, e.HAVE_CURRENT_DATA, 'element read
yState'); |
| 134 e.controller = new MediaController(); |
| 135 assert_false(e.controller.paused, 'controller paused state before cl
ick'); |
| 136 assert_false(e.paused, 'element paused state before click'); |
| 137 e.click(); |
| 138 assert_true(e.controller.paused, 'controller paused state after clic
k'); |
| 139 assert_false(e.paused, 'element paused state after click'); |
| 140 t.done(); |
| 141 }); |
| 142 }, tagName + ' activation behavior for playing media controller (with non-bl
ocked playing slave)'); |
| 143 |
| 144 async_test(function(t) |
| 145 { |
| 146 var e1 = document.createElement(tagName); |
| 147 var e2 = document.createElement(tagName); |
| 148 e1.controls = true; |
| 149 e1.src = src; |
| 150 e1.preload = 'auto'; |
| 151 e1.oncanplay = t.step_func(function() |
| 152 { |
| 153 assert_greater_than(e1.readyState, e1.HAVE_CURRENT_DATA, 'element 1
readyState'); |
| 154 assert_equals(e2.readyState, e2.HAVE_NOTHING, 'element 2 readyState'
); |
| 155 e1.controller = new MediaController(); |
| 156 e2.controller = e1.controller; |
| 157 assert_false(e1.controller.paused, 'controller paused state before c
lick'); |
| 158 assert_true(e1.paused, 'element 1 paused state before click'); |
| 159 assert_true(e2.paused, 'element 2 paused state before click'); |
| 160 e1.click(); |
| 161 assert_true(e1.controller.paused, 'controller paused state after cli
ck'); |
| 162 assert_true(e1.paused, 'element 1 paused state after click'); |
| 163 assert_true(e2.paused, 'element 2 paused state after click'); |
| 164 t.done(); |
| 165 }); |
| 166 }, tagName + ' activation behavior for playing media controller (with non-bl
ocked autoplaying-and-paused and blocked paused slaves)'); |
| 167 |
| 168 test(function() |
| 169 { |
| 170 var e = document.createElement(tagName); |
| 171 e.controls = true; |
| 172 assert_true(e.paused, 'paused state before click()'); |
| 173 e.click(); |
| 174 assert_false(e.paused, 'paused state after click()'); |
| 175 }, tagName + ' activation behavior for paused media element'); |
| 176 |
| 177 test(function() |
| 178 { |
| 179 var e = document.createElement(tagName); |
| 180 e.controls = true; |
| 181 e.play(); |
| 182 assert_false(e.paused, 'paused state before click()'); |
| 183 e.click(); |
| 184 assert_true(e.paused, 'paused state after click()'); |
| 185 }, tagName + ' activation behavior for playing media element'); |
| 186 |
| 187 test(function() |
| 188 { |
| 189 var e = document.createElement(tagName); |
| 190 e.controls = true; |
| 191 e.onclick = function(ev) { ev.preventDefault(); }; |
| 192 assert_true(e.paused, 'paused state before click()'); |
| 193 e.click(); |
| 194 assert_true(e.paused, 'paused state after click()'); |
| 195 }, tagName + ' activation behavior for canceled event'); |
| 196 |
| 197 test(function() |
| 198 { |
| 199 var e = document.createElement(tagName); |
| 200 assert_true(e.paused, 'paused state before click()'); |
| 201 e.click(); |
| 202 assert_true(e.paused, 'paused state after click()'); |
| 203 }, tagName + ' activation behavior without controls'); |
| 204 } |
| 205 |
| 206 activation_behavior_test('audio', findMediaFile('audio', 'content/test')); |
| 207 activation_behavior_test('video', findMediaFile('video', 'content/test')); |
| 208 </script> |
OLD | NEW |