2022-10-12 18:54:28 +03:00
|
|
|
<!doctype html>
|
|
|
|
<html lang="en-us">
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
|
<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">
|
|
|
|
<link rel="stylesheet" href="../common/emscripten.css"/>
|
|
|
|
<link rel="stylesheet" href="../common/testing.css"/>
|
2022-11-19 19:16:40 +03:00
|
|
|
<title>sqlite3 tester #1: Worker thread</title>
|
2022-10-12 18:54:28 +03:00
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
font-family: monospace;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
2022-11-19 19:16:40 +03:00
|
|
|
<h1 id='color-target'>sqlite3 tester #1: Worker thread</h1>
|
2022-10-21 09:58:27 +03:00
|
|
|
<div>See <a href='tester1.html' target='tester1.html'>tester1.html</a>
|
|
|
|
for the UI-thread variant.</div>
|
|
|
|
<div class='input-wrapper'>
|
2022-10-25 11:15:57 +03:00
|
|
|
<input type='checkbox' id='cb-log-reverse'>
|
2022-10-21 09:58:27 +03:00
|
|
|
<label for='cb-log-reverse'>Reverse log order?</label>
|
|
|
|
</div>
|
2022-10-13 11:03:31 +03:00
|
|
|
<div id='test-output'></div>
|
2022-10-12 18:54:28 +03:00
|
|
|
<script>(function(){
|
2022-10-13 11:03:31 +03:00
|
|
|
const logTarget = document.querySelector('#test-output');
|
2022-10-12 18:54:28 +03:00
|
|
|
const logHtml = function(cssClass,...args){
|
|
|
|
const ln = document.createElement('div');
|
2022-10-21 09:26:17 +03:00
|
|
|
if(cssClass){
|
|
|
|
for(const c of (Array.isArray(cssClass) ? cssClass : [cssClass])){
|
|
|
|
ln.classList.add(c);
|
|
|
|
}
|
|
|
|
}
|
2022-10-12 18:54:28 +03:00
|
|
|
ln.append(document.createTextNode(args.join(' ')));
|
2022-10-13 11:03:31 +03:00
|
|
|
logTarget.append(ln);
|
2022-10-12 18:54:28 +03:00
|
|
|
};
|
2022-10-21 09:58:27 +03:00
|
|
|
const cbReverse = document.querySelector('#cb-log-reverse');
|
|
|
|
const cbReverseIt = ()=>{
|
|
|
|
logTarget.classList[cbReverse.checked ? 'add' : 'remove']('reverse');
|
|
|
|
};
|
|
|
|
cbReverse.addEventListener('change',cbReverseIt,true);
|
|
|
|
cbReverseIt();
|
2022-11-19 19:16:40 +03:00
|
|
|
const urlParams = new URL(self.location.href).searchParams;
|
|
|
|
const workerArgs = [];
|
|
|
|
if(urlParams.has('esm')){
|
|
|
|
logHtml('warning',"Attempting to run an ES6 Worker Module, "+
|
|
|
|
"which is not supported by all browsers! "+
|
|
|
|
"e.g. Firefox (as of 2022-11) cannot do this.");
|
|
|
|
workerArgs.push("tester1-esm.js",{type:"module"});
|
|
|
|
document.querySelectorAll('title,#color-target').forEach((e)=>{
|
|
|
|
e.innerText = "sqlite3 tester #1: ES6 Worker Module";
|
|
|
|
});
|
|
|
|
}else{
|
|
|
|
workerArgs.push("tester1.js?sqlite3.dir=jswasm");
|
|
|
|
}
|
|
|
|
const w = new Worker(...workerArgs);
|
2022-10-12 18:54:28 +03:00
|
|
|
w.onmessage = function({data}){
|
|
|
|
switch(data.type){
|
|
|
|
case 'log':
|
|
|
|
logHtml(data.payload.cssClass, ...data.payload.args);
|
|
|
|
break;
|
2022-11-01 10:49:49 +03:00
|
|
|
case 'error':
|
|
|
|
logHtml('error', ...data.payload.args);
|
|
|
|
break;
|
|
|
|
case 'test-result':
|
|
|
|
document.querySelector('#color-target').classList.add(
|
|
|
|
data.payload.pass ? 'tests-pass' : 'tests-fail'
|
|
|
|
);
|
|
|
|
break;
|
2022-10-12 18:54:28 +03:00
|
|
|
default:
|
|
|
|
logHtml('error',"Unhandled message:",data.type);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})();</script>
|
|
|
|
</body>
|
|
|
|
</html>
|