| Index: third_party/WebKit/LayoutTests/inspector/sources/debugger-async/async-await/callstack.html
|
| diff --git a/third_party/WebKit/LayoutTests/inspector/sources/debugger-async/async-await/callstack.html b/third_party/WebKit/LayoutTests/inspector/sources/debugger-async/async-await/callstack.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e444eec3d5ba9203708a177a777edfb35e2f4ba0
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/inspector/sources/debugger-async/async-await/callstack.html
|
| @@ -0,0 +1,183 @@
|
| +<html>
|
| +<head>
|
| +<script src="../../../../http/tests/inspector/inspector-test.js"></script>
|
| +<script src="../../../../http/tests/inspector/debugger-test.js"></script>
|
| +<script>
|
| +
|
| +function timeoutPromise(value, ms)
|
| +{
|
| + return new Promise(function promiseCallback(resolve, reject) {
|
| + function resolvePromise()
|
| + {
|
| + resolve(value);
|
| + }
|
| + function rejectPromise()
|
| + {
|
| + reject(value);
|
| + }
|
| + if (value instanceof Error)
|
| + setTimeout(rejectPromise, ms || 0);
|
| + else
|
| + setTimeout(resolvePromise, ms || 0);
|
| + });
|
| +}
|
| +
|
| +function settledPromise(value)
|
| +{
|
| + function resolveCallback(resolve, reject)
|
| + {
|
| + resolve(value);
|
| + }
|
| + function rejectCallback(resolve, reject)
|
| + {
|
| + reject(value);
|
| + }
|
| + if (value instanceof Error)
|
| + return new Promise(rejectCallback);
|
| + else
|
| + return new Promise(resolveCallback);
|
| +}
|
| +
|
| +function testFunction()
|
| +{
|
| + setTimeout(testFunctionTimeout, 0);
|
| +}
|
| +
|
| +function testFunctionTimeout()
|
| +{
|
| + var functions = [doTestPromiseConstructor, doTestSettledPromisesResolved, doTestSettledPromisesRejected, doTestChainedPromises, doTestChainedPromisesJSON, doTestPromiseAll, doTestThrowFromChain, doTestTimeoutChain, doTestPromiseResolve, doTestPromiseReject];
|
| + for (var i = 0; i < functions.length; ++i)
|
| + functions[i]();
|
| +}
|
| +
|
| +function thenCallback(value)
|
| +{
|
| + debugger;
|
| +}
|
| +
|
| +function errorCallback(error)
|
| +{
|
| + debugger;
|
| +}
|
| +
|
| +function doTestPromiseConstructor()
|
| +{
|
| + new Promise(function promiseCallback(resolve, reject) {
|
| + resolve(1);
|
| + debugger;
|
| + });
|
| +}
|
| +
|
| +async function doTestSettledPromisesResolved()
|
| +{
|
| + try {
|
| + let value = await settledPromise("resolved");
|
| + thenCallback(value);
|
| + } catch (e) {
|
| + errorCallback(e);
|
| + }
|
| +}
|
| +
|
| +async function doTestSettledPromisesRejected()
|
| +{
|
| + try {
|
| + let value = await settledPromise("rejected");
|
| + thenCallback(value);
|
| + } catch (e) {
|
| + errorCallback(e);
|
| + }
|
| +}
|
| +
|
| +async function doTestChainedPromises()
|
| +{
|
| + try {
|
| + await timeoutPromise(1);
|
| + debugger;
|
| + await timeoutPromise(2);
|
| + debugger;
|
| + await 3;
|
| + debugger;
|
| + await settledPromise(4);
|
| + debuger;
|
| + thenCallback(await timeoutPromise(5));
|
| + } catch (e)
|
| + errorCallback(e);
|
| + }
|
| +}
|
| +
|
| +async function doTestChainedPromisesJSON()
|
| +{
|
| + let one = await timeoutPromise(1);
|
| + let stringify = await JSON.stringify(one);
|
| + let parse = await JSON.parse(stringify);
|
| + debugger;
|
| +}
|
| +
|
| +async function doTestPromiseAll()
|
| +{
|
| + try {
|
| + let all = await Promise.all([11, 22, 33, 44, 55].map(timeoutPromise));
|
| + thenCallback(all);
|
| + } catch (e) {
|
| + errorCallback(e);
|
| + }
|
| +}
|
| +
|
| +async function doTestThrowFromChain()
|
| +{
|
| + await timeoutPromise(1);
|
| + await timeoutPromise(2);
|
| + await settledPromise(3);
|
| + throw Error("thrown from 4");
|
| + await timeoutPromise(5);
|
| + debugger;
|
| +}
|
| +
|
| +async function doTestTimeoutChain() {
|
| + await timeoutPromise(1);
|
| + await timeoutPromise(2);
|
| + await timeoutPromise(3);
|
| + await timeoutPromise(Error(4));
|
| + throw Error("thrown from chained3");
|
| + await timeoutPromise(5);
|
| + debugger;
|
| +}
|
| +
|
| +function doTestPromiseResolve()
|
| +{
|
| + try {
|
| + let value = Promise.resolve(1);
|
| + thenCallback(e);
|
| + } catch (e) {
|
| + errorCallback(e);
|
| + }
|
| +}
|
| +
|
| +function doTestPromiseReject()
|
| +{
|
| + try {
|
| + let value = Promise.reject(Error("2"))
|
| + thenCallback(e);
|
| + } catch (e) {
|
| + errorCallback(e);
|
| + }
|
| +}
|
| +
|
| +var test = function()
|
| +{
|
| + var totalDebuggerStatements = 14;
|
| + var maxAsyncCallStackDepth = 4;
|
| + InspectorTest.runAsyncCallStacksTest(totalDebuggerStatements, maxAsyncCallStackDepth);
|
| +}
|
| +
|
| +</script>
|
| +</head>
|
| +
|
| +<body onload="runTest()">
|
| +<p>
|
| +Tests asynchronous call stacks for Promises.
|
| +</p>
|
| +
|
| +</body>
|
| +</html>
|
| +
|
|
|