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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/playback-temporary-two-videos.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,qualifier) {
2
3 var testname = testnamePrefix(qualifier, config.keysystem)
4 + ', temporary, '
5 + /video\/([^;]*)/.exec(config.videoType)[1]
6 + ', playback two videos';
7
8 var configuration = { initDataTypes: [ config.initDataType ],
9 audioCapabilities: [ { contentType: config.audioType } ],
10 videoCapabilities: [ { contentType: config.videoType } ],
11 sessionTypes: [ 'temporary' ] };
12
13 promise_test(function(test)
14 {
15 var promises = config.video.map(function(video) { return play_video_as_p romise(test,video); });
16 return Promise.all(promises);
17
18 }, testname);
19
20 function play_video_as_promise(test, _video) {
21 var _mediaKeys,
22 _mediaKeySession,
23 _mediaSource;
24
25 function onFailure(error) {
26 forceTestFailureFromPromise(test, error);
27 }
28
29 function onMessage(event) {
30 assert_equals(event.target, _mediaKeySession);
31 assert_true(event instanceof window.MediaKeyMessageEvent);
32 assert_equals(event.type, 'message');
33
34 assert_in_array( event.messageType, ['license-request', 'individuali zation-request']);
35
36 config.messagehandler(event.messageType, event.message).then(functio n(response) {
37 return _mediaKeySession.update(response);
38 }).catch(onFailure);
39 }
40
41 function onEncrypted(event) {
42 assert_equals(event.target, _video);
43 assert_true(event instanceof window.MediaEncryptedEvent);
44 assert_equals(event.type, 'encrypted');
45
46 waitForEventAndRunStep('message', _mediaKeySession, onMessage, test) ;
47
48 _mediaKeySession.generateRequest(config.initData ? config.initDataTy pe : event.initDataType,
49 config.initData || event.initDat a).catch(onFailure);
50 }
51
52 function wait_for_timeupdate_message(video)
53 {
54 return new Promise(function(resolve) {
55 video.addEventListener('timeupdate', function listener(event) {
56 if (event.target.currentTime > (config.duration || 1))
57 {
58 video.removeEventListener('timeupdate', listener);
59 resolve(event);
60 }
61 });
62 });
63 };
64
65 return navigator.requestMediaKeySystemAccess(config.keysystem, [configur ation]).then(function(access) {
66 return access.createMediaKeys();
67 }).then(function(mediaKeys) {
68 _mediaKeys = mediaKeys;
69 return _video.setMediaKeys(_mediaKeys);
70 }).then(function() {
71 _mediaKeySession = _mediaKeys.createSession('temporary');
72 waitForEventAndRunStep('encrypted', _video, onEncrypted, test);
73 return testmediasource(config);
74 }).then(function(source) {
75 _mediaSource = source;
76 _video.src = URL.createObjectURL(_mediaSource);
77 return source.done;
78 }).then(function(){
79 _video.play();
80 return wait_for_timeupdate_message(_video);
81 }).catch(onFailure);
82 }
83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698