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;
let extensionCreateImageBitmap = function(...args) {
if (args.length == 0) {
return contentWindow.Promise.resolve(null);
}
return nativeCreateImageBitmap.apply(this, args);
};
try { try {
contentWindow.createImageBitmap = function(...args) { // Window.createImageBitmap is inherited from a WebIDL prototype in
if (args.length == 0) { // older UXP builds. Assignment can therefore leave the native
return contentWindow.Promise.resolve(null); // method in place; define an own property so extension feature probes
} // actually reach the compatibility wrapper.
return nativeCreateImageBitmap.apply(this, args); Object.defineProperty(contentWindow, "createImageBitmap", {
}; configurable: true,
} catch (e) {} enumerable: true,
writable: true,
value: extensionCreateImageBitmap,
});
} catch (e) {
try {
contentWindow.createImageBitmap = extensionCreateImageBitmap;
} catch (e2) {}
}
} }
Schemas.exportLazyGetter(contentWindow, "browser", () => { Schemas.exportLazyGetter(contentWindow, "browser", () => {