Bug 147096 - Web Inspector: start using Promises to handle asynchronous steps in protocol tests
Summary: Web Inspector: start using Promises to handle asynchronous steps in protocol ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Brian Burg
URL:
Keywords: InRadar
Depends on:
Blocks: InspectorTest 147097
  Show dependency treegraph
 
Reported: 2015-07-19 14:59 PDT by Brian Burg
Modified: 2015-07-21 08:42 PDT (History)
10 users (show)

See Also:


Attachments
Patch (39.71 KB, patch)
2015-07-19 18:29 PDT, Brian Burg
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews102 for mac-mavericks (541.30 KB, application/zip)
2015-07-19 19:02 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews104 for mac-mavericks-wk2 (593.41 KB, application/zip)
2015-07-19 19:08 PDT, Build Bot
no flags Details
PFR (fixed test result) (41.12 KB, patch)
2015-07-19 20:03 PDT, Brian Burg
no flags Details | Formatted Diff | Diff
PFR (address comments) (41.06 KB, patch)
2015-07-20 16:12 PDT, Brian Burg
joepeck: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Burg 2015-07-19 14:59:09 PDT
.
Comment 1 Radar WebKit Bug Importer 2015-07-19 14:59:24 PDT
<rdar://problem/21892871>
Comment 2 Brian Burg 2015-07-19 18:29:02 PDT
Created attachment 257070 [details]
Patch
Comment 3 Build Bot 2015-07-19 19:02:29 PDT
Comment on attachment 257070 [details]
Patch

Attachment 257070 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/4606950234914816

New failing tests:
inspector-protocol/sync-test-suite.html
Comment 4 Build Bot 2015-07-19 19:02:32 PDT
Created attachment 257072 [details]
Archive of layout-test-results from ews102 for mac-mavericks

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-mavericks  Platform: Mac OS X 10.9.5
Comment 5 Build Bot 2015-07-19 19:07:57 PDT
Comment on attachment 257070 [details]
Patch

Attachment 257070 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/5118500704092160

New failing tests:
inspector-protocol/sync-test-suite.html
Comment 6 Build Bot 2015-07-19 19:08:00 PDT
Created attachment 257073 [details]
Archive of layout-test-results from ews104 for mac-mavericks-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews104  Port: mac-mavericks-wk2  Platform: Mac OS X 10.9.5
Comment 7 Brian Burg 2015-07-19 20:03:47 PDT
Created attachment 257074 [details]
PFR (fixed test result)
Comment 8 Joseph Pecoraro 2015-07-20 15:28:17 PDT
Comment on attachment 257074 [details]
PFR (fixed test result)

View in context: https://bugs.webkit.org/attachment.cgi?id=257074&action=review

> LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js:200
> +        result.catch(function(e) {

return result.catch(...) instead of result?

> LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js:324
> +    if (this.forceSyncDebugLogging)
> +        this.debugLog(formattedMessage);
> +    else
> +        this.log(formattedMessage);

This can just call log() which will handle forceSyncDebugLogging for us.

> LayoutTests/inspector-protocol/runtime/getProperties.html:54
> +                InspectorTest.awaitCommand({
> +                    method: "Runtime.evaluate",
> +                    params: {expression}
> +                })
> +                .then(function(reply) {
> +                    var objectId = reply.result.objectId;
> +                    if (objectId === undefined)
> +                        throw new Error("objectId is expected");
> +
> +                    return InspectorTest.awaitCommand({
> +                        method: "Runtime.getProperties",
> +                        params: {objectId, ownProperties: true}
> +                    });
> +                })
> +                .then(function(reply) {
> +                    dumpGetPropertiesResult(reply);
> +                    resolve();
> +                });

If some exception is triggered inside the awaitCommand's callbacks, that doesn't appear to propagate to anything.

I have a feeling, that somehow there should be an:

    .catch(reject)

I'm not sure if you could return the chain (see below) because here we are actually calling resolve() on our own...

    return InspectorTest.awaitCommand(...)
        .then(...)
        .then(...);

But maybe it would work if it returned Promise.resolve() instead of calling resolve().

        return InspectorTest.awaitCommand(...)
        .then(...)
        .then(function() {
            ...
            return Promise.resolve()
        })

That seems messier though. Thoughts?
Comment 9 Brian Burg 2015-07-20 16:12:38 PDT
Created attachment 257140 [details]
PFR (address comments)
Comment 10 Joseph Pecoraro 2015-07-20 16:29:51 PDT
Comment on attachment 257140 [details]
PFR (address comments)

r=me
Comment 11 Brian Burg 2015-07-20 16:37:11 PDT
Committed r187046: <http://trac.webkit.org/changeset/187046>