Migrate some tests to the new htmlRunner

Fix events.get_timeStamp (was events.get_timestamp, wrong casing).

Rename `newRunner` to `htmlRunner`.

move tests to src/tests (from src/browser/tests). src/runtime and possibly other
parts might want to have html tests too.
This commit is contained in:
Karl Seguin
2025-09-02 10:38:27 +08:00
parent e486f28a41
commit 81766c8517
22 changed files with 317 additions and 300 deletions

View File

@@ -0,0 +1,17 @@
<script src="../testing.js"></script>
<script id=decoder>
let d1 = new TextDecoder();
testing.expectEqual('utf-8', d1.encoding);
testing.expectEqual(false, d1.fatal);
testing.expectEqual(false, d1.ignoreBOM);
testing.expectEqual('𠮷', d1.decode(new Uint8Array([240, 160, 174, 183])));
testing.expectEqual('𠮷', d1.decode(new Uint8Array([0xEF, 0xBB, 0xBF, 240, 160, 174, 183])));
testing.expectEqual('<27>2', d1.decode(new Uint8Array([249, 50])));
let d2 = new TextDecoder('utf8', {fatal: true})
testing.expectError('Error: InvalidUtf8', () => {
let data = new Uint8Array([240, 240, 160, 174, 183]);
d2.decode(data);
});
</script>

View File

@@ -0,0 +1,13 @@
<script src="../testing.js"></script>
<script id=encoder>
var encoder = new TextEncoder();
testing.expectEqual('utf-8', encoder.encoding);
testing.expectEqual([226, 130, 172], Array.from(encoder.encode('€')));
// Invalid utf-8 sequence.
// Browsers give a different result for this, they decode it to:
// 50, 50, 54, 44, 52, 48, 44, 49, 54, 49
testing.expectError('Error: InvalidUtf8', () => {
encoder.encode(new Uint8Array([0xE2,0x28,0xA1]));
});
</script>