Lukenickerson opened a new issue, #110:
URL: https://github.com/apache/cordova-browser/issues/110
# Bug Report
## Problem
Including `cordova.js` in an iframe page causes cordova functionality to
fail in the parent, but gives no indication as to *why*.
### What is expected to happen?
When you load an iframe page that includes `cordova.js`, but the parent has
already included `cordova.js`, I would expect either:
1. An error is shown immediately, similar to what happens if you include
cordova.js twice in the same page.
2. OR cordova functionality can work independently on both the iframe page
and the parent page without error.
### What does actually happen?
When running cordova functionality, such a plugin, in the parent page an
error is thrown: **Error: Java exception was raised during method invocation at
androidExec (cordova.js:992) ...**
This is confusing because it makes it look like the error is in that
particular part of the parent's code. It is very difficult to debug and
discover that the iframe's cordova.js is really causing the underlying issue.
### Command or Code
Create a base page that includes cordova.js, contains an iframe, loads
another page, and then tries to do some cordova functionality.
1. Create an `iframe.html` with the basic html tags (html, head, body).
Include `<script src="cordova.js"></script>` in the `<head>`.
3. Create a `index.html` page that includes `<script
src="cordova.js"></script>` in the head and `<iframe id="test"></iframe>` in
the body. Also include some javascript to run after the page loads -- see next
steps.
4. Include a test function that runs some cordova functionality in the
`index.html`:
```js
// As an example this uses the ActivityIndicator plugin, but you should be
able to use any plugin functionality:
function test() {
try {
ActivityIndicator.show('test');
ActivityIndicator.hide();
console.log('Test ran OK');
} catch (err) {
console.error(err);
}
}
```
5. Run the test before and after the iframe page is loaded
```js
test(); // should work fine
// Now load the iframe page
const iframe = document.getElementById('test');
iframe.src = 'iframe.html';
iframe.addEventListener('load', () => {
console.log('iframe is loaded');
// No error is shown by just loading the iframe
// But all subsequent cordova functionality, e.g., running the test
again, should now throw an error
test();
});
```
6. Open the index page in cordova in an Android emulator
### Environment, Platform, Device
Windows, in Android emulator
### Version information
I'm using `cordova-android` of `10.1.2`, cordova command line `11.0.0`. In
the `cordova.js` file it says `PLATFORM_VERSION_BUILD_LABEL = '4.4.3'`
## Checklist
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]