Skip to content

Commit

Permalink
Better fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyGu committed Jul 19, 2018
1 parent c796e4a commit 1c519a7
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
// second actually calls document.open() to test if the method call removes
// that specific task from the queue.

setup({
allow_uncaught_exception: true
});

function taskTest(description, testBody) {
async_test(t => {
const frame = document.body.appendChild(document.createElement("iframe"));
Expand Down Expand Up @@ -86,16 +90,20 @@ taskTest("MessagePort", (t, frame, open) => {
});

taskTest("Promise rejection", (t, frame, open) => {
// The frame.contentWindow.setTimeout is necessary to make the test work on
// Safari. See: https://bugs.webkit.org/show_bug.cgi?id=187822
frame.contentWindow.setTimeout(() => {
const promise = frame.contentWindow.eval("Promise.reject(42);");
open(frame.contentDocument);
frame.contentWindow.onunhandledrejection = t.step_func_done(ev => {
assert_equals(ev.promise, promise);
assert_equals(ev.reason, 42);
});
// There is currently some ambiguity on which Window object the
// unhandledrejection event should be fired on. Here, let's account for that
// ambiguity and allow event fired on _any_ global to pass this test.
// See:
// - https://github.com/whatwg/html/issues/958,
// - https://bugs.webkit.org/show_bug.cgi?id=187822
const promise = frame.contentWindow.eval("Promise.reject(42);");
open(frame.contentDocument);
const listener = t.step_func_done(ev => {
assert_equals(ev.promise, promise);
assert_equals(ev.reason, 42);
});
frame.contentWindow.onunhandledrejection = listener;
window.onunhandledrejection = listener;
});

taskTest("marquee start", (t, frame, open) => {
Expand Down

0 comments on commit 1c519a7

Please sign in to comment.