cordova-plugin-file
cordova-plugin-file copied to clipboard
fix(android) Issue #329 - Allow plugins to "exec" when on a cdvfile:// url
Allow plugins to exec when on a cdvfile:// url in Android 4.4 (Already works properly in at least Android 6.0+)
Platforms affected
Android (Specifically for Android OS 4.4, maybe Android OS 5.0)
Motivation and Context
This fixes #329
(Also accidentally caused my previous pull request (PR #332) to accidentally close.)
Description
Due to different/incorrect native code in Android 4.4, the received origin onJsPrompt is "" when on a "cdvfile://" url.
So in the case that cordova-plugin-file is asked if a url should(be)Allow(ed)BridgeAccess, it will manually retrieve the url from the webView in the case that it has received the broken "" and check if it is a "cdvfile://" url.
Testing
Added the plugin as a local file to my project. Debugged the new Android code. Walked through it. Observed that desired result of cordova-plugin-file being able to "exec". (Other plugins were also then able to do their exec commands and fire their ready channels as well.) And deviceready was finally fired.
Ran the manual tests, they all passed. The automatic tests had the same failures before and after my change.
Added a new manual test which basically redirects to the same page but is a cdvfile url.
This allows you to run tests from the cdvfile url. When you open this page with an Android OS 4.4 device (before my changes), it is completely blank. After the changes, all the tests run again successfully on the cdvfile url (except those that were broken before changes).
Passed npm run eslint
Checklist
- [x] I've run the tests to see all new and existing tests pass
- [x] I added automated test coverage as appropriate for this change
- [x] Commit is prefixed with
(platform)if this change only applies to one platform (e.g.(android)) - [x] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
- [x] I've updated the documentation if necessary