mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-10 02:08:38 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
|
|
@ -0,0 +1,51 @@
|
|||
|
||||
// generates tests that work in a browser
|
||||
|
||||
// XXX
|
||||
// have it run through valid and invalid properly
|
||||
|
||||
var pth = require("path")
|
||||
, fs = require("fs")
|
||||
, dir = function (path) {
|
||||
return pth.join(__dirname, "..", path);
|
||||
}
|
||||
, allFromDir = function (dir, ext, asJSON) {
|
||||
return fs.readdirSync(dir)
|
||||
.filter(function (it) { return ext.test(it); })
|
||||
.map(function (it) {
|
||||
var cnt = fs.readFileSync(pth.join(dir, it), "utf8");
|
||||
return asJSON ? JSON.parse(cnt) : cnt;
|
||||
});
|
||||
}
|
||||
, data = {
|
||||
valid: {
|
||||
json: allFromDir(dir("syntax/json"), /\.json$/, true)
|
||||
, idl: allFromDir(dir("syntax/idl"), /\.w?idl$/, false)
|
||||
}
|
||||
, invalid:{
|
||||
json: allFromDir(dir("invalid/json"), /\.json$/, true)
|
||||
, idl: allFromDir(dir("invalid/idl"), /\.w?idl$/, false)
|
||||
}
|
||||
}
|
||||
, html = [
|
||||
"<!DOCTYPE html>"
|
||||
, "<html>"
|
||||
, " <head><meta charset='utf-8''><link rel='stylesheet' href='../../node_modules/mocha/mocha.css'>"
|
||||
, " <title>WebIDL2 Browser Tests</title>"
|
||||
, " <script>var data = " + JSON.stringify(data) + "</script>"
|
||||
, " </head>"
|
||||
, " <body><div id='mocha'></div>"
|
||||
, " <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></script>"
|
||||
, " <script src='../../node_modules/expect.js/expect.js'></script>"
|
||||
, " <script src='../../node_modules/mocha/mocha.js'></script>"
|
||||
, " <script src='../../node_modules/jsondiffpatch/jsondiffpatch.min.js'></script>"
|
||||
, " <script src='../../lib/webidl2.js'></script>"
|
||||
, " <script>mocha.setup('bdd');</script>"
|
||||
, " <script src='run-tests.js'></script>"
|
||||
, " <script>mocha.run();</script>"
|
||||
, " </body>"
|
||||
, "</html>"
|
||||
].join("\n")
|
||||
;
|
||||
|
||||
fs.writeFileSync("browser-tests.html", html, "utf8");
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
describe("Parses all of the IDLs to produce the correct ASTs", function () {
|
||||
for (var i = 0, n = data.valid.idl.length; i < n; i++) {
|
||||
var idl = data.valid.idl[i], json = data.valid.json[i];
|
||||
var func = (function (idl, json) {
|
||||
return function () {
|
||||
try {
|
||||
// the AST contains NaN and +/-Infinity that cannot be serialised to JSON
|
||||
// the stored JSON ASTs use the same replacement function as is used below
|
||||
// so we compare based on that
|
||||
var diff = jsondiffpatch.diff(json, WebIDL2.parse(idl));
|
||||
if (diff && debug) console.log(JSON.stringify(diff, null, 4));
|
||||
expect(diff).to.be(undefined);
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e.toString());
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
}(idl, json));
|
||||
it("should produce the same AST for " + i, func);
|
||||
}
|
||||
});
|
||||
|
||||
describe("Parses all of the invalid IDLs to check that they blow up correctly", function () {
|
||||
for (var i = 0, n = data.invalid.idl.length; i < n; i++) {
|
||||
var idl = data.invalid.idl[i], error = data.invalid.json[i];
|
||||
var func = (function (idl, err) {
|
||||
return function () {
|
||||
var error;
|
||||
try {
|
||||
var ast = WebIDL2.parse(idl);
|
||||
console.log(JSON.stringify(ast, null, 4));
|
||||
}
|
||||
catch (e) {
|
||||
error = e;
|
||||
}
|
||||
finally {
|
||||
expect(error).to.be.ok();
|
||||
expect(error.message).to.equal(err.message);
|
||||
expect(error.line).to.equal(err.line);
|
||||
}
|
||||
|
||||
};
|
||||
}(idl, error));
|
||||
it("should produce the right error for " + i, func);
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue