You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "lars Johnson (JIRA)" <ji...@apache.org> on 2017/06/16 14:59:00 UTC
[jira] [Comment Edited] (CB-10143) Local file:// url
XmlHttpRequests are not allowed in WKWebViewEngine
[ https://issues.apache.org/jira/browse/CB-10143?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16052004#comment-16052004 ]
lars Johnson edited comment on CB-10143 at 6/16/17 2:58 PM:
------------------------------------------------------------
I recently made a simple test using [cordova-plugin-wkwebviewxhrfix|https://github.com/TheMattRay/cordova-plugin-wkwebviewxhrfix.git] and it seems to work. In addition could some in the community help validate?
+*My tests*+
My ajax requests worked after "cordova plugin add" and stopped working when "cordova plugin remove". (cordova-plugin-wkwebviewxhrfix)
+*Test calls that I made were from:*+
$.ajax("js/test.json"
and
$.ajax("http://loacalhost: ..
and
$ajax("...Library/NoCloud/test.json"
*+Using:+*
iOS simulator
cordova -v 7.0.1
jQuery.min.3.1.1
+*See below index.html and config file.*+
{code:xml}
//index.html
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *" />
//config.xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="my.project.id" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>wkwvtest</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<feature name="CDVWKWebViewEngine">
<param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<plugin name="cordova-plugin-file" spec="^4.3.3" />
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
<plugin name="cordova-plugin-console" spec="~1.0.7" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<plugin name="cordova-plugin-wkwebview-engine" spec="^1.1.3" />
<plugin name="cordova-plugin-wkwebviewxhrfix" spec="https://github.com/TheMattRay/cordova-plugin-wkwebviewxhrfix" />
</widget>
{code}
was (Author: lars.johnson@voith.com):
I recently made a simple test using [cordova-plugin-wkwebviewxhrfix|https://github.com/TheMattRay/cordova-plugin-wkwebviewxhrfix.git] and it seems to work. In addition could some in the community help validate?
+*My tests*+
My ajax requests worked after "cordova plugin add" and stopped working when "cordova plugin remove". (cordova-plugin-wkwebviewxhrfix)
+*Test calls that I made were from:*+
$.ajax("js/test.json"
and
$.ajax("http://loacalhost: ..
and
$ajax("...Library/NoCloud/test.json"
*+Using:+*
iOS simulator
cordova -v 7.0.1
jQuery.min.3.1.1
+*See below index.html and config file.*+
{code:xml}
//index.html
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *" />
//config.xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="my.project.id" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>wkwvtest</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<feature name="CDVWKWebViewEngine">
<param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
<plugin name="cordova-plugin-console" spec="~1.0.7" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<plugin name="cordova-plugin-wkwebview-engine" spec="^1.1.3" />
<plugin name="cordova-plugin-wkwebviewxhrfix" spec="https://github.com/TheMattRay/cordova-plugin-wkwebviewxhrfix" />
</widget>
{code}
> Local file:// url XmlHttpRequests are not allowed in WKWebViewEngine
> --------------------------------------------------------------------
>
> Key: CB-10143
> URL: https://issues.apache.org/jira/browse/CB-10143
> Project: Apache Cordova
> Issue Type: Bug
> Components: cordova-plugin-wkwebview-engine
> Reporter: Shazron Abdullah
> Labels: wkwebview-known-issues
>
> mobile-spec failure in XMLHttpRequest.spec.4 is a known WKWebView issue, where CORS is now respected and cannot load files from file:// urls, only http*:// urls are allowed.
> With CSP off to rule things out:
> XHR to yourself of course works, but doesn't really make sense for
> real-world use. XHR to a sibling file, parent file, or any child file
> results in the error ""Cross origin requests are only supported for
> HTTP”.
> To illustrate:
> {code}
> |
> parent.xml
> |
> www
> |---- index.html (file currently loaded)
> |---- sibling.xml
> |---- child-folder
> | |---- child.xml
> {code}
> index.html is the currently loaded file in the WebView. From it, you
> can't load parent.xml, sibling.xml nor child.xml using XHR according
> to my tests.
> The workaround is implementing CB-10109
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org