5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8">
6 <link rel=
"shortcut icon" href=
"data:image/x-icon;," type=
"image/x-icon">
7 <link rel=
"stylesheet" href=
"../common/emscripten.css"/>
8 <link rel=
"stylesheet" href=
"../common/testing.css"/>
9 <title>sqlite3 tester #
1: Worker thread
</title>
13 <h1 id='color-target'
>sqlite3 tester #
1: Worker thread
</h1>
15 <a href='tester1.html' target='tester1.html'
>conventional UI thread
</a>,
16 <a href='tester1-worker.html' target='tester1-worker.html'
>conventional worker
</a>,
17 <a href='tester1-esm.html' target='tester1-esm.html'
>ESM in UI thread
</a>,
18 <a href='tester1-worker.html?esm' target='tester1-worker.html?esm'
>ESM worker
</a>
20 <div class='input-wrapper'
>
21 <input type='checkbox' id='cb-log-reverse'
>
22 <label for='cb-log-reverse'
>Reverse log order?
</label>
24 <div id='test-output'
></div>
26 const logTarget
= document
.querySelector('#test-output');
27 const logHtml = function(cssClass
,...args
){
28 const ln
= document
.createElement('div');
30 for(const c
of (Array
.isArray(cssClass
) ? cssClass
: [cssClass
])){
34 ln
.append(document
.createTextNode(args
.join(' ')));
37 const cbReverse
= document
.querySelector('#cb-log-reverse');
38 const cbReverseIt
= ()=>{
39 logTarget
.classList
[cbReverse
.checked
? 'add' : 'remove']('reverse');
41 cbReverse
.addEventListener('change',cbReverseIt
,true);
43 const urlParams
= new URL(self
.location
.href
).searchParams
;
44 const workerArgs
= [];
45 if(urlParams
.has('esm')){
46 logHtml('warning',"Attempting to run an ES6 Worker Module, "+
47 "which is not supported by all browsers! "+
48 "e.g. Firefox (as of 2023-05) cannot do this.");
49 workerArgs
.push("tester1.mjs",{type
:"module"});
50 document
.querySelectorAll('title,#color-target').forEach((e
)=>{
51 e
.innerText
= "sqlite3 tester #1: ES6 Worker Module";
54 workerArgs
.push("tester1.js?sqlite3.dir=jswasm");
56 const w
= new Worker(...workerArgs
);
57 w
.onmessage = function({data
}){
60 logHtml(data
.payload
.cssClass
, ...data
.payload
.args
);
63 logHtml('error', ...data
.payload
.args
);
66 document
.querySelector('#color-target').classList
.add(
67 data
.payload
.pass
? 'tests-pass' : 'tests-fail'
69 const e
= document
.querySelector('title');
71 data
.payload
.pass
? 'PASS' : 'FAIL'
72 ) + ': ' + e
.innerText
;
76 logHtml('error',"Unhandled message:",data
.type
);