You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2020/09/11 11:40:26 UTC
[GitHub] [cordova-plugin-inappbrowser] guycalledseven opened a new issue #780: iOS wrong event.url in IAB events (beforeload, loadstart and loadstop)
guycalledseven opened a new issue #780:
URL: https://github.com/apache/cordova-plugin-inappbrowser/issues/780
# Bug Report
## Problem
I have ionic/cordova IOS/Android/Electron project that downloads zip, unzips it and shows html/css/js from that zip.
It worked OK while on UIWebView and cordova-plugin-inappbrowser v3.2.0, but migrating to WKWebView and latest inappbrowser (4.0 from github master branch) proved a bit harder than I expected.
After my PR #778 I managed to open local files using `file://` , but XHR did not work.
I decided to ditch local files opening with file:// and I implemented local httpd server (using my fork of [cordova-httpd](https://github.com/guycalledseven/cordova-httpd)), and managed to get XHR to work again BUT found different and very strange bug.
My app relies on using IAB `beforeload`, `loadstart` and `loadstop` events which handle detection if outbond links were pressed in local html files etc. When page opens, and event gets triggered I can check `event.url` and see on which url the event got triggered.
### What does actually happen?
While using latest version of `cordova-plugin-inappbrowser` in `event.url` comes wrong.
Instead of `http://127.0.0.1:8888/20612/21018.html` I get `http://localhost:8080/127.0.0.1:8888/20612/21018.html`.
Notice the extra string: **`localhost:8080/`**.
## Information
Let's say that my local data is downloaded into
`/Users/{username}/Library/Developer/CoreSimulator/Devices/B0B80D63-64FD-4FBD-879B-92D2204BA713/data/Containers/Data/Application/1625CAAA-AF07-4706-BDA2-DB2D85938AB8/Documents/WebRoot`, and that is a web root of local webserver.
Local web server is started on `http://127.0.0.1:8888/`
The url passed to IAB for opening is `http:/127.0.0.1:8888/20612/21018.html`
**This works ok**, page gets opened. However, when ANY event is triggered, the `event.url` returned is: `http://localhost:8080/127.0.0.1:8888/20612/21018.html`
I have 0 (zero) references to `localhost:8080` in my code or `config.xml`. However, I have found out that after preparing project, this gets generated:
1. in `platforms/ios/<APPNAME>/config.xml`:
```
<allow-navigation href="http://localhost:8080/*" />
<allow-navigation href="http://127.0.0.1:8080/*" />
```
2. and in `platforms/ios/ios.json`:
```
...
{
"xml": "<allow-navigation href=\"http://localhost:8080/*\" />",
"count": 1
},
{
"xml": "<allow-navigation href=\"http://127.0.0.1:8080/*\" />",
"count": 1
},
...
```
All in all - `allow-navigation` configuration shouldn't have ANY impact on `event.url`.
### Command or Code
```
windowOptions : InAppBrowserOptions | string = {
location : 'no',
hidden : 'no',
zoom : 'yes',
useWideViewPort: 'yes',
hardwareback : 'yes',
hidenavigationbuttons : 'yes',
hideurlbar : 'yes',
mediaPlaybackRequiresUserAction : 'no',
shouldPauseOnSuspend : 'yes',
closebuttoncaption : this.translate.instant('book.close'),
disallowoverscroll : 'no',
toolbar : 'no',
toolbartranslucent : 'yes',
enableViewportScale : 'yes',
allowInlineMediaPlayback : 'yes',
presentationstyle : 'fullscreen',
fullscreen : 'yes',
footer: 'no',
beforeload: 'get'
};
var url = "http:/127.0.0.1:8888/20612/21018.html";
this.windowOptions = this.toOptionsString(this.windowOptions);
var browserIab = cordova.InAppBrowser.open(url, '_blank', this.windowOptions);
browserIab.addEventListener('beforeload', (event, load) => {
if (this.isUrlHomePage(event.url))
{
browserIab.close();
return;
}
});
private toOptionsString(optionsObject) {
return Object.keys(optionsObject).map((key) => key + '=' + optionsObject[key]).join(',');
}
```
### Environment, Platform, Device
iOS 13.7
### Version information
```
Ionic:
Ionic CLI : 6.11.8 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : ionic-angular 3.9.4
@ionic/app-scripts : 3.2.3
Cordova:
Cordova CLI : 10.0.0
Cordova Platforms : ios 5.1.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 2.5.3, cordova-plugin-ionic 5.4.7, (and 20 other plugins)
Utility:
cordova-res : 0.15.1
native-run : 1.0.0
System:
ios-sim : 8.0.2
NodeJS : v12.18.3 (/usr/local/Cellar/node@12/12.18.3/bin/node)
npm : 6.14.8
OS : macOS Catalina
Xcode : Xcode 11.7 Build version 11E801a
```
## Checklist
- [X] I searched for existing GitHub issues
- [ ] 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
[GitHub] [cordova-plugin-inappbrowser] guycalledseven commented on issue #780: iOS wrong event.url in IAB events (beforeload, loadstart and loadstop)
Posted by GitBox <gi...@apache.org>.
guycalledseven commented on issue #780:
URL: https://github.com/apache/cordova-plugin-inappbrowser/issues/780#issuecomment-691126095
**UPDATE:**
At first I thought this was because `cordova-ios` version 5.1.1 is old, but I updated to 6.1.1 of `cordova-ios` with the same strange result.
After further testing, I was able to pinpoint this issue to **`cordova-plugin-ionic-webview`**.
I was using pretty old version `2.5.3`. When I updated to latest `5.0` event.url was ok (without localhost:8080/), did not break anything in the process.
```
2020-09-11 15:33:32.223709+0200 IZZI[7618:2744419] beforeload event_url: http://127.0.0.1:8888/20612/21018.html
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
[GitHub] [cordova-plugin-inappbrowser] guycalledseven commented on issue #780: iOS wrong event.url in IAB events (beforeload, loadstart and loadstop)
Posted by GitBox <gi...@apache.org>.
guycalledseven commented on issue #780:
URL: https://github.com/apache/cordova-plugin-inappbrowser/issues/780#issuecomment-691126095
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
[GitHub] [cordova-plugin-inappbrowser] guycalledseven commented on issue #780: iOS wrong event.url in IAB events (beforeload, loadstart and loadstop)
Posted by GitBox <gi...@apache.org>.
guycalledseven commented on issue #780:
URL: https://github.com/apache/cordova-plugin-inappbrowser/issues/780#issuecomment-691126095
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org