blob: 771365d6d7ce1f9d6496206dc0b2cb3cc0c8f463 [file] [log] [blame]
importScripts('../../resources/js-test-pre.js');
description('Test unhandled promise rejection event.');
var global = this;
global.jsTestIsAsync = true;
global.error = null;
global.promise = [];
global.count = 0;
global.index = 0;
global.onunhandledrejection = function (e) {
error = e;
index = count++;
shouldBe(`error.type`, `"unhandledrejection"`);
shouldBe(`error.cancelable`, `true`);
shouldBe(`error.promise`, `promise[${index}]`);
shouldBe(`error.reason`, `${index}`);
if (count === 3)
finishJSTest();
return false;
};
for (let i = 0; i < 3; ++i)
global.promise[i] = Promise.reject(i);