Skip to content

Commit

Permalink
adding additional test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Kaufman committed Jun 22, 2018
1 parent 7d0c4c2 commit ccebe54
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/Runtime/Library/JavascriptPromise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ namespace Js
stack.Push(this);
visited.Add(this, 1);

while (!stack.Empty())
while (!willBeUnhandled && !stack.Empty())
{
JavascriptPromise * curr = stack.Pop();
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,41 @@ function handledPromiseRejection8_bugbug() {
}
handledPromiseRejection8_bugbug();

function noRejection9() {
//
// In the case below, we're resolving a promise with a promise.
// Ultimately, the rejections is handled, but according to
// ES standard, the resolve of promiseA with promiseB gets
// pushed on the task queue, therefore, at the time the exception
// is raised, promiseB hasn't been "then'd".
//
// There are two ways to address this:
// 1. Change the ResolveThenable task to run immediately vs runing in task queue (this would be in violation of the spec)
// 2. Keep a list of the pending resolve-thenable tasks.
//
function handledPromiseRejection9_bugbug() {
function f1() {
let promiseA = new Promise((resolveA, rejectA) => {
let promiseB = Promise.resolve(true).then(() => {
throw new Error('error for handledPromiseRejection9_bugbug');
});
resolveA(promiseB);
});
return promiseA;
}

f1().catch((e) => {
});
}
handledPromiseRejection9_bugbug();


function noRejection10() {
let p = Promise.resolve(true)
.then(() => {
try {
throw new Error('error for noRejection9');
throw new Error('error for noRejection10');
} catch (err) {
}
});
}
noRejection9();
noRejection10();
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@
}
]
},
{
"callStack": [
{
"line": 112,
"column": 16,
"sourceText": "throw new Error('error for handledPromiseRejection9_bugbug')",
"function": "Anonymous function"
}
]
},
{
"callStack": [
{
Expand Down

0 comments on commit ccebe54

Please sign in to comment.