[Firefox] Avoid unnecessary string-parsing when reading preferences
Note how the [`ChromeActions.getPreferences` method](https://searchfox.org/mozilla-central/rev/4e8f62a231e71dc53eb50b6d74afca21d6b254e9/toolkit/components/pdfjs/content/PdfStreamConverter.sys.mjs#497-530) returns the preferences as a string, which we then have to convert back into an Object in the viewer. Back when that code was originally written it wasn't possible to send Objects from the platform-code, however that's no longer the case and we should be able to (eventually) remove this unnecessary string-parsing now. *Please note that in order to prevent breakage we'll need to land these changes in stages:* - Land this patch in mozilla-central, as part of regular the PDF.js updates. - Change the return type in the `ChromeActions.getPreferences` method, in a mozilla-central patch. - Remove the string-handling from the `FirefoxPreferences._readFromStorage` method.
This commit is contained in:
parent
1f9d1f3696
commit
5c0872d1b0
@ -175,8 +175,8 @@ class DownloadManager {
|
||||
|
||||
class FirefoxPreferences extends BasePreferences {
|
||||
async _readFromStorage(prefObj) {
|
||||
const prefStr = await FirefoxCom.requestAsync("getPreferences", prefObj);
|
||||
return JSON.parse(prefStr);
|
||||
const prefs = await FirefoxCom.requestAsync("getPreferences", prefObj);
|
||||
return typeof prefs === "string" ? JSON.parse(prefs) : prefs;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user