Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[js/web] a bugfix and add tests for wasm proxy worker #9048

Merged
merged 2 commits into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/web/lib/wasm/proxy-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
10 changes: 10 additions & 0 deletions js/web/test/e2e/browser-test-wasm-no-threads-proxy.js
Original file line number Diff line number Diff line change
@@ -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 changes: 9 additions & 0 deletions js/web/test/e2e/browser-test-wasm-proxy.js
Original file line number Diff line number Diff line change
@@ -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'] });
});
2 changes: 1 addition & 1 deletion js/web/test/e2e/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
2 changes: 2 additions & 0 deletions js/web/test/e2e/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down