mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 23:58:07 +02:00
JS -- Actions must be evaluated in global scope
* All the public properties of doc are injected into globalThis, in order to make them available through `this` * Put event in the global scope too.
This commit is contained in:
parent
c366390f6b
commit
167ff1a7fc
7 changed files with 178 additions and 53 deletions
|
@ -129,6 +129,38 @@ describe("Scripting", function () {
|
|||
});
|
||||
});
|
||||
|
||||
describe("Doc", function () {
|
||||
it("should treat globalThis as the doc", async function (done) {
|
||||
const refId = getId();
|
||||
const data = {
|
||||
objects: {
|
||||
field: [
|
||||
{
|
||||
id: refId,
|
||||
value: "",
|
||||
actions: {},
|
||||
type: "text",
|
||||
},
|
||||
],
|
||||
},
|
||||
appInfo: { language: "en-US", platform: "Linux x86_64" },
|
||||
calculationOrder: [],
|
||||
dispatchEventName: "_dispatchMe",
|
||||
};
|
||||
sandbox.createSandbox(data);
|
||||
|
||||
try {
|
||||
await myeval(`(this.foobar = 123456, 0)`);
|
||||
await myeval(`this.getField("field").doc.foobar`).then(value => {
|
||||
expect(value).toEqual(123456);
|
||||
});
|
||||
done();
|
||||
} catch (ex) {
|
||||
done.fail(ex);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("Util", function () {
|
||||
beforeAll(function (done) {
|
||||
sandbox.createSandbox({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue