-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Internal CC machinary for unhandled promise rejection. 2. Simplisitic implimentation in ch 3. Test case
- Loading branch information
Showing
16 changed files
with
258 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,3 +60,5 @@ JsLessThan | |
JsLessThanOrEqual | ||
|
||
JsCreateEnhancedFunction | ||
|
||
JsSetHostPromiseRejectionTracker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Executing test #1 - Reject promise with no reactions. | ||
Uncaught promise rejection | ||
Executing test #2 - Reject promise with a catch reaction only. | ||
Executing test #3 - Reject promise with catch and then reactions. | ||
Executing test #4 - Reject promise then add a catch afterwards. | ||
Uncaught promise rejection | ||
Promise rejection handled | ||
Executing test #5 - Reject promise then add two catches afterwards. | ||
Uncaught promise rejection | ||
Promise rejection handled | ||
Executing test #6 - Async function that throws. | ||
Uncaught promise rejection | ||
Executing test #7 - Async function that throws but is caught. | ||
Uncaught promise rejection | ||
Promise rejection handled | ||
Executing test #8 - Async function that awaits a function that throws. | ||
Uncaught promise rejection | ||
Promise rejection handled | ||
Uncaught promise rejection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
//------------------------------------------------------------------------------------------------------- | ||
// Copyright (C) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. | ||
//------------------------------------------------------------------------------------------------------- | ||
|
||
// Test HostPromiseRejectionTracker - see ecma262 section 25.4.1.9 | ||
|
||
let tests = [ | ||
{ | ||
name: "Reject promise with no reactions.", | ||
body: function(index) | ||
{ | ||
let controller; | ||
let promise = new Promise((resolve, reject)=>{ | ||
controller = {resolve, reject}; | ||
}); | ||
controller.reject();//Should notify rejected | ||
} | ||
}, | ||
{ | ||
name: "Reject promise with a catch reaction only.", | ||
body: function(index) | ||
{ | ||
let controller; | ||
let promise = new Promise((resolve, reject)=>{ | ||
controller = {resolve, reject}; | ||
}).catch(()=>{}); | ||
controller.reject();//Should NOT notify | ||
} | ||
}, | ||
{ | ||
name: "Reject promise with catch and then reactions.", | ||
body: function(index) | ||
{ | ||
let controller; | ||
let promise = new Promise((resolve, reject)=>{ | ||
controller = {resolve, reject}; | ||
}).then(()=>{}).catch(()=>{}); | ||
controller.reject();//Should NOT notify | ||
} | ||
}, | ||
{ | ||
name: "Reject promise then add a catch afterwards.", | ||
body: function(index) | ||
{ | ||
let controller; | ||
let promise = new Promise((resolve, reject)=>{ | ||
controller = {resolve, reject}; | ||
}); | ||
controller.reject();//Should notify rejected | ||
promise.catch(()=>{});//Should notify handled | ||
} | ||
}, | ||
{ | ||
name: "Reject promise then add two catches afterwards.", | ||
body: function(index) | ||
{ | ||
let controller; | ||
let promise = new Promise((resolve, reject)=>{ | ||
controller = {resolve, reject}; | ||
}); | ||
controller.reject();//Should notify rejected | ||
promise.catch(()=>{});//Should notify handled | ||
promise.catch(()=>{});//Should NOT notify | ||
} | ||
}, | ||
{ | ||
name: "Async function that throws.", | ||
body: function(index) | ||
{ | ||
async function aFunction() | ||
{ | ||
throw "throwing"; | ||
} | ||
aFunction();//Should notify rejected | ||
} | ||
}, | ||
{ | ||
name: "Async function that throws but is caught.", | ||
body: function(index) | ||
{ | ||
async function aFunction() | ||
{ | ||
throw "throwing"; | ||
} | ||
aFunction().catch(()=>{});//Should notify rejected AND then handled | ||
} | ||
}, | ||
{ | ||
name: "Async function that awaits a function that throws.", | ||
body: function(index) | ||
{ | ||
async function aFunction() | ||
{ | ||
throw "throwing";//Should notify rejected | ||
} | ||
async function bFunction() | ||
{ | ||
await aFunction();//Should notify handled | ||
} | ||
bFunction();//Should notify rejected | ||
} | ||
} | ||
]; | ||
|
||
for(let i = 0; i < tests.length; ++i) | ||
{ | ||
WScript.Echo('Executing test #' + (i + 1) + ' - ' + tests[i].name); | ||
tests[i].body(i+1); | ||
} |
Oops, something went wrong.