(iOS): Fix iframes in iOS/WKWebview which were broken by #418. Fixes #424. #425
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
iOS
Motivation and Context
This fixes iframes in WKWebView implementation for iOS which was broken by PR #418 in its attempt to fix issue #417.
#418 tried to solve the issue of page links with target=_blank not working by redirecting any request which was not targeted at the main frame back to the main frame, based on https://stackoverflow.com/a/25853806/777265.
While this fixed links where target=_blank, it also had the unintended side effect of redirecting iframe requests, causing the target URL to be loaded into the main frame.
Description
This PR fixes that by only redirecting requests that don't have a target frame set, i.e. those with a "new window action" aka target=_blank.
This based on https://stackoverflow.com/a/25713070/777265.
Testing
The changes have been tested with page links that contain target=_blank (e.g. https://dpa99c.github.io/cordova-plugin-inappbrowser-test/iab_content/iab.html) and with pages that use iframes (e.g. https://www.trivago.com) to ensure both still work.
There are currently no automated tests that cover this functionality specifically.
Checklist
(platform)
if this change only applies to one platform (e.g.(android)
)