4 <title>Setting src twice after MediaKeys set
</title>
5 <script src=
"encrypted-media-utils.js"></script>
6 <script src=
"../../resources/testharness.js"></script>
7 <script src=
"../../resources/testharnessreport.js"></script>
10 <video id=
"testVideo"></video>
13 async_test(function(test
)
16 var encryptedEventIndex
= 0;
17 var video
= document
.getElementById('testVideo');
18 assert_not_equals(video
, null);
20 var onEncrypted = function(event
)
22 ++encryptedEventIndex
;
23 assert_not_equals(video
.mediaKeys
, null);
24 assert_true(video
.mediaKeys
=== mediaKeys
);
26 // This event is fired once for the audio stream and once
27 // for the video stream each time .src is set.
28 if (encryptedEventIndex
== 2) {
29 // Finished first video, set src a second time.
30 video
.src
= '../content/test-encrypted.webm';
31 } else if (encryptedEventIndex
== 4) {
32 // Finished second video.
37 // Create a MediaKeys object and assign it to video.
38 navigator
.requestMediaKeySystemAccess('org.w3.clearkey', [{}])
39 .then(function(access
) {
40 assert_equals(access
.keySystem
, 'org.w3.clearkey');
41 return access
.createMediaKeys();
42 }).then(function(result
) {
44 assert_not_equals(mediaKeys
, null);
45 return video
.setMediaKeys(mediaKeys
);
46 }).then(function(result
) {
47 assert_not_equals(video
.mediaKeys
, null, 'not set initially');
48 assert_true(video
.mediaKeys
=== mediaKeys
);
50 // Set src to a video.
51 waitForEventAndRunStep('encrypted', video
, onEncrypted
, test
);
52 video
.src
= '../content/test-encrypted.webm';
53 }).catch(function(error
) {
54 forceTestFailureFromPromise(test
, error
);
56 }, 'Setting src twice after MediaKeys set.');