MCPcopy Create free account
hub / github.com/ColmapView/Colmapview.github.io / installCanvasToBlob

Function installCanvasToBlob

src/hooks/useFrustumTexture.test.ts:241–253  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

239}
240
241function installCanvasToBlob(): () => void {
242 const originalToBlob = Object.getOwnPropertyDescriptor(HTMLCanvasElement.prototype, 'toBlob');
243 Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', {
244 configurable: true,
245 value: (callback: BlobCallback) => {
246 callback(new Blob(['png'], { type: 'image/png' }));
247 },
248 });
249
250 return () => {
251 restoreProperty(HTMLCanvasElement.prototype, 'toBlob', originalToBlob);
252 };
253}
254
255function installCanvasContext(): () => void {
256 const originalGetContext = Object.getOwnPropertyDescriptor(HTMLCanvasElement.prototype, 'getContext');

Callers 1

Calls 1

restorePropertyFunction · 0.85

Tested by

no test coverage detected