mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-16 16:28:58 +00:00
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:
17
src/tests/encoding/decoder.html
Normal file
17
src/tests/encoding/decoder.html
Normal 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>
|
||||
13
src/tests/encoding/encoder.html
Normal file
13
src/tests/encoding/encoder.html
Normal 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>
|
||||
Reference in New Issue
Block a user