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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-await-promise.html

Issue 2249743006: [DevTools] Fill ExceptionDetails with more details, unify usage across protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: browser test Created 4 years, 4 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
1 <html> 1 <html>
2 <head> 2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto r-protocol-test.js"></script> 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto r-protocol-test.js"></script>
4 <script> 4 <script>
5 5
6 var resolveCallback; 6 var resolveCallback;
7 var rejectCallback; 7 var rejectCallback;
8 function createPromise() 8 function createPromise()
9 { 9 {
10 return new Promise((resolve, reject) => { resolveCallback = resolve; rejectC allback = reject }); 10 return new Promise((resolve, reject) => { resolveCallback = resolve; rejectC allback = reject });
(...skipping 18 matching lines...) Expand all
29 if (window.gc) 29 if (window.gc)
30 window.gc(); 30 window.gc();
31 } 31 }
32 32
33 function test() 33 function test()
34 { 34 {
35 InspectorTest.sendCommandPromise("Debugger.enable", {}) 35 InspectorTest.sendCommandPromise("Debugger.enable", {})
36 .then(() => InspectorTest.sendCommandPromise("Debugger.setAsyncCallStack Depth", { maxDepth: 128 })) 36 .then(() => InspectorTest.sendCommandPromise("Debugger.setAsyncCallStack Depth", { maxDepth: 128 }))
37 .then(() => testSuite()); 37 .then(() => testSuite());
38 38
39 function dumpResult(result)
40 {
41 if (result.exceptionDetails) {
42 if (result.exceptionDetails.stackTrace && result.exceptionDetails.st ackTrace.parent) {
43 for (var frame of result.exceptionDetails.stackTrace.parent.call Frames) {
44 frame.scriptId = 0;
45 frame.url = "";
46 }
47 }
48 result.exceptionDetails.exceptionId = 0;
49 if (result.exceptionDetails.exception)
50 result.exceptionDetails.exception.objectId = 0;
51 }
52 InspectorTest.logObject(result);
53 }
54
39 function testSuite() 55 function testSuite()
40 { 56 {
41 InspectorTest.runTestSuite([ 57 InspectorTest.runTestSuite([
42 function testResolvedPromise(next) 58 function testResolvedPromise(next)
43 { 59 {
44 InspectorTest.sendCommandPromise("Runtime.evaluate", { expressio n: "Promise.resolve(239)"}) 60 InspectorTest.sendCommandPromise("Runtime.evaluate", { expressio n: "Promise.resolve(239)"})
45 .then((result) => InspectorTest.sendCommandPromise("Runtime. awaitPromise", { promiseObjectId: result.result.result.objectId, returnByValue: false, generatePreview: true })) 61 .then((result) => InspectorTest.sendCommandPromise("Runtime. awaitPromise", { promiseObjectId: result.result.result.objectId, returnByValue: false, generatePreview: true }))
46 .then((result) => InspectorTest.logObject(result.result)) 62 .then((result) => dumpResult(result.result))
47 .then(() => next()); 63 .then(() => next());
48 }, 64 },
49 65
50 function testRejectedPromise(next) 66 function testRejectedPromise(next)
51 { 67 {
52 InspectorTest.sendCommandPromise("Runtime.evaluate", { expressio n: "Promise.reject({ a : 1 })"}) 68 InspectorTest.sendCommandPromise("Runtime.evaluate", { expressio n: "Promise.reject({ a : 1 })"})
53 .then((result) => InspectorTest.sendCommandPromise("Runtime. awaitPromise", { promiseObjectId: result.result.result.objectId, returnByValue: true, generatePreview: false })) 69 .then((result) => InspectorTest.sendCommandPromise("Runtime. awaitPromise", { promiseObjectId: result.result.result.objectId, returnByValue: true, generatePreview: false }))
54 .then((result) => InspectorTest.logObject(result.result)) 70 .then((result) => dumpResult(result.result))
55 .then(() => next()); 71 .then(() => next());
56 }, 72 },
57 73
58 function testRejectedPromiseWithStack(next) 74 function testRejectedPromiseWithStack(next)
59 { 75 {
60 InspectorTest.sendCommandPromise("Runtime.evaluate", { expressio n: "createPromise()"}) 76 InspectorTest.sendCommandPromise("Runtime.evaluate", { expressio n: "createPromise()"})
61 .then((result) => scheduleRejectAndAwaitPromise(result)) 77 .then((result) => scheduleRejectAndAwaitPromise(result))
62 .then((result) => dumpResult(result.result)) 78 .then((result) => dumpResult(result.result))
63 .then(() => next()); 79 .then(() => next());
64 80
65 function scheduleRejectAndAwaitPromise(result) 81 function scheduleRejectAndAwaitPromise(result)
66 { 82 {
67 var promise = InspectorTest.sendCommandPromise("Runtime.awai tPromise", { promiseObjectId: result.result.result.objectId }); 83 var promise = InspectorTest.sendCommandPromise("Runtime.awai tPromise", { promiseObjectId: result.result.result.objectId });
68 InspectorTest.sendCommandPromise("Runtime.evaluate", { expre ssion: "rejectPromise()" }); 84 InspectorTest.sendCommandPromise("Runtime.evaluate", { expre ssion: "rejectPromise()" });
69 return promise; 85 return promise;
70 } 86 }
71
72 function dumpResult(result)
73 {
74 for (var frame of result.exceptionDetails.stackTrace.parent. callFrames) {
75 frame.scriptId = 0;
76 frame.url = "";
77 }
78 InspectorTest.logObject(result);
79 }
80 }, 87 },
81 88
82 function testPendingPromise(next) 89 function testPendingPromise(next)
83 { 90 {
84 InspectorTest.sendCommandPromise("Runtime.evaluate", { expressio n: "createPromise()"}) 91 InspectorTest.sendCommandPromise("Runtime.evaluate", { expressio n: "createPromise()"})
85 .then((result) => scheduleFulfillAndAwaitPromise(result)) 92 .then((result) => scheduleFulfillAndAwaitPromise(result))
86 .then((result) => InspectorTest.logObject(result.result)) 93 .then((result) => dumpResult(result.result))
87 .then(() => next()); 94 .then(() => next());
88 95
89 function scheduleFulfillAndAwaitPromise(result) 96 function scheduleFulfillAndAwaitPromise(result)
90 { 97 {
91 var promise = InspectorTest.sendCommandPromise("Runtime.awai tPromise", { promiseObjectId: result.result.result.objectId }); 98 var promise = InspectorTest.sendCommandPromise("Runtime.awai tPromise", { promiseObjectId: result.result.result.objectId });
92 InspectorTest.sendCommandPromise("Runtime.evaluate", { expre ssion: "resolvePromise()" }); 99 InspectorTest.sendCommandPromise("Runtime.evaluate", { expre ssion: "resolvePromise()" });
93 return promise; 100 return promise;
94 } 101 }
95 }, 102 },
96 103
97 function testResolvedWithoutArgsPromise(next) 104 function testResolvedWithoutArgsPromise(next)
98 { 105 {
99 InspectorTest.sendCommandPromise("Runtime.evaluate", { expressio n: "Promise.resolve()"}) 106 InspectorTest.sendCommandPromise("Runtime.evaluate", { expressio n: "Promise.resolve()"})
100 .then((result) => InspectorTest.sendCommandPromise("Runtime. awaitPromise", { promiseObjectId: result.result.result.objectId, returnByValue: true, generatePreview: false })) 107 .then((result) => InspectorTest.sendCommandPromise("Runtime. awaitPromise", { promiseObjectId: result.result.result.objectId, returnByValue: true, generatePreview: false }))
101 .then((result) => InspectorTest.logObject(result.result)) 108 .then((result) => dumpResult(result.result))
102 .then(() => next()); 109 .then(() => next());
103 }, 110 },
104 111
105 function testGarbageCollectedPromise(next) 112 function testGarbageCollectedPromise(next)
106 { 113 {
107 InspectorTest.sendCommandPromise("Runtime.evaluate", { expressio n: "new Promise(() => undefined)" }) 114 InspectorTest.sendCommandPromise("Runtime.evaluate", { expressio n: "new Promise(() => undefined)" })
108 .then((result) => scheduleGCAndawaitPromise(result)) 115 .then((result) => scheduleGCAndawaitPromise(result))
109 .then((result) => InspectorTest.logObject(result.error)) 116 .then((result) => InspectorTest.logObject(result.error))
110 .then(() => next()); 117 .then(() => next());
111 118
(...skipping 14 matching lines...) Expand all
126 ]); 133 ]);
127 } 134 }
128 } 135 }
129 </script> 136 </script>
130 </head> 137 </head>
131 <body onLoad="runTest();"> 138 <body onLoad="runTest();">
132 Tests that Runtime.awaitPromise works. 139 Tests that Runtime.awaitPromise works.
133 </body> 140 </body>
134 </html> 141 </html>
135 142
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698