Merge pull request #13408 from keymanapp/test/web/core-stresstest

test(web): add stress-test page for loading KMX keyboard from blob 🎼
This commit is contained in:
Eberhard Beilharz 2025-03-17 16:03:48 +01:00 • committed by GitHub
commit 8124cd6b6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 78 additions and 0 deletions

View file

@ -0,0 +1,9 @@
export async function loadKeyboardBlob(uri) {
const response = await fetch(uri);
if (!response.ok) {
throw new Error(`HTTP ${response.status} ${response.statusText}`);
}
const buffer = await response.arrayBuffer();
return new Uint8Array(buffer);
}

View file

@ -0,0 +1 @@
export const CORE_WASM = '../../../../../build/engine/core-processor/obj/import/core';

View file

@ -0,0 +1,65 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<!-- Set the viewport width to match phone and tablet device widths -->
<meta name="viewport" content="width=device-width,user-scalable=no" />
<title>KeymanWeb Core Stress Test</title>
<!--
Import map defines where we can find KeymanWeb compiled modules; this must
be specified inline.
-->
<script type="importmap">
{
"imports": {
"keyman/": "../../../../../build/"
}
}
</script>
<script module="es6" type="module">
import { KM_Core } from 'keyman/engine/core-processor/lib/index.mjs';
import { CORE_WASM } from './paths.js';
import { loadKeyboardBlob } from './load-keyboard-blob.js';
let intervalId = null;
function stress() {
if (intervalId) {
window.clearInterval(intervalId);
intervalId = null;
console.log('Stopping stress');
return;
}
intervalId = window.setInterval(doStress, 10);
}
async function doStress() {
console.log('Starting to stress');
const km_core = await KM_Core.createCoreProcessor(CORE_WASM);
const blob = await loadKeyboardBlob('./test_8568_deadkeys.kmx')
const result = km_core.keyboard_load_from_blob('test', blob);
result.delete();
}
window.addEventListener('load', function () {
document.getElementById('stress').addEventListener('click', stress);
});
</script>
</head>
<body>
<h2>KeymanWeb Sample Page - Core Testing</h2>
<p>This page is designed to stress-test the loading a KMX keyboard from blob. It will repeatedly load a .kmx using the KM_Core loader.</p>
<p>Be sure to reference the developer console for additional feedback. </p>
<button id="stress">Stress Test</button>
<hr />
<h3><a href="../index.html">Return to testing home page</a></h3>
</body>
</html>

Binary file not shown.

View file

@ -45,6 +45,9 @@
<h2><a href="./issue62/index.html">Light test for touch-based MutationObserver functionality</a></h2>
<h2><a href="./issue63/index.html">Test/stress-test touch-based MutationObserver functionality</a></h2>
<h1>Keyman Core tests</h1>
<h2><a href="./core/stress.html">Stress-test kmx blob loader</a></h2>
<h1>Issue Testing</h1>
<h2><a href="./empty-row/index.html">Tests OSK handling of empty rows</a></h2>
<h2><a href="./keyboard-errors/index.html">Tests keyboard error-handling functionality</a></h2>