girst [Sun, 3 Mar 2024 11:59:18 +0000 (12:59 +0100)]
port legacyfox to ecmascript modules
mozilla calls this 'esm-ification'. the last relevant to us modules were
ported in mozilla124[1], so this is our new minimum version. the old
version will likely be compatible with firefox up to version 128esr[2].
static imports are not supported in autoconfig scripts. i tried to keep
the diff as small as possible w.r.t comm-central's final JSMs. because
of this, we don't lazy-load any modules any more, nor provide any lazy
getters, as they would need to be loaded into a `lazy` object instead
the global (`this`) namespace, causing more churn. other than that, the
largest change was removing the now-useless Services.jsm workaround as
well as removing globalGetters for objects already loaded automatically.
girst [Thu, 1 Feb 2024 20:22:58 +0000 (21:22 +0100)]
remove OS.File references
osfile.jsm was removed by bugzil.la/1772262. This method is not used any
more, so we can just remove it. the modern alternative would be the
following, but that only works on mozilla>=85.
return IOUtils.writeUTF8(file, this.serializeToString());
osfile.jsm was loaded lazily (and in our case therefore never), so we
didn't die immediately upon import, fortunately.
girst [Thu, 1 Feb 2024 20:17:50 +0000 (21:17 +0100)]
remove use of deprecated components
console.createInstance() is available since firefox59 (Bug 1425574), so
no workaround needed. ChromeUtils.defineLazyGetter() however only is
since firefox112 (Bug 1805288) but the backwards-compatible code is tiny
see also:
https://bugzilla.mozilla.org/show_bug.cgi?id=1875216
https://bugzilla.mozilla.org/show_bug.cgi?id=1430810
https://bugzilla.mozilla.org/show_bug.cgi?id=1828156
https://groups.google.com/a/mozilla.org/g/dev-platform/c/BdyWnTjLSXg
reported to https://github.com/xiaoxiaoflood/firefox-scripts/issues/115
> I just found that for my legacy addon after restart it some of it
> function calls that initiated by timer or observer callback are
> running in a sandbox context of the last startup which is different
> from current one. And this cause malfunctions for my addon.
This is not necessary, as it is only checked in
XPIDatabase.jsm::mustSign(), which we can override instead, and in
aboutaddonsCommon.js::isDisabledUnsigned(), which we cannot affect
anyways and only uses it to show a red warning bar for legacy addons.
This also removes the old AddonSettings.ALLOW_LEGACY_EXTENSIONS
override, which was only used in Extension.jsm::experimentsAllowed()
and XPIDatabase.jsm::isDisabledLegacy().
This is in preparation for the ESM-ification endeavours going on at
Mozilla, which will make importing a module's global object (as we did
with `let Xdb = Cu.import(...)`) impossible, but was needed to get a
reference to AddonSettings (instead of a copy). Step two will be
replacing Cu.import() with ChromeUtils.import(), which has stricter
semantics about exported objects (doesn't hurt us; see Bug 1766114).
downgrading the warning color stopped working some time ago. for
completeness, as of nightly99 xpinstall.signatures.required is only
checked in these places, none of which affect us:
- nsContentSecurityUtils.cpp::DetectJsHacks()
only for telemetry and relaxing some security measures we don't need
- BrowserGlue.jsm::_onWindowsRestored()
gates call to _notifyUnsignedAddonsDisabled(), which isn't triggered
by our stuff (signedState != SIGNEDSTATE_MISSING)
- AddonSettings.jsm::REQUIRE_SIGNING
overridden by our config.js script, so doesn't matter
- XPIProvider.jsm::observe()
calls XPIDatabase.updateAddonAppDisabledStates(), which calls
this.updateAddonDisabledState(addon), which depends on
this.isUsableAddon(aAddon), which returns true as long as we override
this.isDisabledLegacy(aAddon)
girst [Thu, 1 Oct 2020 20:59:50 +0000 (22:59 +0200)]
automatically disable signature requirement
Having signatures enforced causes a big red error message to appear
below unsigned extensions, telling the user the extension has been
disabled. This is not true, though; the extensions are still enabled.
Setting xpinstall.signatures.required;false downgrades this error to a
(yellow) warning.
don't prevent unsigned addon warning to not break some addons
This broke installing some, but not all, addons. The reason is that some
addons derive their addon-id from a certificate's CommonName in
XPIInstall.jsm::loadManifest(aPackage, aLocation, aOldAddon)
bring the patch closer to the then-upstream comm-central. might have the
negative side-effect of being detectable by websites according to:
https://developer.mozilla.org/en-US/docs/Mozilla/Chrome_Registration
this hopefully makes the monkey patch update persistent.
Note: instead of using FileUtils, this would be another method:
const {Services} = Cu.import('resource://gre/modules/Services.jsm');
let manifest = Services.dirsvc.get('GreD', Ci.nsIFile);
manifest.append('legacy.manifest');