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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/polyfill/cast-polyfill.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() {
2
3 if ( /CrKey\/[0-9]+\.[0-9a-z]+\.[0-9a-z]+/i.exec( navigator.userAgent ) ) {
4
5 var castscript = document.createElement('script');
6 castscript.type = 'text/javascript';
7 castscript.src = 'https://www.gstatic.com/cast/sdk/libs/receiver/2.0.0/c ast_receiver.js'
8 document.head.appendChild( castscript );
9
10 var _requestMediaKeySystemAccess = navigator.requestMediaKeySystemAccess .bind( navigator ),
11 _setMediaKeys = HTMLMediaElement.prototype.setMediaKeys,
12 _load = MediaKeySession.prototype.load;
13
14 MediaKeySession.prototype.load = function load()
15 {
16 return _load.call( this ).then( function( success )
17 {
18 return success ? this.remove() : false;
19 }.bind( this ) );
20 };
21
22 function MediaKeys( mediaKeys )
23 {
24 this._mediaKeys = mediaKeys;
25 }
26
27 MediaKeys.prototype.setServerCertificate = function setServerCertificate ( certificate )
28 {
29 return this._mediaKeys.setServerCertificate( certificate );
30 };
31
32 MediaKeys.prototype.createSession = function createSession( sessionType ) {
33
34 if ( sessionType === 'persistent-usage-record' )
35 {
36 return cast.receiver.eme.KeySession.createSession( this._mediaKe ys, 'persistent-release-message' );
37 }
38
39 return this._mediaKeys.createSession( sessionType );
40 };
41
42 function MediaKeySystemAccess( access )
43 {
44 this._access = mediaKeySystemAccess;
45 }
46
47 Object.defineProperty( MediaKeySystemAccess.prototype, 'keySystem', { ge t: function() { return this._access.keySystem; } } );
48
49 MediaKeySystemAccess.prototype.getConfiguration = function getConfigurat ion() { return this._access.getConfiguration(); };
50
51 MediaKeySystemAccess.prototype.createMediaKeys = function createMediaKey s() {
52
53 return this._access.createMediaKey().then( function( mediaKeys ) { r eturn new MediaKeys( mediaKeys ); } );
54
55 };
56
57 HTMLMediaElement.prototype.setMediaKeys = function setMediaKeys( mediaKe ys )
58 {
59 if ( mediaKeys instanceof MediaKeys )
60 {
61 return _setMediaKeys.call( this, mediaKeys._mediaKeys );
62 }
63 else
64 {
65 return _setMediaKeys.call( this, mediaKeys );
66 }
67 };
68
69 navigator.requestMediaKeySystemAccess = function requestMediaKeySystemAc cess( keysystem, supportedConfigurations ) {
70
71 if ( keysystem !== 'com.chromecast.playready' )
72 {
73 return _requestMediaKeySystemAccess( keysystem, supportedConfigu rations );
74 }
75
76 return _requestMediaKeySystemAccess( keysystem, supportedConfigurati ons )
77 .then( function( access ) { return new MediaKeySystemAccess( access ); } );
78 };
79 }
80 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698