From: Bill Mill on
Hello all,

I want to have a user able to eval code in a text box. However, if he
accidentally types "while(1) { i=0; }" and hits "run", I also want him
to be able to hit a stop button such that his browser does not go into
an infinite, soul-crushing, interface-locking loop. The stop button
would not need to be instantly responsive, but of course the more
responsive the better.

Short of writing a javascript-in-javascript interpreter, is there any
way to do so? Does Caja make this sort of thing possible? Will I need
to restrict myself to Gears+threads to do this?

Thanks for any help,
Bill Mill
bill.mill(a)gmail.com
From: Erwin Moller on
Bill Mill schreef:
> Hello all,
>
> I want to have a user able to eval code in a text box. However, if he
> accidentally types "while(1) { i=0; }" and hits "run", I also want him
> to be able to hit a stop button such that his browser does not go into
> an infinite, soul-crushing, interface-locking loop. The stop button
> would not need to be instantly responsive, but of course the more
> responsive the better.

Hi Bill,

My Firefox notices long running scripts and offers to abort them after a
while.
What browser are you using?

Regards,
Erwin Moller

>
> Short of writing a javascript-in-javascript interpreter, is there any
> way to do so? Does Caja make this sort of thing possible? Will I need
> to restrict myself to Gears+threads to do this?
>
> Thanks for any help,
> Bill Mill
> bill.mill(a)gmail.com
From: Captain Paralytic on
On 23 Apr, 07:29, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...(a)spamyourself.com> >
> Hi Bill,
>
> My Firefox notices long running scripts and offers to abort them after a
> while.
> What browser are you using?
Surely what browser the OP is using has no bearing on this. The
question is what browser will the arbitrary user be using?
From: Thomas 'PointedEars' Lahn on
Bill Mill wrote:
> I want to have a user able to eval code in a text box. However, if he
> accidentally types "while(1) { i=0; }" and hits "run", I also want him
> to be able to hit a stop button such that his browser does not go into
> an infinite, soul-crushing, interface-locking loop. The stop button
> would not need to be instantly responsive, but of course the more
> responsive the better.
>
> Short of writing a javascript-in-javascript interpreter, is there any
> way to do so?

No. ECMAScript implementations so far are single-threaded, and there is yet
an algorithm to be written for a universal solution of the Halting Problem.

http://en.wikipedia.org/wiki/Halting_problem

You will have to rely on the user's user agent to recognize a not-responding
script, and provide the user with such a dialog window, as Gecko-based UAs
(e.g. Mozilla Firefox) do.

> Does Caja make this sort of thing possible?

I don't think so:

http://code.google.com/p/google-caja/wiki/AttackVectors

Please be more verbose next time.

> Will I need to restrict myself to Gears+threads to do this?

Never heard of those.


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
From: Bill Mill on
On Apr 23, 1:07 pm, Thomas 'PointedEars' Lahn <PointedE...(a)web.de>
wrote:
> Bill Mill wrote:
> > I want to have a user able to eval code in a text box. However, if he
> > accidentally types "while(1) { i=0; }" and hits "run", I also want him
> > to be able to hit a stop button such that his browser does not go into
> > an infinite, soul-crushing, interface-locking loop. The stop button
> > would not need to be instantly responsive, but of course the more
> > responsive the better.
>
> > Short of writing a javascript-in-javascript interpreter, is there any
> > way to do so?
>
> No.  ECMAScript implementations so far are single-threaded, and there is yet
> an algorithm to be written for a universal solution of the Halting Problem..
>
> http://en.wikipedia.org/wiki/Halting_problem

Thanks, I know just what that is, and I'm not asking for a solution to
it. Allowing a user to stop an eval is not equivalent to determining
prior to the eval whether or not it will ever complete.

>
> You will have to rely on the user's user agent to recognize a not-responding
> script, and provide the user with such a dialog window, as Gecko-based UAs
> (e.g. Mozilla Firefox) do.

I can't rely on this, since I would like to allow the user to write
scripts that take a while to run. Thus, he's likely to disable this
dialog for the page.

>
> > Does Caja make this sort of thing possible?
>
> I don't think so:
>
> http://code.google.com/p/google-caja/wiki/AttackVectors

How is that relevant to what I asked? I've read the Caja website, as
well as the PDF describing the system, and I'm still not clear on
whether it can or not.

>
> Please be more verbose next time.

what more would you like to know?

>
> > Will I need to restrict myself to Gears+threads to do this?
>
> Never heard of those.

I meant that I might be able to use Google Gears' threads to achieve
what I'm looking for.

-Bill Mill