mirror of
https://github.com/greggman/twgl.js.git
synced 2025-12-08 19:26:07 +00:00
82 lines
2.2 KiB
HTML
82 lines
2.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>TWGL Tests</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="stylesheet" href="mocha.css">
|
|
<style>
|
|
#mocha #other {
|
|
text-decoration: underline;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="timeout" style="display: none; color: red;">
|
|
warning: timeout = 0
|
|
</div>
|
|
<div id="mocha">
|
|
</div>
|
|
<script>
|
|
// this is here for puppeteer. It's resolved in index.js
|
|
// so we can await on window.testPromiseInfo
|
|
function makePromise() {
|
|
const info = {};
|
|
const promise = new Promise((resolve, reject) => {
|
|
Object.assign(info, {resolve, reject});
|
|
});
|
|
info.promise = promise;
|
|
return info;
|
|
}
|
|
|
|
window.testsPromiseInfo = makePromise();
|
|
</script>
|
|
<script src="mocha.js"></script>
|
|
<script type="module">
|
|
/* global document */
|
|
/* global mocha */
|
|
/* global URLSearchParams */
|
|
/* global window */
|
|
import {setConfig} from './assert.js';
|
|
|
|
async function main() {
|
|
mocha.setup('bdd');
|
|
mocha.fullTrace();
|
|
const query = Object.fromEntries(new URLSearchParams(window.location.search).entries());
|
|
let timeout = query.src ? 0 : 1000;
|
|
if (query.timeout !== undefined) {
|
|
timeout = parseInt(query.timeout);
|
|
}
|
|
if (timeout === 0) {
|
|
document.querySelector('#timeout').style.display = '';
|
|
}
|
|
mocha.timeout(timeout);
|
|
const lint = query.lint !== 'false';
|
|
const throwOnError = !query.warn;
|
|
|
|
const src = query.src ? '../src/twgl-full.js' : '../dist/7.x/twgl-full.module.js';
|
|
|
|
try {
|
|
window.twgl = await import(src);
|
|
loadScript('index.js', 'module');
|
|
} catch (e) {
|
|
console.error(e);
|
|
}
|
|
}
|
|
|
|
function loadScript(url, type = 'text/javascript') {
|
|
return new Promise((resolve, reject) => {
|
|
const script = document.createElement('script');
|
|
script.onload = resolve;
|
|
script.onerror = reject;
|
|
script.type = type;
|
|
script.src = url;
|
|
document.head.appendChild(script);
|
|
});
|
|
}
|
|
|
|
main();
|
|
</script>
|
|
</body>
|
|
</html>
|