Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Browser.execute() issue
Browser.execute() issue [message #105543] Thu, 18 September 2008 09:42 Go to next message
Martin Schmied is currently offline Martin SchmiedFriend
Messages: 5
Registered: July 2009
Junior Member
Hi,

The Browser.execute() is not working for me. It always returns false and
no script is executed. I'm running Ubuntu with Firefox. I've noticed this
while porting our RCP application. But even the simplest scenario (
browser.execute("alert('Hello world')" call in RAP Workbench demo )
produces the same result.

Regards, Martin Schmied
Re: Browser.execute() issue [message #105557 is a reply to message #105543] Thu, 18 September 2008 12:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rherrmann.innoopract.com

Martin,

here are a few ideas what you could investigate in order to narrow
the problem:
* try to run a different browser and see if it also fails
* are there any add-ons that might prevent the Javscript execution
* what version of RAP are you using?
* if working against RAP CVS HEAD, you could write
"this.debug( e );" in line 29 of Browser.js to see if
a Javascript error occurs


HTH
Rüdiger

Martin Schmied wrote:
> Hi,
>
> The Browser.execute() is not working for me. It always returns false and
> no script is executed. I'm running Ubuntu with Firefox. I've noticed
> this while porting our RCP application. But even the simplest scenario (
> browser.execute("alert('Hello world')" call in RAP Workbench demo )
> produces the same result.
>
> Regards, Martin Schmied
>
Re: Browser.execute() issue [message #105597 is a reply to message #105543] Thu, 18 September 2008 15:44 Go to previous messageGo to next message
Boris Stepanov is currently offline Boris StepanovFriend
Messages: 68
Registered: July 2009
Member
I also feel some problem with Browser widget. I was looking for a way to
refresh browser. I've tried to do it via execute("document.location =
document.location") and via setUrl method. Both methods are not stable,
so now I just dispose Browser and create new one and set old url.

> Hi,
>
> The Browser.execute() is not working for me. It always returns false and
> no script is executed. I'm running Ubuntu with Firefox. I've noticed
> this while porting our RCP application. But even the simplest scenario (
> browser.execute("alert('Hello world')" call in RAP Workbench demo )
> produces the same result.
>
> Regards, Martin Schmied
>
Re: Browser.execute() issue [message #105624 is a reply to message #105557] Thu, 18 September 2008 20:21 Go to previous messageGo to next message
Martin Schmied is currently offline Martin SchmiedFriend
Messages: 5
Registered: July 2009
Junior Member
Hi Rüdiger,

thanks for responding. My original setup uses RAP 1.1 I've tried Firefox
and Opera with the same negative result. Then (already at my laptop
running Windows Vista) I switched to CVS bundles as you proposed, added
some JS debugging code and here's the result:

On Firefox and Opera the 'this.getContentWindow()' statement returns null
causing the subsequent evaluation to throw a NPE

On IE7 the context window is indeed returned, but "Permission denied"
exception is thrown from the evaluation.

One way or another, the Browser.execute() always fails.

Regards, Martin Schmied
Re: Browser.execute() issue [message #105640 is a reply to message #105624] Fri, 19 September 2008 06:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rherrmann.innoopract.com

Hi Martin,

thanks for your investigation. When using the Browser widget please
bear in mind that it is represented by an IFRAME element on the
client-side. Therefore its general use is limited by implementation
details that vary on different browsers and security restrictions.
Plus user-specific security settings may restrict its features further.

It seems to be a bug that 'this.getContentWindow()' returns null.
Feel free to open a bugzilla if you have a code snippet to reproduce
the behavior.

The 'permission denied' exception, to me looks like a security
restriction that cannot be overcome, except maybe by altering the
client-side security settings.

Cheers,
Rüdiger

Martin Schmied wrote:
> Hi Rüdiger,
>
> thanks for responding. My original setup uses RAP 1.1 I've tried Firefox
> and Opera with the same negative result. Then (already at my laptop
> running Windows Vista) I switched to CVS bundles as you proposed, added
> some JS debugging code and here's the result:
>
> On Firefox and Opera the 'this.getContentWindow()' statement returns
> null causing the subsequent evaluation to throw a NPE
>
> On IE7 the context window is indeed returned, but "Permission denied"
> exception is thrown from the evaluation.
>
> One way or another, the Browser.execute() always fails.
>
> Regards, Martin Schmied
>
Re: Browser.execute() issue [message #106010 is a reply to message #105640] Tue, 23 September 2008 15:18 Go to previous messageGo to next message
Martin Schmied is currently offline Martin SchmiedFriend
Messages: 5
Registered: July 2009
Junior Member
Hi Rudiger,

I've found that to reproduce the issue in RAP Workspace Demo you have to
call execute() right after (or close enough) an URL change - when the page
is still loading. The following code should do that:

browser.setUrl("http://times.com");
browser.execute("alert('hello world');")

This might be a browser issue you can do nothing about. However, in our
original application where I encountered the error for the first time,
there's no URL change directly preceding the execute() call. The page
loaded in browser contains UI of a streaming map application
(http://www.openstreetmap.org/). Every time the execute() call fails, it's
because this.getContentWindow() in Browser.js returns null.

Regards, Martin Schmied
Re: Browser.execute() issue [message #106094 is a reply to message #106010] Wed, 24 September 2008 07:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rherrmann.innoopract.com

Hi Martin,

this seems to be a problem related to qooxdoo and its queuing
mechanisms. It certainly has nothing to do with the way setUrl() and
execute() are called.

When the client-side Browser object is created, its respective DOM
nodes (namely the IFRAME) aren't created immediately. All DOM
operations are queued and executed 'sometime' later. This is the
reason why getContentWindow() (returns the actual DOM node)
sometimes returns null.

It seems possible to work around this in RAP. Please file a Bugzilla
to track progress on this.


Cheers,
Rüdiger
-----------------------------
Rüdiger Herrmann
Innoopract
http://innoopract.com
delivering eclipse technology

Martin Schmied wrote:
> Hi Rudiger,
>
> I've found that to reproduce the issue in RAP Workspace Demo you have to
> call execute() right after (or close enough) an URL change - when the
> page is still loading. The following code should do that:
>
> browser.setUrl("http://times.com");
> browser.execute("alert('hello world');")
>
> This might be a browser issue you can do nothing about. However, in our
> original application where I encountered the error for the first time,
> there's no URL change directly preceding the execute() call. The page
> loaded in browser contains UI of a streaming map application
> (http://www.openstreetmap.org/). Every time the execute() call fails,
> it's because this.getContentWindow() in Browser.js returns null.
>
> Regards, Martin Schmied
>
Re: Browser.execute() issue [message #106121 is a reply to message #106094] Wed, 24 September 2008 13:43 Go to previous messageGo to next message
Martin Schmied is currently offline Martin SchmiedFriend
Messages: 5
Registered: July 2009
Junior Member
Hi Rüdiger,

Looking on RAP 1.1.1 I've found a resolved bug #234683
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=234683). My problems are
most probably caused by security restrictions (this is covered by the bug)
- because the execute() method works fine with pages created via setText()
and fails when a page from an external URL is loaded in the browser.
Mozilla/Opera do not throw any Exceprtion (IE does) but iframe DOM is not
accessible in them (using CVS HEAD revision of RAP). If there's a
workaround to execute JS in Browser object with loaded external page, then
it might be posted as comment to #234683

Cheers, Martin
Re: Browser.execute() issue [message #106148 is a reply to message #106121] Wed, 24 September 2008 15:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rherrmann.innoopract.com

This is a multi-part message in MIME format.
--------------060708020907020708050804
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi Martin,

if it turns out be actually be a security restriction, I don't think
that we can do much about it.
Still, I wonder, why the IFRAME returned by getContentWindow() is
null. Even if security settings apply, the page is displayed and
thus there must be an IFRAME element. The IFRAME may or may not
execute Javascript, but it should be there at least.

Attached is a Browser.js with the workaround mentioned in the
earlier post.
Note 1: this workaround is *not* to circumvent security issues.
Note 2: it is untested as I cannot reproduce the problem.
You may replace the existing org/eclipse/swt/browser/Browser.js in
the js source folder with this file and see if it works.

HTH,
R
Re: Browser.execute() issue [message #106254 is a reply to message #106148] Thu, 25 September 2008 10:58 Go to previous message
Martin Schmied is currently offline Martin SchmiedFriend
Messages: 5
Registered: July 2009
Junior Member
Hi Rüdiger,

first of all - thank you very much for your help. Unfortunately the script
you've attached to your last post worked exactly the same as the original
one. I think the problem is really a security issue and not a problem of
delayed DOM creation - when I run RAP controls demo, then with custom HTML
page (via setText()) inside the browser everything works fine -> load page
from URL -> run the JS -> script execution fails with the mentioned NPE.
The inaccessible iframe DOM element is confusing, but still I do think
it's a security issue you can do nothing about. Thanks again for your
thoughts :)

Regards, Martin
Previous Topic:RAP 1.2 plan
Next Topic:Checkboxes, Buttons in Table
Goto Forum:
  


Current Time: Fri Apr 26 17:51:05 GMT 2024

Powered by FUDForum. Page generated in 0.04173 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top