Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <html> | 1 <html> |
| 2 <video autoplay controls></video> | 2 <video autoplay controls></video> |
| 3 <script src=media-file.js></script> | 3 <script src=media-file.js></script> |
| 4 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 | 4 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 |
| 5 (Please avoid writing new tests using video-test.js) --> | 5 (Please avoid writing new tests using video-test.js) --> |
| 6 <script src=video-test.js></script> | 6 <script src=video-test.js></script> |
| 7 <body> | 7 <body> |
| 8 <pre> | 8 <pre> |
| 9 Check if the autoplay gesture override experiment works. There are a lot | 9 Check if the autoplay gesture override experiment works. There are a lot |
| 10 of config options, so this test just runs all of them. | 10 of config options, so this test just runs all of them. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 yes - muted attribute is set on the element. | 33 yes - muted attribute is set on the element. |
| 34 Mobile - is page optimized for mobile? | 34 Mobile - is page optimized for mobile? |
| 35 no - page is not optimized for mobile. | 35 no - page is not optimized for mobile. |
| 36 yes - page is optimized for mobile. | 36 yes - page is optimized for mobile. |
| 37 View - is media in viewport? | 37 View - is media in viewport? |
| 38 onscreen - element starts out onscreen. | 38 onscreen - element starts out onscreen. |
| 39 scroll - element starts offscreen, scrolled into view once | 39 scroll - element starts offscreen, scrolled into view once |
| 40 it is ready to play. | 40 it is ready to play. |
| 41 offscreen - element starts out offscreen and stays offscreen. | 41 offscreen - element starts out offscreen and stays offscreen. |
| 42 obscured - onscreen but page is not visible. | 42 obscured - onscreen but page is not visible. |
| 43 Setting - autoplay settings value | |
| 44 enabled - content settings enables autoplay | |
| 45 disabled - content settings disables autoplay | |
| 43 | 46 |
| 44 == Test Outputs == | 47 == Test Outputs == |
| 45 Early? - did playback start before element was scrolled onscreen? For | 48 Early? - did playback start before element was scrolled onscreen? For |
| 46 tests in which View!=scroll, this is reported as "-". | 49 tests in which View!=scroll, this is reported as "-". |
| 47 Played? - did playback start by the conclusion of the test? | 50 Played? - did playback start by the conclusion of the test? |
| 48 Muted? - was the media muted? If the media didn't play, then this is | 51 Muted? - was the media muted? If the media didn't play, then this is |
| 49 reported as "-". | 52 reported as "-". |
| 50 | 53 |
| 51 </pre> | 54 </pre> |
| 52 <table id="results"> | 55 <table id="results"> |
| 53 <tr> | 56 <tr> |
| 54 <td>#</td> | 57 <td>#</td> |
| 55 <td>Flags</td> | 58 <td>Flags</td> |
| 56 <td>Type</td> | 59 <td>Type</td> |
| 57 <td>Play w/</td> | 60 <td>Play w/</td> |
| 58 <td>Mute</td> | 61 <td>Mute</td> |
| 59 <td>Mobile</td> | 62 <td>Mobile</td> |
| 60 <td>View</td> | 63 <td>View</td> |
| 64 <td>Setting</td> | |
| 61 <td>Early?</td> | 65 <td>Early?</td> |
| 62 <td>Played?</td> | 66 <td>Played?</td> |
| 63 <td>Muted?</td> | 67 <td>Muted?</td> |
| 64 </tr> | 68 </tr> |
| 65 </table> | 69 </table> |
| 66 </body> | 70 </body> |
| 67 | 71 |
| 68 <script> | 72 <script> |
| 69 | 73 |
| 70 // Starting configuration number. This should be zero normally. | 74 // Starting configuration number. This should be zero normally. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 88 } | 92 } |
| 89 | 93 |
| 90 function becomeOptimizedForMobile(enable) | 94 function becomeOptimizedForMobile(enable) |
| 91 { | 95 { |
| 92 // If we're in the right state already, then return; | 96 // If we're in the right state already, then return; |
| 93 if (enable == isOptimizedForMobile) | 97 if (enable == isOptimizedForMobile) |
| 94 return; | 98 return; |
| 95 | 99 |
| 96 if (!enable) { | 100 if (!enable) { |
| 97 // We can't transition out of optimized for mobile. | 101 // We can't transition out of optimized for mobile. |
| 98 console.log("becomeOptimizedForMobile: test is broken -- cannot un-enabl e mobile"); | |
| 99 endTest(); | 102 endTest(); |
| 100 } else { | 103 } else { |
| 101 // This only works once. | 104 // This only works once. |
| 102 mobileMetaTag = document.createElement('meta'); | 105 mobileMetaTag = document.createElement('meta'); |
| 103 mobileMetaTag.name = "viewport"; | 106 mobileMetaTag.name = "viewport"; |
| 104 mobileMetaTag.content = "width=device-width"; | 107 mobileMetaTag.content = "width=device-width"; |
| 105 document.head.appendChild(mobileMetaTag); | 108 document.head.appendChild(mobileMetaTag); |
| 106 isOptimizedForMobile = true; | 109 isOptimizedForMobile = true; |
| 107 } | 110 } |
| 108 } | 111 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 123 smallType += type.includes("-foraudio")?"a":""; | 126 smallType += type.includes("-foraudio")?"a":""; |
| 124 smallType += type.includes("-ifviewport")?"V":""; | 127 smallType += type.includes("-ifviewport")?"V":""; |
| 125 smallType += type.includes("-ifpagevisible")?"P":""; | 128 smallType += type.includes("-ifpagevisible")?"P":""; |
| 126 smallType += type.includes("-ifmuted")?"M":""; | 129 smallType += type.includes("-ifmuted")?"M":""; |
| 127 smallType += type.includes("-playmuted")?"p":""; | 130 smallType += type.includes("-playmuted")?"p":""; |
| 128 smallType += type.includes("-ifmobile")?"m":""; | 131 smallType += type.includes("-ifmobile")?"m":""; |
| 129 row.insertCell().innerText = smallType; | 132 row.insertCell().innerText = smallType; |
| 130 | 133 |
| 131 // Add remaining fields. | 134 // Add remaining fields. |
| 132 var fields = [ "elementType", "autoplayType", "mutedType", "mobileType", | 135 var fields = [ "elementType", "autoplayType", "mutedType", "mobileType", |
| 133 "visType", "playedEarly", "played", "muted"]; | 136 "visType", "settingValue", "playedEarly", "played", "muted"]; |
| 134 for(idx in fields) | 137 for(idx in fields) |
| 135 row.insertCell().innerText = spec[fields[idx]].substring(0,7); | 138 row.insertCell().innerText = spec[fields[idx]].substring(0,7); |
| 136 } | 139 } |
| 137 | 140 |
| 138 function configureElementViaScript(element, spec) | 141 function configureElementViaScript(element, spec) |
| 139 { | 142 { |
| 140 if(spec.autoplayType == "play()") | 143 if(spec.autoplayType == "play()") |
| 141 element.play(); | 144 element.play(); |
| 142 } | 145 } |
| 143 | 146 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 164 // test to proceed very slowly. | 167 // test to proceed very slowly. |
| 165 testRunner.setPageVisibility("visible"); | 168 testRunner.setPageVisibility("visible"); |
| 166 | 169 |
| 167 queueNextExperiment(); | 170 queueNextExperiment(); |
| 168 } | 171 } |
| 169 | 172 |
| 170 function runOneConfig(spec) | 173 function runOneConfig(spec) |
| 171 { | 174 { |
| 172 internals.settings.setAutoplayExperimentMode(spec.experimentType); | 175 internals.settings.setAutoplayExperimentMode(spec.experimentType); |
| 173 internals.settings.setViewportMetaEnabled(true); | 176 internals.settings.setViewportMetaEnabled(true); |
| 177 testRunner.setAutoplayAllowed(spec.settingValue == "enabled"); | |
| 174 | 178 |
| 175 // Create, configure, and attach a media element. | 179 // Create, configure, and attach a media element. |
| 176 var element = document.createElement(spec.elementType); | 180 var element = document.createElement(spec.elementType); |
| 177 element.controls = true; | 181 element.controls = true; |
| 178 | 182 |
| 179 // Hide or show the page. | 183 // Hide or show the page. |
| 180 if (spec.visType == "obscured") | 184 if (spec.visType == "obscured") |
| 181 testRunner.setPageVisibility("hidden"); | 185 testRunner.setPageVisibility("hidden"); |
| 182 | 186 |
| 183 // Pick whether the element will be visible when canPlayThrough. | 187 // Pick whether the element will be visible when canPlayThrough. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 "enabled-foraudio", | 245 "enabled-foraudio", |
| 242 "enabled-forvideo-ifmobile", | 246 "enabled-forvideo-ifmobile", |
| 243 "enabled-foraudio-ifviewport", | 247 "enabled-foraudio-ifviewport", |
| 244 ]; | 248 ]; |
| 245 var elementTypes = ["video", "audio"]; | 249 var elementTypes = ["video", "audio"]; |
| 246 var autoplayTypes = ["none", "attr", "play()"]; | 250 var autoplayTypes = ["none", "attr", "play()"]; |
| 247 var mutedTypes = ["no", "yes"]; | 251 var mutedTypes = ["no", "yes"]; |
| 248 var visTypes = ["onscreen", "scroll", "offscreen", "obscured"]; | 252 var visTypes = ["onscreen", "scroll", "offscreen", "obscured"]; |
| 249 // mobileTypes must always start with no, since we cannot un-optimize the page. | 253 // mobileTypes must always start with no, since we cannot un-optimize the page. |
| 250 var mobileTypes = ["no", "yes"]; | 254 var mobileTypes = ["no", "yes"]; |
| 255 var autoplaySettings = ["enabled", "disabled"]; | |
| 251 | 256 |
| 252 function runNextConfig() | 257 function runNextConfig() |
| 253 { | 258 { |
| 254 // Convert configNumber into a spec, and run it. | 259 // Convert configNumber into a spec, and run it. |
| 255 var exp = configNumber; | 260 var exp = configNumber; |
| 256 | 261 |
| 257 // Convert this experiment number into settings. | 262 // Convert this experiment number into settings. |
| 258 var spec = {}; | 263 var spec = {}; |
| 259 spec.elementType = elementTypes[exp % elementTypes.length]; | 264 spec.elementType = elementTypes[exp % elementTypes.length]; |
| 260 exp = Math.floor(exp / elementTypes.length); | 265 exp = Math.floor(exp / elementTypes.length); |
| 261 spec.experimentType = experimentTypes[exp % experimentTypes.length]; | 266 spec.experimentType = experimentTypes[exp % experimentTypes.length]; |
| 262 exp = Math.floor(exp / experimentTypes.length); | 267 exp = Math.floor(exp / experimentTypes.length); |
| 263 spec.autoplayType = autoplayTypes[exp % autoplayTypes.length]; | 268 spec.autoplayType = autoplayTypes[exp % autoplayTypes.length]; |
| 264 exp = Math.floor(exp / autoplayTypes.length); | 269 exp = Math.floor(exp / autoplayTypes.length); |
| 265 spec.mutedType = mutedTypes[exp % mutedTypes.length]; | 270 spec.mutedType = mutedTypes[exp % mutedTypes.length]; |
| 266 exp = Math.floor(exp / mutedTypes.length); | 271 exp = Math.floor(exp / mutedTypes.length); |
| 267 spec.visType = visTypes[exp % visTypes.length]; | 272 spec.visType = visTypes[exp % visTypes.length]; |
| 268 exp = Math.floor(exp / visTypes.length); | 273 exp = Math.floor(exp / visTypes.length); |
| 274 spec.settingValue = autoplaySettings[exp % autoplaySettings.length]; | |
|
liberato (no reviews please)
2016/04/29 14:41:43
might want to restrict the cases that this covers
| |
| 275 exp = Math.floor(exp / autoplaySettings.length); | |
| 269 // Mobile must always change last, so that all the "no" cases precede | 276 // Mobile must always change last, so that all the "no" cases precede |
| 270 // all the "yes" cases, since we can't switch the doc back to "not | 277 // all the "yes" cases, since we can't switch the doc back to "not |
| 271 // optimized for mobile". | 278 // optimized for mobile". |
| 272 spec.mobileType = mobileTypes[exp % mobileTypes.length]; | 279 spec.mobileType = mobileTypes[exp % mobileTypes.length]; |
| 273 exp = Math.floor(exp / mobileTypes.length); | 280 exp = Math.floor(exp / mobileTypes.length); |
| 281 | |
| 274 spec.experimentNumber = configNumber; | 282 spec.experimentNumber = configNumber; |
| 275 | 283 |
| 276 // Return null if configNumber was larger than the highest experiment. | 284 // Return null if configNumber was larger than the highest experiment. |
| 277 if (exp > 0) | 285 if (exp > 0) |
| 278 endTest(); | 286 endTest(); |
| 279 | 287 |
| 280 configNumber++; | 288 configNumber++; |
| 281 | 289 |
| 282 // To keep the test fast, skip a few combinations. | 290 // To keep the test fast, skip a few combinations. |
| 283 var skip = false; | 291 var skip = false; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 queueNextExperiment(); | 340 queueNextExperiment(); |
| 333 else | 341 else |
| 334 runOneConfig(spec); | 342 runOneConfig(spec); |
| 335 } | 343 } |
| 336 | 344 |
| 337 window.internals.settings.setMediaPlaybackRequiresUserGesture(true); | 345 window.internals.settings.setMediaPlaybackRequiresUserGesture(true); |
| 338 runNextConfig(); | 346 runNextConfig(); |
| 339 | 347 |
| 340 </script> | 348 </script> |
| 341 </html> | 349 </html> |
| OLD | NEW |