import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo

This commit is contained in:
Roy Tam 2018-01-19 03:59:58 +08:00
commit dcd9973243
150858 changed files with 23884658 additions and 0 deletions

View file

@ -0,0 +1,75 @@
"use strict";
var { classes: Cc, interfaces: Ci, utils: Cu } = Components;
const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
function isObject(value) {
return typeof value === "object" && value !== null;
}
function intersect(a, b) {
const seen = new Set(a);
return b.filter(value => seen.has(value));
}
function checkEquivalentASTs(expected, actual, prop = []) {
do_print("Checking: " + prop.join(" "));
if (!isObject(expected)) {
return void do_check_eq(expected, actual);
}
do_check_true(isObject(actual));
if (Array.isArray(expected)) {
do_check_true(Array.isArray(actual));
do_check_eq(expected.length, actual.length);
for (let i = 0; i < expected.length; i++) {
checkEquivalentASTs(expected[i], actual[i], prop.concat(i));
}
} else {
// We must intersect the keys since acorn and Reflect have different
// extraneous properties on their AST nodes.
const keys = intersect(Object.keys(expected), Object.keys(actual));
for (let key of keys) {
checkEquivalentASTs(expected[key], actual[key], prop.concat(key));
}
}
}
// Register a console listener, so console messages don't just disappear
// into the ether.
var errorCount = 0;
var listener = {
observe: function (aMessage) {
errorCount++;
try {
// If we've been given an nsIScriptError, then we can print out
// something nicely formatted, for tools like Emacs to pick up.
var scriptError = aMessage.QueryInterface(Ci.nsIScriptError);
dump(aMessage.sourceName + ":" + aMessage.lineNumber + ": " +
scriptErrorFlagsToKind(aMessage.flags) + ": " +
aMessage.errorMessage + "\n");
var string = aMessage.errorMessage;
} catch (x) {
// Be a little paranoid with message, as the whole goal here is to lose
// no information.
try {
var string = "" + aMessage.message;
} catch (x) {
var string = "<error converting error message to string>";
}
}
// Ignored until they are fixed in bug 1242968.
if (string.includes("JavaScript Warning")) {
return;
}
do_throw("head_acorn.js got console message: " + string + "\n");
}
};
var consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
consoleService.registerListener(listener);

View file

@ -0,0 +1,18 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test that we can require acorn.
*/
function run_test() {
const acorn = require("acorn/acorn");
const acorn_loose = require("acorn/acorn_loose");
const walk = require("acorn/util/walk");
do_check_true(isObject(acorn));
do_check_true(isObject(acorn_loose));
do_check_true(isObject(walk));
do_check_eq(typeof acorn.parse, "function");
do_check_eq(typeof acorn_loose.parse_dammit, "function");
do_check_eq(typeof walk.simple, "function");
}

View file

@ -0,0 +1,62 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test that acorn's lenient parser gives something usable.
*/
const acorn_loose = require("acorn/acorn_loose");
function run_test() {
let actualAST = acorn_loose.parse_dammit("let x = 10", {});
do_print("Actual AST:");
do_print(JSON.stringify(actualAST, null, 2));
do_print("Expected AST:");
do_print(JSON.stringify(expectedAST, null, 2));
checkEquivalentASTs(expectedAST, actualAST);
}
const expectedAST = {
"type": "Program",
"start": 0,
"end": 10,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 3,
"expression": {
"type": "Identifier",
"start": 0,
"end": 3,
"name": "let"
}
},
{
"type": "ExpressionStatement",
"start": 4,
"end": 10,
"expression": {
"type": "AssignmentExpression",
"start": 4,
"end": 10,
"operator": "=",
"left": {
"type": "Identifier",
"start": 4,
"end": 5,
"name": "x"
},
"right": {
"type": "Literal",
"start": 8,
"end": 10,
"value": 10,
"raw": "10"
}
}
}
]
};

View file

@ -0,0 +1,37 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test that Reflect and acorn create the same AST for ES5.
*/
const acorn = require("acorn/acorn");
const { Reflect } = require("resource://gre/modules/reflect.jsm");
const testCode = "" + function main () {
function makeAcc(n) {
return function () {
return ++n;
};
}
var acc = makeAcc(10);
for (var i = 0; i < 10; i++) {
acc();
}
console.log(acc());
};
function run_test() {
const reflectAST = Reflect.parse(testCode);
const acornAST = acorn.parse(testCode);
do_print("Reflect AST:");
do_print(JSON.stringify(reflectAST, null, 2));
do_print("acorn AST:");
do_print(JSON.stringify(acornAST, null, 2));
checkEquivalentASTs(reflectAST, acornAST);
}

View file

@ -0,0 +1,10 @@
[DEFAULT]
tags = devtools
head = head_acorn.js
tail =
firefox-appdir = browser
skip-if = toolkit == 'android'
[test_import_acorn.js]
[test_same_ast.js]
[test_lenient_parser.js]