You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2020/04/20 06:46:53 UTC

[GitHub] [cordova-ios] jurihahn opened a new issue #827: WkWebView break iframe working from file://

jurihahn opened a new issue #827:
URL: https://github.com/apache/cordova-ios/issues/827


   # Bug Report
   
   ## Problem
   if i use WkWebView loading HTML file to iframe I get error:
   WebPageProxy::Ignoring request to load this main resource because it is outside the sandbox
   its happened only if I try to load HTML file not from app self. I download a HTML file and start it from App-Data folder "cordova.file.dataDirectory".
   
   
   ### What is expected to happen?
   iframe should load HTML page from "file://" protocol. May be its need an Option to allow some URL's
   
   
   ### What does actually happen?
   Error: WebPageProxy::Ignoring request to load this main resource because it is outside the sandbox
   
   
   ## Information
   I try to switch from UIWebView to WkWebView and this is last Problem.
   I have found information about this Problem https://stackoverflow.com/questions/40123321/wkwebview-run-local-html-in-document-received-an-unexpected-url-from-the-web-p
   but how can I provide my URL to this function to allow loading?
   this is added to config
   <allow-navigation href="*" />
   <allow-navigation href="file://*" />
   <allow-intent href="file://*" />
   <allow-intent href="*" />
   
   
   ### Command or Code
   create HTML File in App-Data "cordova.file.dataDirectory" and load this file in iFrame NOT InAppBrowser
   
   
   
   ### Environment, Platform, Device
   iPhone iOS 13.4.1
   
   
   
   ### Version information
   <!-- 
   What are relevant versions you are using?
   For example:
   Cordova 9.0.0, 
   Cordova iOS 5.1.1, 
   cordova-plugin-file 6.0.2, 
   Xcode 11.4.1, 
   -->
   
   
   
   ## 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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-ios] GMK82 commented on issue #827: WkWebView breaks iframe working from "cordova.file.dataDirectory" file://

Posted by GitBox <gi...@apache.org>.
GMK82 commented on issue #827:
URL: https://github.com/apache/cordova-ios/issues/827#issuecomment-707047648


   > I'm not sure if you noticed [this page](https://cordova.apache.org/news/2018/08/01/future-cordova-ios-webview.html), sounds like iframes might not be supported with wkwebview.
   
   It works for WKWebView but not for iframe. Now it is possible to load content only by http pre-add url to the whitelist in config file: <allow-navigation href="https://domain" />


----------------------------------------------------------------
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-ios] GMK82 removed a comment on issue #827: WkWebView breaks iframe working from "cordova.file.dataDirectory" file://

Posted by GitBox <gi...@apache.org>.
GMK82 removed a comment on issue #827:
URL: https://github.com/apache/cordova-ios/issues/827#issuecomment-707047648


   > I'm not sure if you noticed [this page](https://cordova.apache.org/news/2018/08/01/future-cordova-ios-webview.html), sounds like iframes might not be supported with wkwebview.
   
   It works for WKWebView but not for iframe. Now it is possible to load content only by http pre-add url to the whitelist in config file: <allow-navigation href="https://domain" />


----------------------------------------------------------------
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-ios] blukis edited a comment on issue #827: WkWebView breaks iframe working from "cordova.file.dataDirectory" file://

