onnxruntime/js/web/test/e2e/browser-test-wasm-binary-override.js
Yulong Wang 50b38ca9d5
[js/web] update default export to include webgpu (#22754)
### Description

This PR changes the following exports:
- `onnxruntime-web` now is same to `onnxruntime-web/webgpu`.
- `onnxruntime-web/webgpu` is deprecating.

### Migration instructions:
- use `onnxruntime-web` instead of `onnxruntime-web/webgpu`.
- use `onnxruntime-web/wasm` if want to use onnxruntime-web without
webgpu/webnn.

### Export table

| file name | export entry | includes WASM | includes JSEP (WebGPU &
WebNN) | includes WebGL
| ------------- | ------------- | ----- | ----- | -----
| ort.all.min.js<br/>ort.all.js<br/>ort.all.min.mjs<br/>ort.all.mjs |
`onnxruntime-web/all` | ✔️| ✔️| ✔️
| ort.min.js<br/>ort.js<br/>ort.min.mjs<br/>ort.mjs | `onnxruntime-web`
| ✔️|  --> ✔️| ✔️ -->
|
ort.webgpu.min.js<br/>ort.webgpu.js<br/>ort.webgpu.min.mjs<br/>ort.webgpu.mjs
| `onnxruntime-web/webgpu` | ✔️ | ✔️ |
| ort.wasm.min.js<br/>ort.wasm.js<br/>ort.wasm.min.mjs<br/>ort.wasm.mjs
| `onnxruntime-web/wasm` | ✔️ |  |
2024-12-04 09:46:45 -08:00

22 lines
742 B
JavaScript

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
const documentUrl = document.currentScript.src;
it('Browser E2E testing - WebAssembly backend', async function () {
// preload .wasm file binary
const wasmUrl = new URL('./node_modules/onnxruntime-web/dist/ort-wasm-simd-threaded.jsep.wasm', documentUrl).href;
const response = await fetch(wasmUrl);
// make sure the .wasm file is loaded successfully
assert(response.ok);
assert(response.headers.get('Content-Type') === 'application/wasm');
// override wasm binary
const binary = await response.arrayBuffer();
ort.env.wasm.wasmBinary = binary;
await testFunction(ort, { executionProviders: ['wasm'] });
});