RESOLVED FIXED Bug 192171
Web Inspector: Audit: tests should support async operations
https://bugs.webkit.org/show_bug.cgi?id=192171
Summary Web Inspector: Audit: tests should support async operations
Devin Rousso
Reported 2018-11-29 12:19:43 PST
If a test returns a Promise (either by manually `return new Promise(...)` or using an `async function() { ... }`), we should wait on that promise before completing the test.
Attachments
Patch (45.33 KB, patch)
2018-11-29 12:27 PST, Devin Rousso
no flags
Archive of layout-test-results from ews102 for mac-sierra (2.57 MB, application/zip)
2018-11-29 13:28 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews106 for mac-sierra-wk2 (3.15 MB, application/zip)
2018-11-29 13:42 PST, EWS Watchlist
no flags
Patch (46.88 KB, patch)
2018-11-29 13:57 PST, Devin Rousso
no flags
Archive of layout-test-results from ews107 for mac-sierra-wk2 (2.99 MB, application/zip)
2018-11-29 15:20 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews103 for mac-sierra (2.65 MB, application/zip)
2018-11-29 15:43 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews114 for mac-sierra (2.30 MB, application/zip)
2018-11-29 17:01 PST, EWS Watchlist
no flags
Patch (47.37 KB, patch)
2018-11-30 00:56 PST, Devin Rousso
no flags
Archive of layout-test-results from ews103 for mac-sierra (2.46 MB, application/zip)
2018-11-30 01:38 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews114 for mac-sierra (1.99 MB, application/zip)
2018-11-30 02:32 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews124 for ios-simulator-wk2 (2.73 MB, application/zip)
2018-11-30 09:12 PST, EWS Watchlist
no flags
Patch (47.79 KB, patch)
2018-11-30 11:19 PST, Devin Rousso
no flags
[Patch] Mapped Callbacks (48.22 KB, patch)
2018-11-30 12:08 PST, Devin Rousso
no flags
Patch (52.09 KB, patch)
2018-11-30 12:32 PST, Devin Rousso
ews-watchlist: commit-queue-
Archive of layout-test-results from ews104 for mac-sierra-wk2 (3.24 MB, application/zip)
2018-11-30 13:45 PST, EWS Watchlist
no flags
Patch (51.26 KB, patch)
2018-11-30 13:50 PST, Devin Rousso
no flags
Patch (51.26 KB, patch)
2018-11-30 20:26 PST, Devin Rousso
no flags
Patch (62.14 KB, patch)
2018-12-03 20:55 PST, Devin Rousso
no flags
Patch (62.34 KB, patch)
2018-12-03 21:24 PST, Devin Rousso
ews-watchlist: commit-queue-
Archive of layout-test-results from ews101 for mac-sierra (2.47 MB, application/zip)
2018-12-03 22:26 PST, EWS Watchlist
no flags
Patch (62.34 KB, patch)
2018-12-03 22:28 PST, Devin Rousso
no flags
Devin Rousso
Comment 1 2018-11-29 12:27:07 PST
EWS Watchlist
Comment 2 2018-11-29 12:29:18 PST Comment hidden (obsolete)
EWS Watchlist
Comment 3 2018-11-29 12:29:29 PST Comment hidden (obsolete)
EWS Watchlist
Comment 4 2018-11-29 13:28:41 PST Comment hidden (obsolete)
EWS Watchlist
Comment 5 2018-11-29 13:28:43 PST Comment hidden (obsolete)
EWS Watchlist
Comment 6 2018-11-29 13:42:28 PST Comment hidden (obsolete)
EWS Watchlist
Comment 7 2018-11-29 13:42:30 PST Comment hidden (obsolete)
Devin Rousso
Comment 8 2018-11-29 13:57:22 PST
Created attachment 356056 [details] Patch Add locking
EWS Watchlist
Comment 9 2018-11-29 13:59:49 PST Comment hidden (obsolete)
EWS Watchlist
Comment 10 2018-11-29 15:20:27 PST Comment hidden (obsolete)
EWS Watchlist
Comment 11 2018-11-29 15:20:29 PST Comment hidden (obsolete)
EWS Watchlist
Comment 12 2018-11-29 15:43:32 PST Comment hidden (obsolete)
EWS Watchlist
Comment 13 2018-11-29 15:43:33 PST Comment hidden (obsolete)
EWS Watchlist
Comment 14 2018-11-29 17:01:24 PST Comment hidden (obsolete)
EWS Watchlist
Comment 15 2018-11-29 17:01:26 PST Comment hidden (obsolete)
Devin Rousso
Comment 16 2018-11-30 00:56:00 PST
EWS Watchlist
Comment 17 2018-11-30 01:00:18 PST Comment hidden (obsolete)
EWS Watchlist
Comment 18 2018-11-30 01:38:04 PST Comment hidden (obsolete)
EWS Watchlist
Comment 19 2018-11-30 01:38:06 PST Comment hidden (obsolete)
EWS Watchlist
Comment 20 2018-11-30 02:32:36 PST Comment hidden (obsolete)
EWS Watchlist
Comment 21 2018-11-30 02:32:38 PST Comment hidden (obsolete)
EWS Watchlist
Comment 22 2018-11-30 09:12:19 PST Comment hidden (obsolete)
EWS Watchlist
Comment 23 2018-11-30 09:12:20 PST Comment hidden (obsolete)
Devin Rousso
Comment 24 2018-11-30 11:19:55 PST
EWS Watchlist
Comment 25 2018-11-30 11:23:16 PST Comment hidden (obsolete)
Joseph Pecoraro
Comment 26 2018-11-30 11:56:42 PST
Comment on attachment 356160 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=356160&action=review > Source/JavaScriptCore/inspector/InjectedScriptBase.cpp:131 > + ASSERT(!hadException); > + // FIXME: since `callback` is moved above, we can't call it if there's an execption while trying > + // to execute the `JSNativeStdFunction` inside InjectedScriptSource.js. I think it is fine to just ASSERT here. But you can invoke the JSNativeStdFunction yourself (or reach into it and call it). Just save a reference to it yourself above. > Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js:39 > + static supportsAwaitPromise() Can we just inline this, with a // COMPATIBILITY (iOS 12): ... > LayoutTests/inspector/runtime/awaitPromise.html:32 > + function addValueTest(name, value) { > + addTest(name, `Promise.resolve(${JSON.stringify(value)})`, {returnByValue: true, saveResult: true}, (remoteObject, wasThrown) => { There should be tests for a rejected promise. There are only Tests here for resolved promises.
Devin Rousso
Comment 27 2018-11-30 12:08:34 PST
Created attachment 356218 [details] [Patch] Mapped Callbacks Store callbacks within a map on InjectedScriptBase so that they can later be retrieved
EWS Watchlist
Comment 28 2018-11-30 12:11:01 PST Comment hidden (obsolete)
Devin Rousso
Comment 29 2018-11-30 12:32:02 PST
EWS Watchlist
Comment 30 2018-11-30 12:34:42 PST Comment hidden (obsolete)
EWS Watchlist
Comment 31 2018-11-30 13:45:56 PST Comment hidden (obsolete)
EWS Watchlist
Comment 32 2018-11-30 13:45:58 PST Comment hidden (obsolete)
Devin Rousso
Comment 33 2018-11-30 13:50:14 PST
Devin Rousso
Comment 34 2018-11-30 20:26:35 PST
Created attachment 356286 [details] Patch This is what happens when you manually edit a diff... :|
EWS Watchlist
Comment 35 2018-11-30 20:29:22 PST Comment hidden (obsolete)
Radar WebKit Bug Importer
Comment 36 2018-12-03 10:41:01 PST
Joseph Pecoraro
Comment 37 2018-12-03 18:54:50 PST
Comment on attachment 356286 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=356286&action=review r=me > Source/JavaScriptCore/inspector/InjectedScriptBase.cpp:138 > + // Since `callback` is moved above, we can't call it if there's an execption while trying to Typo: "execption" > Source/JavaScriptCore/inspector/protocol/Runtime.json:230 > + "description": "Evaluates promise on global object.", Might use a better description. This calls the callback when the given objectId (which must be a Promise) resolves / rejects. > Source/WebInspectorUI/UserInterface/Models/AuditTestCase.js:239 > + let response = null; > + > + metadata.startTimestamp = new Date; > + response = await RuntimeAgent.evaluate.invoke(evaluateArguments); Merge the `let response = ...` here? > Source/WebInspectorUI/UserInterface/Models/AuditTestCase.js:244 > + metadata.asyncTimestamp = metadata.endTimestamp; Note to Devin: Add `asyncTimestamp` to `fromPayload` (so export/import uses it). > Source/WebInspectorUI/UserInterface/Models/AuditTestCase.js:249 > + addError(WI.UIString("Async audits are not supported on this device.")); Probably better to just say "are not support". The "on this device" thing is a little weird. > LayoutTests/inspector/runtime/awaitPromise.html:49 > + let expression = `new Promise((resolve, reject) => setTimeout(reject, 100, ${JSON.stringify(value)}))`; If this is triggering onunhandledrejection console messages we should provide a way in tests to mute those so that this doesn't end up being flakey. > LayoutTests/inspector/runtime/awaitPromise.html:77 > + addRejectTest("Runtime.awaitPromise.Reject.Object", {a: 1, b: 2}); I'd also want to see a Promise chain. • Promise (1) that resolves to -> Promise (2) that resolves to -> Promise (3) that resolves to -> a value Should end up with the final value and not object (2).
Devin Rousso
Comment 38 2018-12-03 20:55:08 PST
EWS Watchlist
Comment 39 2018-12-03 21:00:47 PST Comment hidden (obsolete)
Devin Rousso
Comment 40 2018-12-03 21:24:42 PST
EWS Watchlist
Comment 41 2018-12-03 21:28:56 PST Comment hidden (obsolete)
EWS Watchlist
Comment 42 2018-12-03 22:26:10 PST Comment hidden (obsolete)
EWS Watchlist
Comment 43 2018-12-03 22:26:12 PST Comment hidden (obsolete)
Devin Rousso
Comment 44 2018-12-03 22:28:42 PST
EWS Watchlist
Comment 45 2018-12-03 22:40:21 PST Comment hidden (obsolete)
WebKit Commit Bot
Comment 46 2018-12-04 01:08:51 PST
Comment on attachment 356471 [details] Patch Clearing flags on attachment: 356471 Committed r238850: <https://trac.webkit.org/changeset/238850>
WebKit Commit Bot
Comment 47 2018-12-04 01:08:53 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.