Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Specify Javascript version when using eval()

6 views
Skip to first unread message

Jan Odvarko

unread,
Aug 30, 2010, 3:01:49 AM8/30/10
to
Is it possible to somehow specify Javascript version when evaluating
script on the page?

The <script> tag allows this by using a 'type' attribute:

<script type="application/javascript;version=1.7">
let a='bar';
console.log(a);
</script>

But how to specify the version (e.g. 1.7) when evaluating on the
current page using eval() ?

Honza

Shawn Wilsher

unread,
Aug 30, 2010, 11:00:30 AM8/30/10
to dev-apps...@lists.mozilla.org
On 8/30/2010 12:01 AM, Jan Odvarko wrote:
> But how to specify the version (e.g. 1.7) when evaluating on the
> current page using eval() ?
You can do this with Components.utils.evalInSandbox:
https://developer.mozilla.org/en/Components.utils.evalInSandbox

Cheers,

Shawn

johnjbarton

unread,
Aug 30, 2010, 11:36:47 AM8/30/10
to

The eval() Jan is referring to is jsdIStackFrame.eval(). So we need to
recreate the scope chain. I guess we can do this by nesting all of the
objects in the chain using 'with'?

jjb

Boris Zbarsky

unread,
Aug 30, 2010, 12:04:11 PM8/30/10
to
On 8/30/10 11:36 AM, johnjbarton wrote:
> The eval() Jan is referring to is jsdIStackFrame.eval().

Oh, the one we fully control and can modify however we want to? How
about we just add a "version" argument to it?

-Boris

Jan Honza Odvarko

unread,
Aug 30, 2010, 12:57:43 PM8/30/10
to
> Oh, the one we fully control and can modify however we want to?  How
> about we just add a "version" argument to it?
yes sounds great
https://bugzilla.mozilla.org/show_bug.cgi?id=591961

I guess the Web Console could happily utilize this too.
Honza

0 new messages