-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JS] Some functions (print, alert,...) must be called only after a user activation #15618
Conversation
src/pdf.sandbox.external.js
Outdated
if (callbackId === 0) { | ||
this.win.clearTimeout(this.timeoutIds.get(0)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have similar code in the setInterval
method below?
If not, maybe add a (brief) comment to explain what's "special" about this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me, with a couple of minor comments and passing tests; thank you!
src/scripting_api/app.js
Outdated
@@ -23,6 +23,7 @@ const VIEWER_TYPE = "PDF.js"; | |||
const VIEWER_VARIATION = "Full"; | |||
const VIEWER_VERSION = 21.00720099; | |||
const FORMS_VERSION = 21.00720099; | |||
const USERACTIVATION_CALBACKID = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making this a constant was a good idea, but please fix the spelling :-)
const USERACTIVATION_CALBACKID = 0; | |
const USERACTIVATION_CALLBACKID = 0; |
src/pdf.sandbox.external.js
Outdated
if (callbackId === 0) { | ||
// This callbackId corresponds to the one used for userActivation. | ||
// So here, we cancel the last userActivation. | ||
this.win.clearTimeout(this.timeoutIds.get(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's avoid the additional hard-coding here:
this.win.clearTimeout(this.timeoutIds.get(0)); | |
this.win.clearTimeout(this.timeoutIds.get(callbackId)); |
…er activation - Some events, which require a user interaction, will allow those functions to be called. But after few seconds, if there are no more user interaction, it won't be possible anymore. The idea is to give an opportunity to the user to leave the pdf. - Disable print function when we're printing, the same with saving and disallow to save on open events.
/botio unittest |
From: Bot.io (Linux m4)ReceivedCommand cmd_unittest from @calixteman received. Current queue size: 0 Live output at: http://54.241.84.105:8877/63edac26607e263/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_unittest from @calixteman received. Current queue size: 0 Live output at: http://54.193.163.58:8877/1d286f49d78f477/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/63edac26607e263/output.txt Total script time: 2.34 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.193.163.58:8877/1d286f49d78f477/output.txt Total script time: 7.90 mins
|
/botio integrationtest |
From: Bot.io (Linux m4)ReceivedCommand cmd_integrationtest from @calixteman received. Current queue size: 0 Live output at: http://54.241.84.105:8877/460adc3fb880795/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_integrationtest from @calixteman received. Current queue size: 0 Live output at: http://54.193.163.58:8877/d96c1bd53512b26/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/460adc3fb880795/output.txt Total script time: 4.13 mins
|
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/d96c1bd53512b26/output.txt Total script time: 12.18 mins
|
The idea is to give an opportunity to the user to leave the pdf.
Close #15614.