Make createImageBitmap() zero-argument

This commit is contained in:
wuggy 2026-09-19 05:18:51 -07:00
commit e98942c307

View file

@ -778,14 +778,28 @@ class ExtensionPageContextChild extends BaseContext {
// native, but make the probe harmless in extension pages. // native, but make the probe harmless in extension pages.
if (typeof contentWindow.createImageBitmap == "function") { if (typeof contentWindow.createImageBitmap == "function") {
let nativeCreateImageBitmap = contentWindow.createImageBitmap; let nativeCreateImageBitmap = contentWindow.createImageBitmap;
try { let extensionCreateImageBitmap = function(...args) {
contentWindow.createImageBitmap = function(...args) {
if (args.length == 0) { if (args.length == 0) {
return contentWindow.Promise.resolve(null); return contentWindow.Promise.resolve(null);
} }
return nativeCreateImageBitmap.apply(this, args); return nativeCreateImageBitmap.apply(this, args);
}; };
} catch (e) {} try {
// Window.createImageBitmap is inherited from a WebIDL prototype in
// older UXP builds. Assignment can therefore leave the native
// method in place; define an own property so extension feature probes
// actually reach the compatibility wrapper.
Object.defineProperty(contentWindow, "createImageBitmap", {
configurable: true,
enumerable: true,
writable: true,
value: extensionCreateImageBitmap,
});
} catch (e) {
try {
contentWindow.createImageBitmap = extensionCreateImageBitmap;
} catch (e2) {}
}
} }
Schemas.exportLazyGetter(contentWindow, "browser", () => { Schemas.exportLazyGetter(contentWindow, "browser", () => {