onnxruntime/js/web/test/e2e/browser-test-webgl.js
Nanashi ca465dc087
[js] Make error friendly when isOrtFormat is undefined (#19958)
### Description
Make error friendly when isOrtFormat is undefined
(`onnxruntime.InferenceSession.create` is called with ArrayBuffer or
Uint8Array).

### Motivation and Context
I was trying to run my onnx model in WebGL EP, but it gave me the error
"Cannot read properties of null (reading 'irVersion')".
I used debugger to find that actual error is `int64 is not supported`,
but the error was invisible for me.
So I made it to show both error when isOrtFormat is undefined.
<s>I haven't written unit test yet, so I'm making it draft. (I have no
idea about how do I test this though...)</s>
[d62d942](d62d9425ba)
2024-03-27 02:07:00 -07:00

21 lines
610 B
JavaScript

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
it('Browser E2E testing - WebGL backend', async function() {
await testFunction(ort, {executionProviders: ['webgl']});
});
it('Browser E2E testing - invalid buffer', async () => {
try {
await ort.InferenceSession.create(
new Uint8Array(Array.from({length: 100}, () => 42)), {executionProviders: ['webgl']});
// Should not reach here.
assert(false);
} catch (e) {
assert(e.message.includes('as ONNX format'));
assert(e.message.includes('as ORT format'));
}
});