Truly independent web browser
<!DOCTYPE html>
<script src="include.js"></script>
<script>
asyncTest(async done => {
const events = [];
window.addEventListener("unhandledrejection", event => {
event.preventDefault();
events.push(`unhandledrejection: ${event.reason}`);
});
window.addEventListener("rejectionhandled", event => {
events.push(`rejectionhandled: ${event.reason}`);
});
// NB: Only the property of the holder refers to the promise, so a collection that moves cells moves it while
// it is in the outstanding rejected promises weak set.
const holder = { promise: Promise.reject("moved") };
await waitForCondition(() => events.length === 1);
await internals.gcAsync(true);
holder.promise.catch(() => {});
await waitForCondition(() => events.length === 2);
events.forEach(println);
done();
});
</script>