(browser) support safari private browsing mode by using base64 text instead of blob #301
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Platforms affected
cordova-browser
Motivation and Context
Bascially cordova-browser uses indexeddb in order to store File(Blob) object as file-saving.
However the private browsing mode on safari browser in mac does not permit to store
File(Blob) object into the indexeddb.
(See Webkit source code https://github.com/WebKit/webkit/blob/5dada1bf8d706e1c544f1a23bfb67f3eaeb4f412/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp#L328-L331 )
This PR is to fix this issue.
Description
The private borwsing mode on safari throws
DataCloneError
when storing Blob object to indexeddb.Therefore this PR detects
DataCloneError
and store base64 encoded text instead of Blob object itself.According to this, decoding/encoding helper functions are introduced.
Note that the safari browser (emulator ?) in the saucelab used in travis ci seems to work in
private browsing mode.
For example previous master branch fails tests for safari browser in travis ci like https://travis-ci.org/apache/cordova-plugin-file/builds/502885593?utm_source=github_status&utm_medium=notification .
This PR fix the issue.
Testing
The test with both public and private browsing modes on safari on My local mac are done.
I confirmed this PR passes all test suites (specs).
Checklist
(platform)
if this change only applies to one platform (e.g.(android)
)