aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/common/SqliteTestUtil.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2022-09-09 04:50:18 +0000
committerstephan <stephan@noemail.net>2022-09-09 04:50:18 +0000
commite66b26818b3a6347dd395df4db568b92f9fe662e (patch)
treed081bdf50b051927f41c008726937fd505bc28b1 /ext/wasm/common/SqliteTestUtil.js
parentdd628ed58bb29e2f83325c8913e8b97f78eccc4f (diff)
downloadsqlite-e66b26818b3a6347dd395df4db568b92f9fe662e.tar.gz
sqlite-e66b26818b3a6347dd395df4db568b92f9fe662e.zip
speedtest1 wasm: add a link in the worker variant which launches the main-thread variant with the selected CLI flags. Append collected stdout/stderr to the main-thread page after execution is finished to avoid having to open the dev tools (which inexplicably slows down wasm execution).
FossilOrigin-Name: 02709ee2beab36d144b807fd9ffaee639e3c1bdd1908a34e05f3fd23dad2ef66
Diffstat (limited to 'ext/wasm/common/SqliteTestUtil.js')
-rw-r--r--ext/wasm/common/SqliteTestUtil.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/ext/wasm/common/SqliteTestUtil.js b/ext/wasm/common/SqliteTestUtil.js
index 51cd64108..779f271fb 100644
--- a/ext/wasm/common/SqliteTestUtil.js
+++ b/ext/wasm/common/SqliteTestUtil.js
@@ -113,6 +113,46 @@
++this.counter;
if(!this.toBool(expr)) throw new Error(msg || "throwUnless() failed");
return this;
+ },
+
+ /**
+ Parses window.location.search-style string into an object
+ containing key/value pairs of URL arguments (already
+ urldecoded). The object is created using Object.create(null),
+ so contains only parsed-out properties and has no prototype
+ (and thus no inherited properties).
+
+ If the str argument is not passed (arguments.length==0) then
+ window.location.search.substring(1) is used by default. If
+ neither str is passed in nor window exists then false is returned.
+
+ On success it returns an Object containing the key/value pairs
+ parsed from the string. Keys which have no value are treated
+ has having the boolean true value.
+
+ Pedantic licensing note: this code has appeared in other source
+ trees, but was originally written by the same person who pasted
+ it into those trees.
+ */
+ processUrlArgs: function(str) {
+ if( 0 === arguments.length ) {
+ if( ('undefined' === typeof window) ||
+ !window.location ||
+ !window.location.search ) return false;
+ else str = (''+window.location.search).substring(1);
+ }
+ if( ! str ) return false;
+ str = (''+str).split(/#/,2)[0]; // remove #... to avoid it being added as part of the last value.
+ const args = Object.create(null);
+ const sp = str.split(/&+/);
+ const rx = /^([^=]+)(=(.+))?/;
+ var i, m;
+ for( i in sp ) {
+ m = rx.exec( sp[i] );
+ if( ! m ) continue;
+ args[decodeURIComponent(m[1])] = (m[3] ? decodeURIComponent(m[3]) : true);
+ }
+ return args;
}
};