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

Unified Diff: third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/polyfill/chrome-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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/polyfill/chrome-polyfill.js
diff --git a/third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/polyfill/chrome-polyfill.js b/third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/polyfill/chrome-polyfill.js
new file mode 100644
index 0000000000000000000000000000000000000000..2f11497ccafc73a462f9c269ee2b3d2e72a7e2d8
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/polyfill/chrome-polyfill.js
@@ -0,0 +1,37 @@
+(function(){
+ if( navigator.userAgent.toLowerCase().indexOf('edge') === -1
+ && navigator.userAgent.toLowerCase().indexOf('chrome') > -1){
+
+ if ( ( /chrome\/([0-9]*)\./.exec( navigator.userAgent.toLowerCase() )[1] | 0 ) < 54 ) {
+
+ // Work around https://bugs.chromium.org/p/chromium/issues/detail?id=622956
+ // Chrome does not fire the empty keystatuschange event when a session is closed
+ var _mediaKeySessionClose = MediaKeySession.prototype.close;
+ var _mediaKeySessionKeyStatusesGetter = Object.getOwnPropertyDescriptor( MediaKeySession.prototype, 'keyStatuses' ).get;
+ var _emptyMediaKeyStatusMap = { size: 0,
+ has: function() { return false; },
+ get: function() { return undefined; },
+ entries:function() { return []; }, // this may not be correct, I think it should be some iterator thing
+ keys: function() { return []; },
+ values: function() { return []; },
+ forEach:function() { return; } };
+
+ MediaKeySession.prototype.close = function close()
+ {
+ this.__closed = true;
+
+ setTimeout( function() {
+ this.dispatchEvent( new Event( 'keystatuseschange' ) );
+ }.bind( this ), 0 );
+
+ return _mediaKeySessionClose.call( this );
+ };
+
+ Object.defineProperty( MediaKeySession.prototype, 'keyStatuses', { get: function() {
+
+ return this.__closed ? _emptyMediaKeyStatusMap : _mediaKeySessionKeyStatusesGetter.call( this );
+
+ } } );
+ }
+ }
+}());

Powered by Google App Engine
This is Rietveld 408576698