mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-10 17:37:14 +00:00
[js/web] a bugfix and add tests for wasm proxy worker (#9048)
* [js/web] add tests for wasm proxy worker * fix script src override
This commit is contained in:
parent
e574be4a53
commit
be80698698
6 changed files with 29 additions and 4 deletions
|
|
@ -79,7 +79,7 @@ const onProxyWorkerMessage = (ev: MessageEvent<OrtWasmMessage>): void => {
|
|||
}
|
||||
};
|
||||
|
||||
const scriptSrc = isProxy() ? (document?.currentScript as HTMLScriptElement)?.src : undefined;
|
||||
const scriptSrc = typeof document !== 'undefined' ? (document?.currentScript as HTMLScriptElement)?.src : undefined;
|
||||
|
||||
export const initWasm = async(): Promise<void> => {
|
||||
if (isProxy()) {
|
||||
|
|
|
|||
10
js/web/test/e2e/browser-test-wasm-no-threads-proxy.js
Normal file
10
js/web/test/e2e/browser-test-wasm-no-threads-proxy.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
'use strict';
|
||||
|
||||
it('Browser E2E testing - WebAssembly backend (no threads, proxy)', async function () {
|
||||
ort.env.wasm.numThreads = 1;
|
||||
ort.env.wasm.proxy = true;
|
||||
await testFunction(ort, { executionProviders: ['wasm'] });
|
||||
});
|
||||
9
js/web/test/e2e/browser-test-wasm-proxy.js
Normal file
9
js/web/test/e2e/browser-test-wasm-proxy.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
'use strict';
|
||||
|
||||
it('Browser E2E testing - WebAssembly backend (proxy)', async function () {
|
||||
ort.env.wasm.proxy = true;
|
||||
await testFunction(ort, { executionProviders: ['wasm'] });
|
||||
});
|
||||
|
|
@ -19,7 +19,7 @@ module.exports = function (config) {
|
|||
config.set({
|
||||
frameworks: ['mocha'],
|
||||
files: [
|
||||
{ pattern: distPrefix + 'ort.js' },
|
||||
{ pattern: distPrefix + 'ort.min.js' },
|
||||
{ pattern: './common.js' },
|
||||
{ pattern: TEST_MAIN },
|
||||
{ pattern: './node_modules/onnxruntime-web/dist/*.wasm', included: false, nocache: true },
|
||||
|
|
|
|||
|
|
@ -86,6 +86,8 @@ async function testAllBrowserCases({ hostInKarma }) {
|
|||
await runKarma({ hostInKarma, main: './browser-test-webgl.js', browser: 'Chrome_default' });
|
||||
await runKarma({ hostInKarma, main: './browser-test-wasm.js', browser: 'Chrome_default' });
|
||||
await runKarma({ hostInKarma, main: './browser-test-wasm-no-threads.js', browser: 'Chrome_default' });
|
||||
await runKarma({ hostInKarma, main: './browser-test-wasm-proxy.js', browser: 'Chrome_default' });
|
||||
await runKarma({ hostInKarma, main: './browser-test-wasm-no-threads-proxy.js', browser: 'Chrome_default' });
|
||||
await runKarma({ hostInKarma, main: './browser-test-wasm-path-override-filename.js', browser: 'Chrome_default' });
|
||||
await runKarma({ hostInKarma, main: './browser-test-wasm-path-override-prefix.js', browser: 'Chrome_default' });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,11 +217,15 @@ jobs:
|
|||
- script: |
|
||||
npm test
|
||||
workingDirectory: '$(Build.SourcesDirectory)\js\web'
|
||||
displayName: 'Run ort-web tests - unpacked mode'
|
||||
displayName: 'Run ort-web tests'
|
||||
- script: |
|
||||
npm test -- --webgl-texture-pack-mode -b=webgl
|
||||
workingDirectory: '$(Build.SourcesDirectory)\js\web'
|
||||
displayName: 'Run ort-web tests - packed mode'
|
||||
displayName: 'Run ort-web tests - WebGL: packed mode'
|
||||
- script: |
|
||||
npm test -- --wasm-enable-proxy -b=wasm
|
||||
workingDirectory: '$(Build.SourcesDirectory)\js\web'
|
||||
displayName: 'Run ort-web tests - WebAssembly: proxy'
|
||||
- script: |
|
||||
npm pack
|
||||
workingDirectory: '$(Build.SourcesDirectory)\js\common'
|
||||
|
|
|
|||
Loading…
Reference in a new issue