8000 < 8000 meta name="hostname" content="github.com">
Skip to content

Enable userscripts (*.user.js) to access newer JavaScript engine syntax #1026

@Martii

Description

@Martii

Original Ticket: DevjaVu ticket 32
Original Title: Javascript 1.7?
Original Type: Defect, Major priority
Original Report: Approximately 2 years ago.
Original Text:

How do you get JavaScript? 1.7+ enhancements enabled in GM? Dev List Discussion

New Type: Enhancement, Normal priority

Allow user scripts to access newer JavaScript engine syntax in 3.5.X+, such as block scope let for better, faster and more secure OOP.

When evalInSandbox is passed this parameter in an older Firefox, it will be ignored and default back to baseline JavaScript engine support.

Single line modification at #L330 from Components.utils.evalInSandbox(code, sandbox); to Components.utils.evalInSandbox(code, sandbox, "1.8"); will allow this.

Sample:

for (let i = 1; i <= 3; ++i) {
  GM_log('looping ' + i + ' times');
}

GM_log(i);  // This will produce i is not defined since i is block scoped

Reference:
MDC evalInSandbox

MDC JavaScript Engine Version Syntax

It would be nice to see this one line fix in 0.8.2, but it's understandable that it may not make it until next time.

See also:
Martii commit

johan commit

johan commit

johan commit

arantius commit

greasemonkey commit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0