Ensure that the "pdf.js.response" event listener, in FirefoxCom.request
, actually applies to the current Text
node
Given that the event listener is registered on the document, there could in *theory* be more than one of these listeners present at any one time. In practice this doesn't currently happen, since all of the `actions` invoked in [`PdfStreamConverter.jsm`](https://searchfox.org/mozilla-central/rev/bfbacfb6a4efd98247e83d3305e912ca4f7e106a/toolkit/components/pdfjs/content/PdfStreamConverter.jsm#933-952) are *synchronous* methods. However, there's no guarantee that this will always be the case, and it's easy enough to prevent any future issues here by simply registering the "pdf.js.response" event listener on the `Text` node instead. This works since, as can be seen in [`PdfStreamConverter.jsm`](https://searchfox.org/mozilla-central/rev/bfbacfb6a4efd98247e83d3305e912ca4f7e106a/toolkit/components/pdfjs/content/PdfStreamConverter.jsm#919,943), the event is dispatched on the element itself rather than the document.
This commit is contained in:
parent
99b1a62c97
commit
8b3b542447
@ -64,12 +64,11 @@ const FirefoxCom = (function FirefoxComClosure() {
|
||||
request(action, data, callback) {
|
||||
const request = document.createTextNode("");
|
||||
if (callback) {
|
||||
document.addEventListener(
|
||||
request.addEventListener(
|
||||
"pdf.js.response",
|
||||
event => {
|
||||
const node = event.target;
|
||||
const response = event.detail.response;
|
||||
node.remove();
|
||||
event.target.remove();
|
||||
|
||||
callback(response);
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user