JS -- Fix events dispatchment and add tests

* dispatch event to take into account calculation order
 * use a map for actions in Field
This commit is contained in:
Calixte Denizet 2020-11-03 19:24:07 +01:00
parent 83658c974d
commit 2dfac4cb41
7 changed files with 459 additions and 104 deletions

View file

@ -22,7 +22,7 @@ import { ProxyHandler } from "./proxy.js";
import { Util } from "./util.js";
import { ZoomType } from "./constants.js";
function initSandbox(data, extra, out) {
function initSandbox({ data, extra, out, testMode = false }) {
const proxyHandler = new ProxyHandler(data.dispatchEventName);
const { send, crackURL } = extra;
const doc = new Doc({
@ -58,6 +58,14 @@ function initSandbox(data, extra, out) {
out[name] = aform[name].bind(aform);
}
}
if (
(typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")) &&
testMode
) {
out._app = app;
}
}
export { initSandbox };