[Webkit-unassigned] [Bug 165681] Web Inspector: Console could be made useful for very simple await expressions

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Dec 19 23:27:09 PST 2016


https://bugs.webkit.org/show_bug.cgi?id=165681

--- Comment #12 from Joseph Pecoraro <joepeck at webkit.org> ---
> We can improve later with a $n solution.

I think something like:

    Runtime.evaluateAsync

One way this could be implemented is passing a function (like Runtime.callFunctionOn) where `this` is the global object and param provides an API to do things.

    function (injectedScriptAPI) {
        value = ...;
        injectedScriptAPI.result(value); // equivalent of user typing `value` in the console, so $n.
    }

Another approach would be to take in a program / function resulting in a promise. And sending back the result when the promise resolves. So I think this could just send what we want here:

    (async function() {
        return await <expr>;
    })();

InjectedScript could then wrap this in something like:

    async evaluateAsync(id, expression, options)
    {
        try {
            let result = await this._evaluate(expression, options);
            this._saveResult(result);
            InjectedScriptHost.asyncResult(id, {result: this._wrapObject(result), wasThrown: false});
        } catch (e) {
            InjectedScriptHost.asyncResult(id, {result: e, wasThrown: true});
        } 
    }

I think the one drawback of this approach over the other is that you can't actually get back a Promise value here. But perhaps that is perfectly fine.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20161220/720b23b9/attachment.html>


More information about the webkit-unassigned mailing list