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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/playback-persistent-license.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 + ', persistent-license, '
5 + /video\/([^;]*)/.exec(config.videoType)[1]
6 + 'playback';
7
8 var configuration = { initDataTypes: [ config.initDataType ],
9 audioCapabilities: [ { contentType: config.audioType } ],
10 videoCapabilities: [ { contentType: config.videoType } ],
11 sessionTypes: [ 'persistent-license' ] };
12
13
14 async_test(function(test) {
15 var _video = config.video,
16 _mediaKeys,
17 _mediaKeySession,
18 _mediaSource;
19
20 function onFailure(error) {
21 forceTestFailureFromPromise(test, error);
22 }
23
24 function onMessage(event) {
25 assert_equals( event.target, _mediaKeySession );
26 assert_true( event instanceof window.MediaKeyMessageEvent );
27 assert_equals( event.type, 'message');
28
29 assert_in_array( event.messageType, [ 'license-request', 'individual ization-request' ] );
30
31 config.messagehandler(event.messageType, event.message).then( functi on( response ) {
32 return _mediaKeySession.update(response)
33 }).catch(onFailure);
34 }
35
36 function onEncrypted(event) {
37 assert_equals(event.target, _video);
38 assert_true(event instanceof window.MediaEncryptedEvent);
39 assert_equals(event.type, 'encrypted');
40
41 waitForEventAndRunStep('message', _mediaKeySession, onMessage, test) ;
42 _mediaKeySession.generateRequest( config.initData ? config.initDat aType : event.initDataType,
43 config.initData || event.initDat a ).catch(onFailure);
44 }
45
46 function onTimeupdate(event) {
47 if (_video.currentTime > (config.duration || 1)) {
48 _video.pause();
49 test.done();
50 }
51 }
52
53 function onPlaying(event) {
54 // Not using waitForEventAndRunStep() to avoid too many
55 // EVENT(onTimeUpdate) logs.
56 _video.addEventListener('timeupdate', onTimeupdate, true);
57 }
58
59 navigator.requestMediaKeySystemAccess(config.keysystem, [ configuration ]).then(function(access) {
60 return access.createMediaKeys();
61 }).then(function(mediaKeys) {
62 _mediaKeys = mediaKeys;
63 return _video.setMediaKeys(_mediaKeys);
64 }).then(function() {
65 _mediaKeySession = _mediaKeys.createSession( 'persistent-license' );
66 waitForEventAndRunStep('encrypted', _video, onEncrypted, test);
67 waitForEventAndRunStep('playing', _video, onPlaying, test);
68 return testmediasource(config);
69 }).then(function(source) {
70 _mediaSource = source;
71 _video.src = URL.createObjectURL(_mediaSource);
72 return source.done;
73 }).then(function(){
74 _video.play();
75 }).catch(onFailure);
76 }, testname);
77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698