Skip to content

Commit

Permalink
[Firefox] Remove the FirefoxCom.requestSync method, since it's unused
Browse files Browse the repository at this point in the history
After the two previous commits, which removed the remaining call-sites, this method is no longer used and can thus be removed.
As mentioned in the JSDocs for the now removed method, synchronous communication between the viewer and the platform code isn't really a good idea.

Once this patch has landed in mozilla-central some additional clean-up of the platform code will also be possible.
  • Loading branch information
Snuffleupagus committed Nov 26, 2023
1 parent bdae588 commit b3a604f
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions web/firefoxcom.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,6 @@ if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
}

class FirefoxCom {
/**
* Creates an event that the extension is listening for and will
* synchronously respond to.
* NOTE: It is recommended to use requestAsync() instead since one day we may
* not be able to synchronously reply.
* @param {string} action - The action to trigger.
* @param {Object|string} [data] - The data to send.
* @returns {*} The response.
*/
static requestSync(action, data) {
const request = document.createTextNode("");
document.documentElement.append(request);

const sender = new CustomEvent("pdf.js.message", {
bubbles: true,
cancelable: false,
detail: {
action,
data,
sync: true,
},
});
request.dispatchEvent(sender);
const response = sender.detail.response;
request.remove();

return response;
}

/**
* Creates an event that the extension is listening for and will
* asynchronously respond to.
Expand Down Expand Up @@ -96,7 +67,6 @@ class FirefoxCom {
detail: {
action,
data,
sync: false,
responseExpected: !!callback,
},
});
Expand Down

0 comments on commit b3a604f

Please sign in to comment.