apache / apache/cordova-plugin-inappbrowser

Posting form data to wkwebview is not working

Open
#779 6 comments 3 reactions 0 assignees View on GitHub
info-needed
Dominant language
Java
Stars
1.1k
Forks
2.2k
PR merge metrics
No merged PRs in 30d

Description

# Bug Report
I am using inappbrowser plugin (v4.0.0) to redirect to external url, and trying to post data to the url through a form. It works fine in UIWebview, but when i upgraded to wkwebview it is failing.

let formContent = '';
    let element = document.createElement("div");
    let hiddenField = document.createElement("input");
    hiddenField.setAttribute("type", "hidden");
    hiddenField.setAttribute("name", “username”);
    hiddenField.setAttribute("value", “test”);
    element.appendChild(hiddenField);
    formContent += element.innerHTML;
    formContent += "< /form>";
    let formContentUrl = 'data:text/html;base64,' + btoa(formContent);

let options = {location: 'no', usewkwebview: 'yes'}

var browser = this.inAppBrowser.create(formContentUrl, "_blank", options);

browser.on('loadstop').subscribe(event => {
       browser.executeScript({code:"document.getElementById('myForm').submit();"} );
 });

### What is expected to happen?
Expected to post the form data to the url.

### What does actually happen?
The form post data are ignored while redirecting.

## Information

### Environment, Platform, Device
IOS with Wkwebview

### Version information
Cordova: Cordova CLI 9.0.0
Other Frameworks: Ionic 3.9.5 and CLI version 6.0.0
Operating System, Android Studio, Xcode etc.

## 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

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the supplied form submission flow on iOS with WKWebView, using the inAppBrowser create call and the loadstop/executeScript sequence. Compare it with UIWebView and verify completion when the external URL receives the hidden username field in the POST data.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.