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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/resources/drm-retrieve-destroy-persistent-license.html

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 <!doctype html>
2 <html>
3 <head>
4 <meta charset=utf-8>
5 <title>Encrypted Media Extensions: persistent-license, retrieve and destroy, drm</title>
6 <link rel="help" href="https://w3c.github.io/encrypted-media/">
7
8 <!-- Helper scripts for Encrypted Media Extensions tests -->
9 <script src=/encrypted-media/util/utils.js></script>
10 <script src=/encrypted-media/util/fetch.js></script>
11 <script src=/encrypted-media/util/utf8.js></script>
12 <script src=/encrypted-media/util/testmediasource.js></script>
13
14 <!-- Message handler for DRM keysystem -->
15 <script src=/encrypted-media/util/drm-messagehandler.js></script>
16
17 </head>
18 <body>
19 <div id='log'></div>
20
21 <div id='video'>
22 <video id="videoelement" width="200px"></video>
23 </div>
24
25 <script>
26 // Wait for a message from the main window with details of our task
27 window.addEventListener('message', function(event) {
28
29 var config = event.data.config,
30 configuration = { initDataTypes: [config.initDataType],
31 audioCapabilities: [{contentType: config.audioTy pe}],
32 videoCapabilities: [{contentType: config.videoTy pe}],
33 sessionTypes: ['persistent-license']},
34 assertions = [];
35
36 var _mediaKeys,
37 _mediaKeySession;
38
39 config.video = document.getElementById('videoelement');
40 config.messagehandler = (new MessageHandler(config.keysystem, config.con tent, 'persistent-license')).messagehandler;
41
42 function onComplete() {
43 window.opener.postMessage(assertions, '*');
44 }
45
46 function onFailure(error) {
47 assertions.push({actual: false, expected: true, message: error.toStr ing()});
48 onComplete();
49 }
50
51 function onMessage( messageevent )
52 {
53 assertions.push({expected: true, actual: messageevent instanceof win dow.MediaKeyMessageEvent, message: "event is of correct class"});
54 assertions.push({expected: 'message', actual: messageevent.type, mes sage: "event type is message"});
55 assertions.push({expected: 'license-release', actual: messageevent.m essageType, message: "message type is license-release"});
56
57 config.messagehandler(messageevent.messageType, messageevent.message )
58 .then( function(response) {
59 return messageevent.target.update(response);
60 }).catch(onFailure);
61 }
62
63 function onTimeupdate(event) {
64 if (config.video.currentTime > (config.duration || 1)) {
65 config.video.pause();
66 config.video.removeAttribute('src');
67 config.video.load();
68 _mediaKeySession.remove();
69 }
70 }
71
72 function onClosed() {
73 // Try and reload and check this fails
74 var mediaKeySession = _mediaKeys.createSession('persistent-license') ;
75 mediaKeySession.load(event.data.sessionId ).then( function(success) {
76 assertions.push({expected: false, actual: success, message: "Loa d of removed session should fail"});
77 onComplete();
78 }).catch(onFailure);
79 }
80
81 navigator.requestMediaKeySystemAccess(config.keysystem, [configuration] )
82 .then(function(access) {
83 return access.createMediaKeys();
84 }).then(function(mediaKeys) {
85 _mediaKeys = mediaKeys;
86 return config.video.setMediaKeys(mediaKeys);
87 }).then(function() {
88 config.video.addEventListener('timeupdate', onTimeupdate, true);
89 _mediaKeySession = _mediaKeys.createSession('persistent-license');
90 _mediaKeySession.addEventListener('message', onMessage);
91 _mediaKeySession.closed.then(onClosed);
92 return _mediaKeySession.load(event.data.sessionId);
93 }).then(function(success) {
94 assertions.push({actual: success, expected: true, message: "Expect l oad session to succeed"});
95 if (!success) throw new DOMException();
96 return testmediasource(config);
97 }).then(function(source) {
98 config.video.src = URL.createObjectURL(source);
99 config.video.play();
100 })
101 .catch(onFailure);
102 } );
103
104
105 </script>
106 </body>
107 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698