diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/encrypted-media/polyfill/chrome-polyfill.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/encrypted-media/polyfill/chrome-polyfill.js')
-rw-r--r-- | testing/web-platform/tests/encrypted-media/polyfill/chrome-polyfill.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/testing/web-platform/tests/encrypted-media/polyfill/chrome-polyfill.js b/testing/web-platform/tests/encrypted-media/polyfill/chrome-polyfill.js new file mode 100644 index 000000000..2f11497cc --- /dev/null +++ b/testing/web-platform/tests/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 ); + + } } ); + } + } +}()); |