Summary
We'd like contributors to use the same linter and lint rules that we use
internally. This diff swaps out eslint for jshint and fixes all lint failures
except for the max-len failures in the test suites.
Test Plan:
- ka-lint src
- make lint
- make test
Reviewers: emily
Otherwise it could happen that some Mozilla page gets shown which has a
minimal size larger than the 786px we're requesting. And the screenshot
will span that entire page even if the window is smaller, resulting in a
failure to adjust screenshot size.
See http://kb.mozillazine.org/Browser.startup.homepage_override.mstone
and http://kb.mozillazine.org/Browser.startup.page for details.
Just in case, we also include the docker image digests in the travis build
log, to increase chances of reproducing what we get there.
Now Travis can run the screenshotter in verification mode. The files in the
repository will be seen as the expected outcome, and if the actual result
differs from that, it might be attempted four more times before the test
case is actually deemed failed. A timeout between page load and screenshot
should allow any possible font issues to settle down.
The combination of jspngopt and pako should eliminate possible causes for
different PNG encodings, although the core reason for #325 remains unknown.
Pako has poorer compression rates than native libz, but optimization can
counter that effect, and actually reduce the size of the screenshots.
The screenshots for LimitControls and UnsupportedCmds on Firefox used to
exhibit subpixel rendering before, for reasons unknown. The regenerated
versions don't exhibit this. See #324 for a discussion.
Escaping TeX in JSON as query strings is a pain: you have to double all the
\\, you have to escape the & and the #, you can't easily include line breaks
for readability, and so on. YAML solves most of these problems for most of
the situations. Now each test case can be structured, while simple test
cases only consist of a line of verbatim TeX code, with no escaping.
The most troublesome items remaining are lines starting in { since in YAML
these would denote inline mapping types. We use block notation for these.
This avoids one of the few requirements we have left: you no longer have to
start a KaTeX development server, the script will do it for you, using a
random port number.
To reproduce the old behaviour, explicitely state --katex-port=7936.
Since the Selenium images are available for download, and downloading them
is usually faster than building them from scratch, this makes taking
screenshots easier. Furthermore, since the Selenium image is not specific
to KaTeX, it could as well be used for other purposes, thus saving space
since a single image can be used in multiple projects.
This change also deals with the non-determinism in the Lap screenshot:
We detect the one known (and accepted) alternate rendering and change the
output file name to Lap_alt in this case. So either Lap or Lap_alt gets
saved to, and if the image is different from both, then one of these files
will show a modification. On the other hand, if it is equal to either of
these, then the matching one will get overwritten, showing no change.
Summary:
Create our own screenshotting script which takes screenshots. This
improves over huxley for a couple reasons:
- It makes the screenshots the correct size (for some reason, huxley struggles
with this).
- Its configuration matches more with what we want (we don't need multiple
screenshots or interaction, we just want a single static shot)
- It runs faster
I also changed the docs to reflect this change.
Test Plan:
- Make sure all of the tests that were in the Huxleyfile are now in ss_data.json
- Run the screenshotter docker
- Make sure all of the images look reasonable and don't change (except
sometimes the Lap test, which has some strange pixel-positioning
differences...)
Reviewers: kevinb
Reviewed By: kevinb
Differential Revision: https://phabricator.khanacademy.org/D16731