diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/media/test/test_eme_autoplay.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/test/test_eme_autoplay.html')
-rw-r--r-- | dom/media/test/test_eme_autoplay.html | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/dom/media/test/test_eme_autoplay.html b/dom/media/test/test_eme_autoplay.html new file mode 100644 index 0000000000..c8947f63e0 --- /dev/null +++ b/dom/media/test/test_eme_autoplay.html @@ -0,0 +1,115 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test Encrypted Media Extensions</title> + <script 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> + <script type="text/javascript" src="https://example.com:443/tests/dom/media/test/eme.js"></script> +</head> +<body> +<pre id="test"> +<script class="testbody" type="text/javascript"> +/* import-globals-from eme.js */ +var manager = new MediaTestManager; + +var EMEmanifest = [ + { + name:"bipbop 10s", + tracks: [ + { + name:"video", + type:"video/mp4; codecs=\"avc1.4d4015\"", + fragments:[ "bipbop-cenc-video-10s.mp4", + ] + } + ], + keys: { + "7e571d037e571d037e571d037e571d11" : "7e5733337e5733337e5733337e573311", + }, + sessionType:"temporary", + sessionCount:1, + duration:10.01 + }, +]; + +function startTest(test, token) +{ + manager.started(token); + + let v = document.createElement("video"); + v.controls = true; + v.autoplay = true; + + document.body.appendChild(v); + + var eventCounts = { play: 0, playing: 0}; + function ForbiddenEvents(e) { + var video = e.target; + ok(video.readyState >= video.HAVE_FUTURE_DATA, "Must not have received event too early"); + is(eventCounts[e.type], 0, "event should have only be fired once"); + eventCounts[e.type]++; + } + // Log events for debugging. + var events = ["suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata", + "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort", + "waiting", "pause", "durationchange", "seeking", "seeked"]; + function logEvent(e) { + info("got " + e.type + " event"); + } + events.forEach(function(e) { + v.addEventListener(e, logEvent); + }); + v.addEventListener("play", ForbiddenEvents); + v.addEventListener("playing", ForbiddenEvents); + + var gotWaitingForKey = 0; + + let waitForKey = new EMEPromise; + v.addEventListener("waitingforkey", function() { + gotWaitingForKey += 1; + waitForKey.resolve(); + }); + + v.addEventListener("loadedmetadata", function() { + ok(SpecialPowers.do_lookupGetter(v, "isEncrypted").apply(v), + TimeStamp(token) + " isEncrypted should be true"); + is(v.isEncrypted, undefined, "isEncrypted should not be accessible from content"); + }); + + let finish = new EMEPromise; + v.addEventListener("playing", function() { + ok(true, TimeStamp(token) + " got playing event"); + // We expect only one waitingForKey as we delay until all sessions are ready. + // I.e. one waitingForKey should be fired, after which, we process all sessions, + // so it should not be possible to be blocked by a key after that point. + ok(gotWaitingForKey == 1, "Expected number 1 wait, got: " + gotWaitingForKey); + + finish.resolve(); + }); + + Promise.all([ + LoadInitData(v, test, token), + CreateAndSetMediaKeys(v, test, token), + LoadTest(test, v, token, false /* do not call endOfStream */), + waitForKey.promise]) + .then(values => { + let initData = values[0]; + return ProcessInitData(v, test, token, initData); + }) + .then(sessions => { + Log(token, "Updated all sessions, loading complete"); + finish.promise.then(() => CloseSessions(v, sessions)); + return finish.promise; + }) + .catch(reason => ok(false, reason)) + .then(() => manager.finished(token)); +} + +SimpleTest.waitForExplicitFinish(); +manager.runTests(EMEmanifest, startTest); + +</script> +</pre> +</body> +</html> |