Posted by GitBox <gi...@apache.org>.
blukis edited a comment on issue #827:
URL: https://github.com/apache/cordova-ios/issues/827#issuecomment-738191106


   I ran into a similar issue with migration to WkWebView.  (Additionally, I needed iframes to run as same origin, despite WkWebView treating anything in file:// as unique-origin.)  This is my workaround:
   ```
   function frameEl_injectHtml(frameEl, injectHtml) {
   	// frameEl must exist in DOM before its contentWindow is accessible.
   	if (!frameEl.contentWindow) { alert("frameInjectHtml() but frameEl not (yet or anymore) in DOM."); return; }
   
   	frameEl.contentWindow.document.open('text/htmlreplace');
   	frameEl.contentWindow.document.write(injectHtml);
   	frameEl.contentWindow.document.close();
   }
   
   // Create <frame>, insert into DOM, and inject content.
   var frameHtml = "<html><head></head>" +
   	"<body style='background-color:#eee; color:#000;'>" +
   		"iframe body" +
   		"<script>window.parent.alert('iframe even same-origin as parent.');</script>" +
   	"</body></html>";
   var frameEl = document.createElement('iframe');
   frameEl.src = "about:blank";
   document.body.appendChild(frameEl);
   frameEl_injectHtml(frameEl, frameHtml);
   ```


----------------------------------------------------------------
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-ios] GMK82 edited a comment on issue #827: WkWebView breaks iframe working from "cordova.file.dataDirectory" file://

Posted by GitBox <gi...@apache.org>.
GMK82 edited a comment on issue #827:
URL: https://github.com/apache/cordova-ios/issues/827#issuecomment-707048201


   > You may try the setting ...
   > `[webView.configuration.preferences setValue:@YES forKey:@"allowFileAccessFromFileURLs"];`
   > I do not know if this fixes issues related to iframes, too, but is definitely necessary to display file:// URLs at all in WKWebView
   
   It works for WKWebView but not for iframe. Now it is possible to load content only by http pre-add url to the whitelist in config file: <allow-navigation href="https://domain" />
   


----------------------------------------------------------------
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-ios] GMK82 commented on issue #827: WkWebView breaks iframe working from "cordova.file.dataDirectory" file://

Posted by GitBox <gi...@apache.org>.
GMK82 commented on issue #827:
URL: https://github.com/apache/cordova-ios/issues/827#issuecomment-707039408


   > I do not know if this fixes issues related to iframes, too, but is definitely necessary to display file:// URLs at all in WKWebView
   
   


----------------------------------------------------------------
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-ios] GMK82 removed a comment on issue #827: WkWebView breaks iframe working from "cordova.file.dataDirectory" file://

Posted by GitBox <gi...@apache.org>.
GMK82 removed a comment on issue #827:
URL: https://github.com/apache/cordova-ios/issues/827#issuecomment-707043261






----------------------------------------------------------------
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-ios] katzlbt edited a comment on issue #827: WkWebView breaks iframe working from "cordova.file.dataDirectory" file://

Posted by GitBox <gi...@apache.org>.
katzlbt edited a comment on issue #827:
URL: https://github.com/apache/cordova-ios/issues/827#issuecomment-629169566


   You may try the setting ...
   ` [webView.configuration.preferences setValue:@YES forKey:@"allowFileAccessFromFileURLs"];
   `
   I do not know if this fixes issues related to iframes, too, but is definitely necessary to display file:// URLs at all in WKWebView 


----------------------------------------------------------------
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-ios] blukis commented on issue #827: WkWebView breaks iframe working from "cordova.file.dataDirectory" file://

Posted by GitBox <gi...@apache.org>.
blukis commented on issue #827:
URL: https://github.com/apache/cordova-ios/issues/827#issuecomment-738191106


   I ran into a similar issue with migration to WkWebView.  (Additionally, I needed iframes to run as same origin, despite WkWebView treating anything in file:// as unique-origin.)  This is my workaround:
   ```
   frameEl_injectHtml = function(frameEl, injectHtml) {
   	// frameEl must exist in DOM before its contentWindow is accessible.
   	if (!frameEl.contentWindow) { alert("frameInjectHtml() but frameEl not (yet or anymore) in DOM."); return; }
   
   	frameEl.contentWindow.document.open('text/htmlreplace');
   	frameEl.contentWindow.document.write(injectHtml);
   	frameEl.contentWindow.document.close();
   }
   
   // Create <frame>, insert into DOM, and inject content.
   var frameHtml = "<html><head></head>" +
   	"<body style='background-color:#eee; color:#000;'>" +
   		"iframe body" +
   		"<script>window.parent.alert('iframe even same-origin as parent.');</script>" +
   	"</body></html>";
   var frameEl = document.createElement('iframe');
   frameEl.src = "about:blank";
   document.body.appendChild(frameEl);
   frameEl_injectHtml(frameEl, frameHtml);
   ```


----------------------------------------------------------------
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-ios] GMK82 commented on issue #827: WkWebView breaks iframe working from "cordova.file.dataDirectory" file://

