<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Web Inspector: Console could be made useful for very simple await expressions"
href="https://bugs.webkit.org/show_bug.cgi?id=165681#c12">Comment # 12</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Web Inspector: Console could be made useful for very simple await expressions"
href="https://bugs.webkit.org/show_bug.cgi?id=165681">bug 165681</a>
from <span class="vcard"><a class="email" href="mailto:joepeck@webkit.org" title="Joseph Pecoraro <joepeck@webkit.org>"> <span class="fn">Joseph Pecoraro</span></a>
</span></b>
<pre><span class="quote">> We can improve later with a $n solution.</span >
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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>