1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-27 16:10:57 -05:00
denoland-deno/tools/wpt/testharnessreport.js
Colin Ihrig 367e006e06
fix(ext/web): add EventTarget brand checking (#14637)
This commit adds brand checking to EventTarget. It also fixes a
bug where deno would crash if an abort signal was aborted on the
global addEventListener().
2022-06-17 11:05:02 -04:00

29 lines
1 KiB
JavaScript

// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
window.add_result_callback(({ message, name, stack, status }) => {
const data = new TextEncoder().encode(
`${JSON.stringify({ name, status, message, stack })}\n`,
);
let bytesWritten = 0;
while (bytesWritten < data.byteLength) {
bytesWritten += Deno.stderr.writeSync(data.subarray(bytesWritten));
}
});
window.add_completion_callback((_tests, harnessStatus) => {
const data = new TextEncoder().encode(
`#$#$#${JSON.stringify(harnessStatus)}\n`,
);
let bytesWritten = 0;
while (bytesWritten < data.byteLength) {
bytesWritten += Deno.stderr.writeSync(data.subarray(bytesWritten));
}
// TODO(cjihrig): Restore the prototype of globalThis to be an EventTarget
// again. There are WPTs that change the prototype, which causes brand
// checking to fail. Once the globalThis prototype is frozen properly, this
// line can be removed.
Object.setPrototypeOf(globalThis, EventTarget.prototype);
Deno.exit(harnessStatus.status === 0 ? 0 : 1);
});