Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/reset-src-after-setmediakeys.js

Issue 2546853003: Add W3C encrypted-media tests (Closed)
Patch Set: rebase now that content files landed Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 function runTest(config)
2 {
3 async_test(function(test) {
4 var mediaKeys;
5 var mediaSource;
6 var encryptedEventIndex = 0;
7 var video = config.video;
8 var keysystem = config.keysystem;
9 var configuration = {
10 initDataTypes: [config.initDataType],
11 audioCapabilities: [{
12 contentType: config.audioType
13 }],
14 videoCapabilities: [{
15 contentType: config.videoType
16 }],
17 sessionTypes: ['temporary']
18 };
19
20 assert_not_equals(video, null);
21
22 var onEncrypted = function(event) {
23 ++encryptedEventIndex;
24 assert_equals(video.mediaKeys, mediaKeys);
25
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; Create new media source and wait for tw o more encrypted events
30 return testmediasource(config).then(function (source) {
31 video.src = URL.createObjectURL(source);
32 }).catch(function (error) {
33 forceTestFailureFromPromise(test, error)
34 });
35 } else if (encryptedEventIndex === 4) {
36 // Finished second video.
37 test.done();
38 }
39 };
40
41 // Create a MediaKeys object and assign it to video.
42 return navigator.requestMediaKeySystemAccess(keysystem, [configuration]) .then(test.step_func(function (access) {
43 assert_equals(access.keySystem, keysystem);
44 return access.createMediaKeys();
45 })).then(test.step_func(function (result) {
46 mediaKeys = result;
47 assert_not_equals(mediaKeys, null);
48 return video.setMediaKeys(mediaKeys);
49 })).then(test.step_func(function () {
50 assert_equals(video.mediaKeys, mediaKeys);
51 return testmediasource(config);
52 })).then(function (source) {
53 waitForEventAndRunStep('encrypted', video, onEncrypted, test);
54 mediaSource = source;
55 video.src = URL.createObjectURL(mediaSource);
56 }).catch(function (error) {
57 forceTestFailureFromPromise(test, error);
58 });
59
60 }, 'Reset src after setMediaKeys().');
61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698