pdf.js/test/unit/testreporter.js
Jonas Jenwald 1cc3dbb694 Enable the dot-notation ESLint rule
*Please note:* These changes were done automatically, using the `gulp lint --fix` command.

This rule is already enabled in mozilla-central, see https://searchfox.org/mozilla-central/rev/567b68b8ff4b6d607ba34a6f1926873d21a7b4d7/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js#103-104

The main advantage, besides improved consistency, of this rule is that it reduces the size of the code (by 3 bytes for each case). In the PDF.js code-base there's close to 8000 instances being fixed by the `dot-notation` ESLint rule, which end up reducing the size of even the *built* files significantly; the total size of the `gulp mozcentral` build target changes from `3 247 456` to `3 224 278` bytes, which is a *reduction* of `23 178` bytes (or ~0.7%) for a completely mechanical change.

A large number of these changes affect the (large) lookup tables used on the worker-thread, but given that they are still initialized lazily I don't *think* that the new formatting this patch introduces should undo any of the improvements from PR 6915.

Please find additional details about the ESLint rule at https://eslint.org/docs/rules/dot-notation
2020-04-17 12:24:46 +02:00

78 lines
1.9 KiB
JavaScript

"use strict";
// eslint-disable-next-line no-unused-vars
var TestReporter = function (browser, appPath) {
function send(action, json, cb) {
var r = new XMLHttpRequest();
// (The POST URI is ignored atm.)
r.open("POST", action, true);
r.setRequestHeader("Content-Type", "application/json");
r.onreadystatechange = function sendTaskResultOnreadystatechange(e) {
if (r.readyState === 4) {
// Retry until successful
if (r.status !== 200) {
send(action, json, cb);
} else {
if (cb) {
cb();
}
}
}
};
json.browser = browser;
r.send(JSON.stringify(json));
}
function sendInfo(message) {
send("/info", { message });
}
function sendResult(status, description, error) {
var message = {
status,
description,
};
if (typeof error !== "undefined") {
message.error = error;
}
send("/submit_task_results", message);
}
function sendQuitRequest() {
send("/tellMeToQuit?path=" + escape(appPath), {});
}
this.now = function () {
return new Date().getTime();
};
this.jasmineStarted = function (suiteInfo) {
this.runnerStartTime = this.now();
sendInfo("Started tests for " + browser + ".");
};
this.suiteStarted = function (result) {};
this.specStarted = function (result) {};
this.specDone = function (result) {
if (result.failedExpectations.length === 0) {
sendResult("TEST-PASSED", result.description);
} else {
var failedMessages = "";
var items = result.failedExpectations;
for (var i = 0, ii = items.length; i < ii; i++) {
failedMessages += items[i].message + " ";
}
sendResult("TEST-UNEXPECTED-FAIL", result.description, failedMessages);
}
};
this.suiteDone = function (result) {};
this.jasmineDone = function () {
// Give the test.py some time process any queued up requests
setTimeout(sendQuitRequest, 500);
};
};