Bug 1499903 - part2 : add test. r=chunmin

Differential Revision: https://phabricator.services.mozilla.com/D9641

--HG--
extra : moz-landing-system : lando
This commit is contained in:
alwu 2018-10-26 22:36:18 +00:00
Родитель b0a8a872f6
Коммит ecee4c600d
2 изменённых файлов: 48 добавлений и 0 удалений

Просмотреть файл

@ -882,6 +882,7 @@ skip-if = toolkit == 'android' # bug 1274802, android(bug 1232305)
skip-if = toolkit == 'android' # android(bug 1232305)
[test_loop.html]
skip-if = toolkit == 'android' # bug 1242112, android(bug 1232305)
[test_looping_eventsOrder.html]
[test_media_selection.html]
[test_media_sniffer.html]
skip-if = android_version == '17' # android(bug 1232305)

Просмотреть файл

@ -0,0 +1,47 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Looping events order</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
</head>
<script type="text/javascript">
/**
* This test is used to ensure the events order when media is looping back to
* the start position. We should see events in following order.
* 'seeking' -> 'timeupdate' -> 'seeked'.
*/
const manager = new MediaTestManager;
async function testTimeupdateChanged({name, type, duration}) {
info(`- start testPlay for name=${name} -`);
const element = document.createElement(getMajorMimeType(type));
element.src = name;
element.loop = true;
await once(element, "canplay");
ok(await element.play().then(() => true, () => false), `start playing ${name}`);
let gotTimeUpdated = false;
await once(element, "seeking");
element.addEventListener("timeupdate", function() {
gotTimeUpdated = true;
}, {once: true});
await once(element, "seeked");
ok(gotTimeUpdated, "Got timeupdate between seeking and seeked.");
removeNodeAndSource(element);
}
async function runTest(test, token) {
manager.started(token);
await testTimeupdateChanged(test);
manager.finished(token);
}
manager.runTests(gSmallTests, runTest);
</script>
</pre>
</body>
</html>