mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.17k stars 9.95k forks source link

[Editor] Remove event listeners with `AbortSignal.any()` #18586

Closed Snuffleupagus closed 1 month ago

Snuffleupagus commented 1 month ago

There's a fair number of event listeners in the editor-code that we're currently removing "manually", by keeping references to their event handler functions. This was necessary since we have a "global" AbortController that applies to all event listeners used in the editor-code, however it's now possible to combine multiple AbortSignals; please see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static

Since this functionality is fairly new the viewer will check that AbortSignal.any() is available before enabling the editing-functionality. (It should hopefully be fairly straightforward, famous last words, for users to implement a polyfill to allow editing in older browsers.)

Finally, this patch also adds checks and test-only asserts to ensure that we don't add duplicate event listeners in various editor-code.

Snuffleupagus commented 1 month ago

/botio integrationtest

moz-tools-bot commented 1 month ago

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/9b42919522445f0/output.txt

moz-tools-bot commented 1 month ago

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/0fdc0141f7e7afd/output.txt

moz-tools-bot commented 1 month ago

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/0fdc0141f7e7afd/output.txt

Total script time: 8.38 mins

moz-tools-bot commented 1 month ago

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/9b42919522445f0/output.txt

Total script time: 17.83 mins

Snuffleupagus commented 1 month ago

/botio integrationtest

moz-tools-bot commented 1 month ago

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/a6cf1e601da1f2f/output.txt

moz-tools-bot commented 1 month ago

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/d8804eb70eb9728/output.txt

moz-tools-bot commented 1 month ago

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/a6cf1e601da1f2f/output.txt

Total script time: 8.35 mins

moz-tools-bot commented 1 month ago

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/d8804eb70eb9728/output.txt

Total script time: 18.01 mins

Snuffleupagus commented 1 month ago

/botio integrationtest

moz-tools-bot commented 1 month ago

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/b0de5aceed2f82e/output.txt

moz-tools-bot commented 1 month ago

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/625695c9a0049b1/output.txt

moz-tools-bot commented 1 month ago

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/b0de5aceed2f82e/output.txt

Total script time: 8.37 mins

moz-tools-bot commented 1 month ago

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/625695c9a0049b1/output.txt

Total script time: 17.87 mins

Snuffleupagus commented 1 month ago

In reading the docs for AbortSignal::any I noticed AbortSignal::Timeout, is it something we could use somewhere ?

I'm sure that could be helpful, but off the top of my head I don't know of any cases that would benefit from it.