Posted by GitBox <gi...@apache.org>.
GMK82 commented on issue #827:
URL: https://github.com/apache/cordova-ios/issues/827#issuecomment-707043261


   It works for WKWebView but not for iframe. 


----------------------------------------------------------------
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-ios] adamdport commented on issue #827: WkWebView breaks iframe working from "cordova.file.dataDirectory" file://

Posted by GitBox <gi...@apache.org>.
adamdport commented on issue #827:
URL: https://github.com/apache/cordova-ios/issues/827#issuecomment-650622608


   I'm not sure if you noticed [this page](https://cordova.apache.org/news/2018/08/01/future-cordova-ios-webview.html), sounds like iframes might not be supported with wkwebview.


----------------------------------------------------------------
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-ios] katzlbt edited a comment on issue #827: WkWebView breaks iframe working from "cordova.file.dataDirectory" file://

Posted by GitBox <gi...@apache.org>.
katzlbt edited a comment on issue #827:
URL: https://github.com/apache/cordova-ios/issues/827#issuecomment-629169566


   You may try the setting ...
   ` [webView.configuration.preferences setValue:@YES forKey:@"allowFileAccessFromFileURLs"];
   `I do not know if this fixes issues related to iframes, too, but is definitely necessary to display file:// URLs at all in WKWebView 


----------------------------------------------------------------
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-ios] GMK82 edited a comment on issue #827: WkWebView breaks iframe working from "cordova.file.dataDirectory" file://

Posted by GitBox <gi...@apache.org>.
GMK82 edited a comment on issue #827:
URL: https://github.com/apache/cordova-ios/issues/827#issuecomment-707048201


   > You may try the setting ...
   > `[webView.configuration.preferences setValue:@YES forKey:@"allowFileAccessFromFileURLs"];`
   > I do not know if this fixes issues related to iframes, too, but is definitely necessary to display file:// URLs at all in WKWebView
   
   It works for WKWebView but not for iframe. Now it is possible to load content only by http pre-add url to the whitelist in config file: `<allow-navigation href="https://domain" />`
   


----------------------------------------------------------------
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-ios] blukis edited a comment on issue #827: WkWebView breaks iframe working from "cordova.file.dataDirectory" file://

Posted by GitBox <gi...@apache.org>.
blukis edited a comment on issue #827:
URL: https://github.com/apache/cordova-ios/issues/827#issuecomment-738191106


   I ran into a similar issue with migration to WkWebView.  (Additionally, I needed iframes to run as same origin, despite WkWebView treating anything loaded via `src="file://..."` as unique-origin.)  This is my workaround.  It inserts html content directly into the iframe rather than using `src="..."` attribute, so no references to external files.
   
   ```
   function frameEl_injectHtml(frameEl, injectHtml) {
   	// frameEl must exist in DOM before its contentWindow is accessible.
   	if (!frameEl.contentWindow) { alert("frameInjectHtml() but frameEl not (yet or anymore) in DOM."); return; }
   
   	frameEl.contentWindow.document.open('text/htmlreplace');
   	frameEl.contentWindow.document.write(injectHtml);
   	frameEl.contentWindow.document.close();
   }
   
   // Create <frame>, insert into DOM, and inject content.
   var frameHtml = "<html><head></head>" +
   	"<body style='background-color:#eee; color:#000;'>" +
   		"iframe body" +
   		"<script>window.parent.alert('iframe even same-origin as parent.');</script>" +
   	"</body></html>";
   var frameEl = document.createElement('iframe');
   frameEl.src = "about:blank";
   document.body.appendChild(frameEl);
   frameEl_injectHtml(frameEl, frameHtml);
   ```


