Open Bug 503739 Opened 15 years ago Updated 2 years ago

protocol javascript: does not enable javascript 1.7+

Categories

(Core :: DOM: Core & HTML, defect, P5)

defect

Tracking

()

People

(Reporter: georg, Unassigned)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.1pre) Gecko/20090703 SeaMonkey/2.0b1pre
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2a1pre) Gecko/20090704

protocol javascript: does not enable latest language features like (let, destructuring assignments, etc.)

As a side effect of this it is also not supported in the JavaScript Error Console, because there evaluation is delegated by creating a javascript URL from the statement entered in the text field.

Reproducible: Always

Steps to Reproduce:
1. type into the location bar "javascript:let a=1;alert(a);"
2. hit <ENTER> or click on button GO.
3. look into the JavaScript Error Console and find your error message
Actual Results:  
Error: missing ; before statement
Source File: javascript:%20let%20a=1;alert(a);
Line: 1, Column: 1
Source Code:
 let a=1;alert(a);

Expected Results:  
I want to get the alert displaying the value of a.
Confirming on Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5 (.NET CLR 3.5.30729) and on trunk, changing title to more accurately reflect problem.
Status: UNCONFIRMED → NEW
Component: General → Networking
Ever confirmed: true
QA Contact: general → networking
Summary: protocol javascript: does not enable latest language features like (let, destructuring assignments, etc.) → protocol javascript: does not enable javascript 1.7+
Version: unspecified → Trunk
Not networking
Component: Networking → DOM
QA Contact: networking → general
Which file in mercurial does implement this Protocol handler? When I know where to fix it probably is a trivial fix.
I've pulled from hg, did the suggested change, built XulRunner, but don't see any change in behavior. So it seems to be more than just this, or it is running in the sandbox, which is not affected by this modification.
Well, it's possible that JSVERSION_DEFAULT is not the right value.  Does it work if you explicitly set it to JSVERSION_1_7?  If not, then there is more to it than that or it's in the sandbox.  I didn't follow the code path for the sandbox, but changing the version there if necessary shouldn't be too difficult, it's just a question of what else it would affect besides javascript::/
Setting explicit to JSVERSION_1_8 works as desired in location url of a window.open() and in JavaScript Error Console. So setting it to JSVERSION_LATEST, which is defined in http://mxr.mozilla.org/mozilla-central/source/js/src/jspubtd.h#77 does what I want.

Because javascript: URIs are usually not too complex, I do not expect any unwanted side effects by this small modification.
Who should be informed to review this patch?
The people in charge of this section are: http://www.mozilla.org/owners.html#document-object-model

Anyone under the peers list there would work.   Not sure what Olli's shorthand is off hand, but if you put ":sicking" in the review box it will go to Jonas, and ":bz" will go to Boris.  If whomever you ask is busy or can't do it they'll generally redirect it to somebody that can.
Attachment #389296 - Flags: review?(jonas)
Won't this break sites and bookmarklets that rely on using names that are keywords in the newer JavaScript versions?
Yes, it would break some bookmarklets, specifically those would be "let" and "yield" IIRC.

It work also break sites with javascript links using those two words as well.

That's the obvious downside to this.
Test your self:

let o={let:4};alert(o.let);

There are currently no new reserved words and even this statement using let as property name works.

var let={let:4};alert(let.let)

This no longer works. But who does really name a variable let or yield and use it in a javascript URI?

There have been other compatibility issues in former time i.e. related to the different behavior of the Array constructor in JS 1.2.

The advantage of being able to use block scope variables in bookmarklets that do not create unwanted global variables is much more worth.
(In reply to comment #12)
> var let={let:4};alert(let.let)
> 
> This no longer works. But who does really name a variable let or yield and use
> it in a javascript URI?

Don't know, but given the vast amount of JavaScript out there on the web, I find it very unlikely that this wouldn't break someone.

We don't make <script> default to the newest JavaScript version. We shouldn't for javascript: URIs either IMO. Bug 352228 is a better approach to this, though that still wouldn't help bookmarklets or direct entry.
I agree, I think it's almost a given that this breaks someone.  I'm not sure how big a problem that is.  If complete backwards compatibility is wanted, then we need to allow JavaScript to set the version programmatically with something like the "version(170);" statement in the JS shell.
A preference might be also acceptable for people, who want to use it in bookmarklets or on the JavaScript Error Console.
Comment on attachment 389296 [details] [diff] [review]
patch to enable latest JavaScript Version in javascript: URIs

Won't this break any page with a javascript uri that contains a variable named 'yield'?

I think the proper fix here is to lobby the ECMA group to add a 'using' statement that allows opting in to a given release.

Also, please don't add comments indicating which bug changed a given line. It makes the code harder to read if we did that everywhere. There's always hg-annotate to track down changes.
Attachment #389296 - Flags: review?(jonas) → review-
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046

Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: