Allow users to pass canvas: undefined
PiperOrigin-RevId: 520142520
This commit is contained in:
parent
bda2639376
commit
62d86494b0
|
@ -118,9 +118,10 @@ describe('TaskRunner', () => {
|
|||
|
||||
let fetchSpy: jasmine.Spy;
|
||||
let taskRunner: TaskRunnerFake;
|
||||
let fetchStatus = 200;
|
||||
let fetchStatus: number;
|
||||
|
||||
beforeEach(() => {
|
||||
fetchStatus = 200;
|
||||
fetchSpy = jasmine.createSpy().and.callFake(async url => {
|
||||
return {
|
||||
arrayBuffer: () => mockBytes.buffer,
|
||||
|
|
|
@ -185,6 +185,23 @@ describe('VisionTaskRunner', () => {
|
|||
}).toThrowError(/You must create a new task to reset the canvas./);
|
||||
});
|
||||
|
||||
it('validates that an undefined canvas leaves the graph unmodified',
|
||||
async () => {
|
||||
if (typeof OffscreenCanvas === 'undefined') {
|
||||
console.log('Test is not supported under Node.');
|
||||
return;
|
||||
}
|
||||
|
||||
const visionTaskRunner = new VisionTaskRunnerFake();
|
||||
const canvas = new OffscreenCanvas(1, 1);
|
||||
visionTaskRunner.graphRunner.wasmModule.canvas = canvas;
|
||||
|
||||
await visionTaskRunner.setOptions({canvas});
|
||||
await visionTaskRunner.setOptions({canvas: undefined});
|
||||
|
||||
expect(visionTaskRunner.graphRunner.wasmModule.canvas).toBe(canvas);
|
||||
});
|
||||
|
||||
it('sends packets to graph', async () => {
|
||||
const visionTaskRunner = new VisionTaskRunnerFake();
|
||||
await visionTaskRunner.setOptions({runningMode: 'VIDEO'});
|
||||
|
|
|
@ -89,7 +89,7 @@ export abstract class VisionTaskRunner extends TaskRunner {
|
|||
this.baseOptions.setUseStreamMode(useStreamMode);
|
||||
}
|
||||
|
||||
if ('canvas' in options) {
|
||||
if (options.canvas !== undefined) {
|
||||
if (this.graphRunner.wasmModule.canvas !== options.canvas) {
|
||||
throw new Error('You must create a new task to reset the canvas.');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user