Skip to content
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

Ensure that we don't try to re-open, or update the password-callback, when the password dialog is already open #15335

Merged

Conversation

Snuffleupagus
Copy link
Collaborator

Currently in disableWorker=true mode it's possible that opening of password-protected PDF documents outright fails, if an incorrect password is entered. Apparently the event ordering is subtly different in the non-Worker case, which causes the password-callback to be updated before the dialog has been fully closed.
To avoid that we'll utilize a PromiseCapability to keep track of the state of the password dialog, such that we can delay both re-opening and (importantly) updating of the password-callback until doing so is safe.

This patch may also fix issue #15330, but it's impossible for me to tell.

@imbaky
Copy link

imbaky commented Aug 19, 2022

I've tested this change and unfortunately it doesn't fix #15330

Screen Shot 2022-08-19 at 1 59 45 PM

… when the password dialog is already open

Currently in `disableWorker=true` mode it's possible that opening of password-protected PDF documents outright fails, if an *incorrect* password is entered. Apparently the event ordering is subtly different in the non-Worker case, which causes the password-callback to be updated *before* the dialog has been fully closed.
To avoid that we'll utilize a `PromiseCapability` to keep track of the state of the password dialog, such that we can delay both re-opening and (importantly) updating of the password-callback until doing so is safe.

This patch *may* also fix issue 15330, but it's impossible for me to tell.
@Snuffleupagus Snuffleupagus force-pushed the PasswordPrompt-activeCapability branch from c16971c to 8984064 Compare August 19, 2022 18:10
@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_preview from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/4c6a94f3ed926c3/output.txt

@mozilla mozilla deleted a comment from pdfjsbot Aug 19, 2022
@mozilla mozilla deleted a comment from pdfjsbot Aug 19, 2022
@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/4c6a94f3ed926c3/output.txt

Total script time: 2.59 mins

Published

@timvandermeij
Copy link
Contributor

Is this PR ready for review, given the comments above that it doesn't seem to fix the original issue? I'm also fine with merging this if it's an improvement even if it doesn't yet fix the issue at hand, but if you're planning on looking further into this I'll wait with the review.

@Snuffleupagus
Copy link
Collaborator Author

Is this PR ready for review, given the comments above that it doesn't seem to fix the original issue?

Yes, since it fixes problems with disableWorker=true mode. Try opening http://localhost:8888/web/viewer.html?file=/test/pdfs/issue6010_1.pdf#disableWorker=true and enter an incorrect password[1] (try e.g. "test"), note how opening the document simply fails without prompting you to re-enter a password.

but if you're planning on looking further into this I'll wait with the review.

I'd prefer this landing as-is, after being tested and reviewed of course, since it fixes an existing issue where the updateCallback may change before we manage to close the password dialog.

My feeling is also that the remaining issue, which is difficult for me to debug, is connected to the dialog-polyfill itself somehow...


[1] For reference, the correct password is "abc".

@timvandermeij timvandermeij merged commit 14e8167 into mozilla:master Aug 21, 2022
@timvandermeij
Copy link
Contributor

Let's do this; thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants