Skip to content

Disable indexedDB support if a SecurityError is thrown#2236

Merged
joeyparrish merged 5 commits intoshaka-project:masterfrom
devartis:master
Nov 14, 2019
Merged

Disable indexedDB support if a SecurityError is thrown#2236
joeyparrish merged 5 commits intoshaka-project:masterfrom
devartis:master

Conversation

@gikrauss
Copy link
Contributor

When using Shaka player inside an cross domain iframe in Firefox with 3rd party cookies blocked, probeSupport method throws a SecurityError.

The error is thrown in lib/offline/indexeddb/storage_mechanism.js:340, when accessing window.indexedDB.

The proposed solution removes window.indexedDB with a polyfill, using the same approach implemented for Chromecast.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@gikrauss
Copy link
Contributor Author

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

Copy link
Member

@joeyparrish joeyparrish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for your contribution!

Copy link
Member

@joeyparrish joeyparrish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for your contribution!

@shaka-bot
Copy link
Collaborator

Test Failure:

Generating Closure dependencies...
Linting JavaScript...

/var/lib/jenkins/workspace/Manual PR Test (local-tests)/lib/polyfill/indexed_db.js
44:13  error  Unexpected negating the left operand of 'instanceof' operator  no-unsafe-negation

✖ 1 problem (1 error, 0 warnings)
1 error and 0 warnings potentially fixable with the `--fix` option.

END-BUILD: FAILURE
Build step 'Execute shell' marked build as failure

Copy link
Member

@joeyparrish joeyparrish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks! I'll run it through the build bot once more.

@shaka-bot
Copy link
Collaborator

Test Failure:

Generating Closure dependencies...
Linting JavaScript...
Linting CSS...
Linting HTML...

Config loaded: /var/lib/jenkins/workspace/Manual PR Test (local-tests)/.htmlhintrc

Config loaded: /var/lib/jenkins/workspace/Manual PR Test (local-tests)/.htmlhintrc

Config loaded: /var/lib/jenkins/workspace/Manual PR Test (local-tests)/.htmlhintrc

Scanned 3 files, no errors found (49 ms).
Checking that the build files are complete...
Checking for common misspellings...
Checking correct usage of eslint-disable...
Checking the tests for type errors...
No changes detected, skipping. Use --force to override.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.protobuf.UnsafeUtil (file:/var/lib/jenkins/workspace/Manual%20PR%20Test%20(local-tests)/third_party/closure/compiler.jar) to field java.nio.Buffer.address
WARNING: Please consider reporting this to the maintainers of com.google.protobuf.UnsafeUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
/var/lib/jenkins/workspace/Manual PR Test (local-tests)/lib/polyfill/indexed_db.js:42: ERROR - Suspicious code. The result of the 'getprop' operator is not being used.
window.indexedDB;
^^^^^^^^^^^^^^^^

1 error(s), 0 warning(s), 90.4% typed
Build failed
END-BUILD: FAILURE
Build step 'Execute shell' marked build as failure

@gikrauss
Copy link
Contributor Author

I've refactored this code a bit to avoid the previous error ("The result of the 'getprop' operator is not being used"). Additionally, this caused the compiler to completely remove this code.

The compiled version, with this refactor is:
var b=!1;if(Ic("CrKey"))b=!0;else try{window.indexedDB&&(b=!1)}catch(c){b=!0}b&&delete window.indexedDB}

Copy link
Member

@joeyparrish joeyparrish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks!

@shaka-bot
Copy link
Collaborator

Test Failure:

Generating Closure dependencies...
Linting JavaScript...

/var/lib/jenkins/workspace/Manual PR Test (local-tests)/lib/polyfill/indexed_db.js
41:1  error  Line 41 exceeds the maximum line length of 80  max-len
47:1  error  Line 47 exceeds the maximum line length of 80  max-len

✖ 2 problems (2 errors, 0 warnings)

END-BUILD: FAILURE
Build step 'Execute shell' marked build as failure

@gikrauss
Copy link
Contributor Author

Fixed max line length exceeded

@shaka-bot
Copy link
Collaborator

All tests passed!

@joeyparrish joeyparrish merged commit b4bfa15 into shaka-project:master Nov 14, 2019
@joeyparrish
Copy link
Member

Thanks so much for the contribution!

@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

status: archived Archived and locked; will not be updated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants