Revert "Make KaTeX work in Quirks mode (#608)" (#777)

This reverts commit d93a958379.
This commit is contained in:
Kevin Barabash
2017-07-30 23:28:58 -04:00
committed by GitHub
parent d93a958379
commit 1e148746f8
8 changed files with 40 additions and 84 deletions

View File

@@ -21,7 +21,7 @@ docker containers with the selenium setups running. Essentially you
are encouraged to reproduce the steps from `screenshotter.sh`
manually. Example run for Firefox:
container=$(docker run -d -P selenium/standalone-firefox:2.48.2)
container=$(docker run -d -P selenium/standalone-firefox:2.46.0)
node dockers/Screenshotter/screenshotter.js -b firefox -c ${container}
# possibly repeat the above command as often as you need, then eventually
docker stop ${container}

View File

@@ -86,14 +86,6 @@ const opts = require("nomnom")
.option("wait", {
help: "Wait this many seconds between page load and screenshot",
})
.option("mode", {
choices: ["no-quirks", "limited-quirks", "quirks", "all"],
list: true,
help: "Render mode, determined by doctype, " +
"may be given multiple times, " +
"values [no-quirks|limited-quirks|quirks|all], " +
"defaults to all for --verify or no-quirks otherwise",
})
.parse();
let listOfCases;
@@ -109,17 +101,6 @@ if (opts.exclude) {
});
}
let modes = opts.mode || [];
if (!modes.length) {
modes = [opts.verify ? "all" : "no-quirks"];
}
if (modes.indexOf("all") !== -1) {
modes = ["no-quirks", "limited-quirks", "quirks"];
}
if (modes.length > 1 && !opts.verify) {
modes.length = 1;
}
let seleniumURL = opts.seleniumURL;
let seleniumIP = opts.seleniumIP;
let seleniumPort = opts.seleniumPort;
@@ -377,41 +358,16 @@ function findHostIP() {
//////////////////////////////////////////////////////////////////////
// Take the screenshots
let countdown = listOfCases.length * modes.length;
let countdown = listOfCases.length;
let exitStatus = 0;
const listOfFailed = [];
const doctypes = {
"no-quirks": "<!DOCTYPE html>",
"limited-quirks": '<!DOCTYPE HTML PUBLIC ' +
'"-//W3C//DTD HTML 4.01 Transitional//EN" ' +
'"http://www.w3.org/TR/html4/loose.dtd">',
"quirks": '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Draft//">',
};
// Use two characters per abbreviation for better alignment of output
const qabbr = {
"no-quirks": "nq",
"limited-quirks": "lq",
"quirks": " q",
};
function takeScreenshots() {
const html = fs.readFileSync(require.resolve(
"../../test/screenshotter/test.html"));
function handler(req, res, next) {
res.send(doctypes[req.query.mode] + "\n" + html);
}
app.get("/ss-render.html", handler);
modes.forEach(function(mode) {
listOfCases.forEach(function(key) {
takeScreenshot(key, mode);
});
});
listOfCases.forEach(takeScreenshot);
}
function takeScreenshot(key, mode) {
function takeScreenshot(key) {
const itm = data[key];
if (!itm) {
console.error("Test case " + key + " not known!");
@@ -423,19 +379,14 @@ function takeScreenshot(key, mode) {
return;
}
let basename = key + "-" + opts.browser;
if (itm.quirky && itm.quirky.indexOf(mode) !== -1) {
// a test case known to differ depending on mode may make use of this
basename += "-" + qabbr[mode];
}
let file = path.join(dstDir, basename + ".png");
let file = path.join(dstDir, key + "-" + opts.browser + ".png");
let retry = 0;
let loadExpected = null;
if (opts.verify) {
loadExpected = promisify(fs.readFile, file);
}
const url = katexURL + "ss-render.html?mode=" + mode + "&" + itm.query;
const url = katexURL + "test/screenshotter/test.html?" + itm.query;
driver.call(loadMath);
function loadMath() {
@@ -477,9 +428,8 @@ function takeScreenshot(key, mode) {
* the other has something else. By using a different
* output file name for one of these cases, we accept both.
*/
basename = basename.replace(key, key + "_alt");
key += "_alt";
file = path.join(dstDir, basename + ".png");
file = path.join(dstDir, key + "-" + opts.browser + ".png");
if (loadExpected) {
loadExpected = promisify(fs.readFile, file);
}
@@ -488,19 +438,18 @@ function takeScreenshot(key, mode) {
pako: pako,
});
const buf = opt.bufferSync(img.buf);
const line = qabbr[mode] + " " + key;
if (loadExpected) {
return loadExpected.then(function(expected) {
if (!buf.equals(expected)) {
if (++retry >= opts.attempts) {
console.error("FAIL! " + line);
listOfFailed.push(key + "[" + qabbr[mode] + "]");
console.error("FAIL! " + key);
listOfFailed.push(key);
exitStatus = 3;
if (opts.diff) {
return saveScreenshotDiff(key, buf);
}
} else {
console.log("error " + line);
console.log("error " + key);
browserSideWait(300 * retry);
if (retry > 1) {
driverReady = false; // reload fully
@@ -508,12 +457,12 @@ function takeScreenshot(key, mode) {
return driver.call(loadMath);
}
} else {
console.log("* ok " + line);
console.log("* ok " + key);
}
});
} else {
return promisify(fs.writeFile, file, buf).then(function() {
console.log(line);
console.log(key);
});
}
}

View File

@@ -29,7 +29,7 @@ popd || exit 2
container=
trap cleanup EXIT
status=0
for browserTag in chrome:2.48.2 firefox:2.48.2; do
for browserTag in firefox:2.48.2 chrome:2.48.2; do
browser=${browserTag%:*}
image=selenium/standalone-${browserTag}
echo "Starting container for ${image}"