OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Test autoplay muted behaviour in various system conditions.</title> | 2 <title>Test autoplay muted behaviour in various system conditions.</title> |
3 <script src="../resources/testharness.js"></script> | 3 <script src="../resources/testharness.js"></script> |
4 <script src="../resources/testharnessreport.js"></script> | 4 <script src="../resources/testharnessreport.js"></script> |
5 <script src="media-file.js"></script> | 5 <script src="media-file.js"></script> |
6 <body></body> | 6 <body></body> |
7 <script> | 7 <script> |
8 var tests = [ | 8 var tests = [ |
9 { | 9 { |
10 name: 'regular conditions', | 10 name: 'regular conditions', |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 assert_true('lowEndDevice' in test.conditions); | 83 assert_true('lowEndDevice' in test.conditions); |
84 | 84 |
85 internals.settings.setDataSaverEnabled(test.conditions.dataSaver); | 85 internals.settings.setDataSaverEnabled(test.conditions.dataSaver); |
86 if (test.conditions.cellular) | 86 if (test.conditions.cellular) |
87 internals.setNetworkConnectionInfoOverride(true, 'cellular3g', 2.0); | 87 internals.setNetworkConnectionInfoOverride(true, 'cellular3g', 2.0); |
88 else | 88 else |
89 internals.clearNetworkConnectionInfoOverride(); | 89 internals.clearNetworkConnectionInfoOverride(); |
90 internals.settings.setForcePreloadNoneForMediaElements(test.conditions.lowEndD
evice); | 90 internals.settings.setForcePreloadNoneForMediaElements(test.conditions.lowEndD
evice); |
91 | 91 |
92 // Generic required settings. | 92 // Generic required settings. |
93 internals.settings.setMediaPlaybackRequiresUserGesture(true); | 93 internals.settings.setAutoplayPolicy('user-gesture-required'); |
94 internals.runtimeFlags.autoplayMutedVideosEnabled = true; | 94 internals.runtimeFlags.autoplayMutedVideosEnabled = true; |
95 | 95 |
96 t.add_cleanup(() => { | 96 t.add_cleanup(() => { |
97 internals.settings.setDataSaverEnabled(false); | 97 internals.settings.setDataSaverEnabled(false); |
98 internals.clearNetworkConnectionInfoOverride(); | 98 internals.clearNetworkConnectionInfoOverride(); |
99 internals.settings.setForcePreloadNoneForMediaElements(false); | 99 internals.settings.setForcePreloadNoneForMediaElements(false); |
100 internals.settings.setMediaPlaybackRequiresUserGesture(false); | 100 internals.settings.setAutoplayPolicy('no-user-gesture-required'); |
101 internals.runtimeFlags.autoplayMutedVideosEnabled = false; | 101 internals.runtimeFlags.autoplayMutedVideosEnabled = false; |
102 }); | 102 }); |
103 | 103 |
104 var count = 0; | 104 var count = 0; |
105 [ 'attribute', 'method' ].forEach(type => { | 105 [ 'attribute', 'method' ].forEach(type => { |
106 var media = document.createElement('video'); | 106 var media = document.createElement('video'); |
107 document.body.appendChild(media); | 107 document.body.appendChild(media); |
108 | 108 |
109 var expectedEvents = []; | 109 var expectedEvents = []; |
110 if (test.expectations.autoplay) | 110 if (test.expectations.autoplay) |
(...skipping 22 matching lines...) Expand all Loading... |
133 if (type == 'attribute') | 133 if (type == 'attribute') |
134 media.autoplay = true; | 134 media.autoplay = true; |
135 else if (type == 'method') | 135 else if (type == 'method') |
136 media.play().catch(e => {}); | 136 media.play().catch(e => {}); |
137 }); | 137 }); |
138 } | 138 } |
139 | 139 |
140 asyncTests[currentTest].step_func(runTest(asyncTests[currentTest], tests[current
Test])); | 140 asyncTests[currentTest].step_func(runTest(asyncTests[currentTest], tests[current
Test])); |
141 | 141 |
142 </script> | 142 </script> |
OLD | NEW |