summaryrefslogtreecommitdiffstats
path: root/util/wasm/batchedtestrunner/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'util/wasm/batchedtestrunner/util.js')
-rw-r--r--util/wasm/batchedtestrunner/util.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/util/wasm/batchedtestrunner/util.js b/util/wasm/batchedtestrunner/util.js
new file mode 100644
index 0000000000..a297baf6b2
--- /dev/null
+++ b/util/wasm/batchedtestrunner/util.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+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));
+ }
+}