summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/encrypted-media/polyfill/chrome-polyfill.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/encrypted-media/polyfill/chrome-polyfill.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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.js37
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 0000000000..2f11497cca
--- /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 );
+
+ } } );
+ }
+ }
+}());