----------------------------------------------------------------
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-ios] katzlbt commented on issue #827: WkWebView breaks iframe working from "cordova.file.dataDirectory" file://

Posted by GitBox <gi...@apache.org>.
katzlbt commented on issue #827:
URL: https://github.com/apache/cordova-ios/issues/827#issuecomment-629169566


   You may try the setting ...
    [webView.configuration.preferences setValue:@YES forKey:@"allowFileAccessFromFileURLs"];
   I do not know if this fixes issues related to iframes, too, but is definitely necessary to display file:// URLs at all in WKWebView 


----------------------------------------------------------------
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-ios] GMK82 commented on issue #827: WkWebView breaks iframe working from "cordova.file.dataDirectory" file://

Posted by GitBox <gi...@apache.org>.
GMK82 commented on issue #827:
URL: https://github.com/apache/cordova-ios/issues/827#issuecomment-707048201


   > You may try the setting ...
   > `[webView.configuration.preferences setValue:@YES forKey:@"allowFileAccessFromFileURLs"];`
   > I do not know if this fixes issues related to iframes, too, but is definitely necessary to display file:// URLs at all in WKWebView
   
   It works for WKWebView but not for iframe. Now it is possible to load content only by http pre-add url to the whitelist in config file: <allow-navigation href="https://domain" />


----------------------------------------------------------------
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-ios] blukis edited a comment on issue #827: WkWebView breaks iframe working from "cordova.file.dataDirectory" file://

Posted by GitBox <gi...@apache.org>.
blukis edited a comment on issue #827:
URL: https://github.com/apache/cordova-ios/issues/827#issuecomment-738191106


   I ran into a similar issue with migration to WkWebView.  (Additionally, I needed iframes to run as same origin, despite WkWebView treating anything loaded via `src="file://..."` as unique-origin.)  This is my workaround:
   ```
   function frameEl_injectHtml(frameEl, injectHtml) {
   	// frameEl must exist in DOM before its contentWindow is accessible.
   	if (!frameEl.contentWindow) { alert("frameInjectHtml() but frameEl not (yet or anymore) in DOM."); return; }
   
   	frameEl.contentWindow.document.open('text/htmlreplace');
   	frameEl.contentWindow.document.write(injectHtml);
   	frameEl.contentWindow.document.close();
   }
   
   // Create <frame>, insert into DOM, and inject content.
   var frameHtml = "<html><head></head>" +
   	"<body style='background-color:#eee; color:#000;'>" +
   		"iframe body" +
   		"<script>window.parent.alert('iframe even same-origin as parent.');</script>" +
   	"</body></html>";
   var frameEl = document.createElement('iframe');
   frameEl.src = "about:blank";
   document.body.appendChild(frameEl);
   frameEl_injectHtml(frameEl, frameHtml);
   ```


----------------------------------------------------------------
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-ios] GMK82 edited a comment on issue #827: WkWebView breaks iframe working from "cordova.file.dataDirectory" file://

Posted by GitBox <gi...@apache.org>.
GMK82 edited a comment on issue #827:
URL: https://github.com/apache/cordova-ios/issues/827#issuecomment-707048201


   > You may try the setting ...
   > `[webView.configuration.preferences setValue:@YES forKey:@"allowFileAccessFromFileURLs"];`
   > I do not know if this fixes issues related to iframes, too, but is definitely necessary to display file:// URLs at all in WKWebView
   
   It works for WKWebView but not for iframe. Now it is possible to load content only by http pre-add url to the whitelist in config file: <!--<allow-navigation href="https://domain" />-->
   


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