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

Function installCanvasContext

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

Source from the content-addressed store, hash-verified

253}
254
255function installCanvasContext(): () => void {
256 const originalGetContext = Object.getOwnPropertyDescriptor(HTMLCanvasElement.prototype, 'getContext');
257 Object.defineProperty(HTMLCanvasElement.prototype, 'getContext', {
258 configurable: true,
259 value: vi.fn(() => ({
260 drawImage: vi.fn(),
261 })),
262 });
263
264 return () => {
265 restoreProperty(HTMLCanvasElement.prototype, 'getContext', originalGetContext);
266 };
267}
268
269function installObjectUrls(): () => void {
270 const originalCreateObjectUrl = Object.getOwnPropertyDescriptor(URL, 'createObjectURL');

Callers 1

Calls 1

restorePropertyFunction · 0.85

Tested by

no test coverage detected