Skip to content

Commit

Permalink
Disable indexedDB support if an error is thrown (shaka-project#2236)
Browse files Browse the repository at this point in the history
  • Loading branch information
gikrauss authored and joeyparrish committed Nov 14, 2019
1 parent 47c857d commit b4bfa15
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/polyfill/indexed_db.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,25 @@ shaka.polyfill.IndexedDB = class {
static install() {
shaka.log.debug('IndexedDB.install');

let disableIDB = false;
if (shaka.util.Platform.isChromecast()) {
shaka.log.debug('Removing IndexedDB from ChromeCast');
disableIDB = true;
} else {
try {
// This is necessary to avoid Closure compiler over optimize this
// block and remove it if it looks like a noop
if (window.indexedDB) {
disableIDB = false;
}
} catch (e) {
shaka.log.debug(
'Removing IndexedDB due to an exception when accessing it');
disableIDB = true;
}
}

if (disableIDB) {
delete window.indexedDB;
goog.asserts.assert(
!window.indexedDB, 'Failed to override window.indexedDB');
Expand Down

0 comments on commit b4bfa15

Please sign in to comment.