Client-Error: Browser-Widget can not access unkown domain from [message #1823248] |
Mon, 23 March 2020 15:51 |
Marco Descher Messages: 198 Registered: October 2010 Location: Austria |
Senior Member |
|
|
I have a RCP application that I want to make runnable in RAP. The sample I am working on embedds https://fullcalender.io in a Browser widget, with some BrowserFunction contributions etc.
Using this in an e4 RAP application leaves the internal IDE browser with "The application terminated unexpectedly" and Details showing
Error: Error: Operation "call" on target "w13" of type "rwt.widgets.Browser" failed:
SecurityRestriction:
Browser-Widget can not access unkown domain from "127.0.0.1:61163".
Properties:
script = $('#calendar').fullCalendar('option', 'maxTime', '23:59:00');$('#calendar').fullCalendar('option', 'minTime', '00:00:00');
Script: {"head":{},"operations":[["call","w13","evaluate",{"script":"$('#calendar').fullCalendar('option', 'maxTime', '23:59:00');$('#calendar').fullCalendar('option', 'minTime', '00:00:00');"}]]}
line: 62748
column: 20
sourceURL: http://127.0.0.1:61163/rwt-resources/3120/rap-client.js
Stack: _processError@http://127.0.0.1:61163/rwt-resources/3120/rap-client.js:62748:20
processOperationArray@http://127.0.0.1:61163/rwt-resources/3120/rap-client.js:62587:25
processMessage@http://127.0.0.1:61163/rwt-resources/3120/rap-client.js:62539:33
_handleSuccess@http://127.0.0.1:61163/rwt-resources/3120/rap-client.js:63227:33
_success@http://127.0.0.1:61163/rwt-resources/3120/rap-client.js:31585:46
_onReadyStateChange@http://127.0.0.1:61163/rwt-resources/3120/rap-client.js:31622:24
http://127.0.0.1:61163/rwt-resources/3120/rap-client.js:624:22
Debug: on
Request: {"head":{"requestCounter":3},"operations":[["notify","w13","Progress",{}],["set","w1",{"cursorLocation":[337,417]}]]}
The external Chrome browser does not show anything, except in the developers console you see a stalled request that never returns.
I found little on the interwebs to this like https://bugs.eclipse.org/bugs/show_bug.cgi?id=508289 or https://www.eclipse.org/forums/index.php/t/241398/
I don't really understand the problem, and where to start to get it working!
Grateful for any hints or pokes on this!
|
|
|
Re: Client-Error: Browser-Widget can not access unkown domain from [message #1823255 is a reply to message #1823248] |
Mon, 23 March 2020 16:49 |
|
What you're running into is a browser limitation put in place for security purposes. See the mozilla documentation which should be similar for all browsers, specifically the section on Cross-origin Script API Access: https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy - And the microsoft version: https://docs.microsoft.com/en-us/skype-sdk/ucwa/cross_domainiframe
In short, you can't call javascript on an iframe that belongs to another domain. To my knowledge there's not even a way to disable it for local testing. I was running into a similar issue with local services on two different ports (e.g. RAP running on localhost:10080 and another service in my iframe running on localhost:8080). The only workaround I know of is to use a reverse proxy so that both services are hosted on the same domain. Even a subdomain won't work properly (there is supposed to be a workaround where the script in the iframe explicitly allows calls from another domain, but I couldn't get it to work in my limited testing).
Hope you get it working.
|
|
|
Re: Client-Error: Browser-Widget can not access unkown domain from [message #1823257 is a reply to message #1823255] |
Mon, 23 March 2020 16:59 |
|
I did forget to mention the postMessage API, which is referenced on both the mozilla and microsoft sites I linked. The idea is that you post a message to the iframe, and it subscribes to the event and chooses to process it. It would probably be possible to modify the RAP BrowserFunction to use postMessage. I'm not sure of any way to do it using javascript without modifying RAP. Currently BrowserFunction injects a javascript function into the iframe, and that is what is currently not possible. This could be changed so that BrowserFunction instead registers an event listener for the iframe calling postMessage on the parent window.
Another alternative is to modify the code in the iframe to call a service handler on the application. You would probably need to pass the url of the service handler to the iframe as a URL parameter. https://download.eclipse.org/rt/rap/doc/3.3/guide/reference/api/org/eclipse/rap/rwt/service/ServiceHandler.html
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05730 seconds