Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: third_party/WebKit/LayoutTests/inspector/sources/debugger-async/async-await/async-callstack-async-await.html

Issue 2071483002: [LayoutTests] add async callstack tests for V8 async functions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [LayoutTests] add async callstack tests for V8 async functions Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <html>
2 <head>
3 <script src="../../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../../http/tests/inspector/debugger-test.js"></script>
5 <script>
6
7 function timeoutPromise(value, ms)
8 {
9 return new Promise(function promiseCallback(resolve, reject) {
10 function resolvePromise()
11 {
12 resolve(value);
13 }
14 function rejectPromise()
15 {
16 reject(value);
17 }
18 if (value instanceof Error)
19 setTimeout(rejectPromise, ms || 0);
20 else
21 setTimeout(resolvePromise, ms || 0);
22 });
23 }
24
25 function settledPromise(value)
26 {
27 function resolveCallback(resolve, reject)
28 {
29 resolve(value);
30 }
31 function rejectCallback(resolve, reject)
32 {
33 reject(value);
34 }
35 if (value instanceof Error)
36 return new Promise(rejectCallback);
37 else
38 return new Promise(resolveCallback);
39 }
40
41 function testFunction()
42 {
43 setTimeout(testFunctionTimeout, 0);
44 }
45
46 function testFunctionTimeout()
47 {
48 var functions = [doTestPromiseConstructor, doTestSettledPromisesResolved, do TestSettledPromisesRejected, doTestChainedPromises, doTestChainedPromisesJSON, d oTestPromiseAll, doTestThrowFromChain, doTestRejectFromChain, doTestPromiseResol ve, doTestPromiseReject];
49 for (var i = 0; i < functions.length; ++i)
50 functions[i]();
51 }
52
53 function thenCallback(value)
54 {
55 debugger;
56 }
57
58 function errorCallback(error)
59 {
60 debugger;
61 }
62
63 async function doTestPromiseConstructor()
64 {
65 try {
66 let result = await new Promise(function promiseCallback(resolve, reject) {
67 resolve(1);
68 debugger;
69 });
70 thenCallback(result);
71 } catch (e) {
72 errorCallback(e);
73 }
74 }
75
76 async function doTestSettledPromisesResolved()
77 {
78 try {
79 let value = await settledPromise("resolved");
80 thenCallback(value);
81 } catch (e) {
82 errorCallback(e);
83 }
84 }
85
86 async function doTestSettledPromisesRejected()
87 {
88 try {
89 let value = await settledPromise(new Error("rejected"));
90 thenCallback(value);
91 } catch (e) {
92 errorCallback(e);
93 }
94 }
95
96 async function doTestChainedPromises()
97 {
98 try {
99 await timeoutPromise(1);
100 debugger;
101 await timeoutPromise(2);
102 debugger;
103 await 3;
104 debugger;
105 await settledPromise(4);
106 debugger;
107 thenCallback(await timeoutPromise(5));
108 } catch (e) {
109 errorCallback(e);
110 }
111 }
112
113 async function doTestChainedPromisesJSON()
114 {
115 try {
116 let one = await timeoutPromise(1);
117 let stringify = await JSON.stringify(one);
118 let parse = await JSON.parse(stringify);
119 thenCallback(parse);
120 } catch (e) {
121 errorCallback(e);
122 }
123 }
124
125 async function doTestPromiseAll()
126 {
127 try {
128 let all = await Promise.all([11, 22, 33, 44, 55].map(timeoutPromise));
129 thenCallback(all);
130 } catch (e) {
131 errorCallback(e);
132 }
133 }
134
135 async function throwFromChain()
136 {
137 await timeoutPromise(1);
138 await timeoutPromise(2);
139 await settledPromise(3);
140 throw Error("thrown from 4");
141 await timeoutPromise(5);
142 debugger;
143 }
144
145 async function doTestThrowFromChain()
146 {
147 try {
148 let result = await throwFromChain();
149 thencallback(result);
150 } catch (e) {
151 errorCallback(e);
152 }
153 }
154
155 async function rejectFromChain()
156 {
157 await timeoutPromise(1);
158 await timeoutPromise(2);
159 await timeoutPromise(3);
160 await timeoutPromise(new Error(4));
161 throw new Error("thrown from rejectFromChain");
162 debugger;
163 }
164
165 async function doTestRejectFromChain()
166 {
167 try {
168 let result = await rejectFromChain();
169 thenCallback(result);
170 } catch (e) {
171 errorCallback(e);
172 }
173 }
174
175 async function doTestPromiseResolve()
176 {
177 try {
178 let result = await Promise.resolve(1);
179 thenCallback(result);
180 } catch (e) {
181 errorCallback(e);
182 }
183 }
184
185 async function doTestPromiseReject()
186 {
187 try {
188 let result = await Promise.reject(new Error("2"))
189 thenCallback(result);
190 } catch (e) {
191 errorCallback(e);
192 }
193 }
194
195 var test = function()
196 {
197 var totalDebuggerStatements = 15;
198 var maxAsyncCallStackDepth = 5;
199 InspectorTest.runAsyncCallStacksTest(totalDebuggerStatements, maxAsyncCallSt ackDepth);
200 }
201
202 </script>
203 </head>
204
205 <body onload="runTest()">
206 <p>
207 Tests asynchronous call stacks for async functions.
208 </p>
209
210 </body>
211 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698