qt5base-lts/util/wasm/batchedtestrunner/util.js
Mikolaj Boc ad1980cd43 Create a driver for running batched tests on WASM
A driver application has been prepared in js for running batched tests.
There is a convenient public API defined for reading the current test
status & subscribing to changes thereof.
The solution is modular - the module qwasmjsruntime can be used for any
wasm instantiation, e.g. in the next iteration of qtloader.

Change-Id: I00df88188c46a42f86d431285ca96d60d89b3f05
Pick-to: 6.4
Reviewed-by: David Skoland <david.skoland@qt.io>
2022-08-24 19:08:58 +02:00

32 lines
901 B
JavaScript

// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
export function parseQuery() {
const trimmed = window.location.search.substring(1);
return new Map(
trimmed.length === 0 ?
[] :
trimmed.split('&').map(paramNameAndValue => {
const [name, value] = paramNameAndValue.split('=');
return [decodeURIComponent(name), value ? decodeURIComponent(value) : ''];
}));
}
export class EventSource {
#listeners = [];
constructor(receivePrivateInterface) {
receivePrivateInterface({
fireEvent: (arg0, arg1) => this.#fireEvent(arg0, arg1)
});
}
addEventListener(listener) {
this.#listeners.push(listener);
}
#fireEvent(arg0, arg1) {
this.#listeners.forEach(listener => listener(arg0, arg1));
}
}