Bug 1395922 [Part2]- [Test case] Playback clear content and drawImage via CanvasContext2D after detaching MediaKeys from HTMLMediaElement.
MozReview-Commit-ID: 5dWxsMEeXbr
new file mode 100644
--- /dev/null
+++ b/dom/media/test/bipbop_225w_175kbps.mp4^headers^
@@ -0,0 +1,1 @@
+Cache-Control: no-store
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -69,16 +69,18 @@ support-files =
bipbop-cenc-video1.m4s
bipbop-cenc-video1.m4s^headers^
bipbop-cenc-video2.m4s
bipbop-cenc-video2.m4s^headers^
bipbop-cenc-videoinit.mp4
bipbop-cenc-videoinit.mp4^headers^
bipbop-cenc-video-10s.mp4
bipbop-cenc-video-10s.mp4^headers^
+ bipbop_225w_175kbps.mp4
+ bipbop_225w_175kbps.mp4^headers^
bipbop_225w_175kbps-cenc-audio-key1-1.m4s
bipbop_225w_175kbps-cenc-audio-key1-1.m4s^headers^
bipbop_225w_175kbps-cenc-audio-key1-2.m4s
bipbop_225w_175kbps-cenc-audio-key1-2.m4s^headers^
bipbop_225w_175kbps-cenc-audio-key1-3.m4s
bipbop_225w_175kbps-cenc-audio-key1-3.m4s^headers^
bipbop_225w_175kbps-cenc-audio-key1-4.m4s
bipbop_225w_175kbps-cenc-audio-key1-4.m4s^headers^
@@ -778,16 +780,18 @@ skip-if = toolkit == 'android' # bug 114
tags=msg capturestream
skip-if = toolkit == 'android' # bug 1149374
[test_eme_stream_capture_blocked_case2.html]
tags=msg capturestream
skip-if = toolkit == 'android' # bug 1149374
[test_eme_stream_capture_blocked_case3.html]
tags=msg capturestream
skip-if = toolkit == 'android' # bug 1149374
+[test_eme_unsetMediaKeys_then_capture.html]
+skip-if = toolkit == 'android' # bug 1149374
[test_eme_waitingforkey.html]
skip-if = toolkit == 'android' # bug 1149374
[test_empty_resource.html]
[test_error_in_video_document.html]
[test_error_on_404.html]
[test_fastSeek.html]
skip-if = toolkit == 'android' # android(bug 1232305)
[test_fastSeek-forwards.html]
new file mode 100644
--- /dev/null
+++ b/dom/media/test/test_eme_unsetMediaKeys_then_capture.html
@@ -0,0 +1,107 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test Encrypted Media Extensions</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>
+ <script type="text/javascript" src="http://test1.mochi.test:8888/tests/dom/media/test/eme.js"></script>
+</head>
+<body>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+var manager = new MediaTestManager;
+
+// Test that if we can capture a video frame while playing clear content after
+// removing the MediaKeys object which was used for a previous encrypted content
+// playback on the same video element
+function startTest(test, token)
+{
+ manager.started(token);
+ var sessions = [];
+ function onSessionCreated(session) {
+ sessions.push(session);
+ }
+
+ let v = document.createElement("video");
+ document.body.appendChild(v);
+
+ let finish = new EMEPromise;
+
+ function onVideoEnded(ev) {
+ ok(true, TimeStamp(token) + " (ENCRYPTED) content playback ended.");
+ v.removeEventListener("ended", onVideoEnded);
+
+ function playClearVideo() {
+ var p1 = once(v, 'ended', function onended(e) {
+ ok(true, TimeStamp(token) + " (CLEAR) content playback ended.");
+ console.log(" bipbop.mp4 playback ended !!");
+ });
+ var p2 = once(v, 'playing', function onplay(e) {
+ ok(true, TimeStamp(token) + " (CLEAR) content is playing ");
+ canvasElem = document.createElement('canvas');
+ document.body.appendChild(canvasElem);
+ ctx2d = canvasElem.getContext('2d');
+
+ var gotTypeError = false;
+ try {
+ ctx2d.drawImage(v, 0, 0);
+ } catch (e) {
+ if (e instanceof TypeError) {
+ gotTypeError = true;
+ }
+ }
+ ok(!gotTypeError, TimeStamp(token) + " Canvas2D context drawImage succeed.")
+ });
+ v.src = 'bipbop_225w_175kbps.mp4';
+ v.play();
+ Promise.all([p1, p2]).then(() => {
+ manager.finished(token)
+ });
+ }
+
+ Promise.all(sessions.map(s => s.close()))
+ .then(() => {
+ v.setMediaKeys(null)
+ .then(() => {
+ ok(true, TimeStamp(token) + " Setting MediaKeys to null.");
+ playClearVideo();
+ }, () => {
+ ok(false, TimeStamp(token) + " Setting MediaKeys to null.");
+ });;
+ });
+ }
+
+ v.addEventListener("ended", onVideoEnded);
+
+ // Create a MediaKeys object and set to HTMLMediaElement then start the playback.
+ Promise.all([
+ LoadInitData(v, test, token),
+ CreateAndSetMediaKeys(v, test, token),
+ LoadTest(test, v, token)])
+ .then(values => {
+ let initData = values[0];
+ v.play();
+ initData.map(ev => {
+ let session = v.mediaKeys.createSession();
+ onSessionCreated(session);
+ MakeRequest(test, token, ev, session);
+ });
+ })
+ .then(() => {
+ return finish.promise;
+ })
+ .catch(reason => ok(false, reason))
+}
+
+function beginTest() {
+ manager.runTests(gEMETests, startTest);
+}
+
+SimpleTest.waitForExplicitFinish();
+SetupEMEPref(beginTest);
+
+</script>
+</pre>
+</body>
+</html>