New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 755104 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Aug 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug



Sign in to add a comment

Result of the evaluation is not a promise

Reported by netforge...@gmail.com, Aug 14 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36

Steps to reproduce the problem:
1. navigate to https://public.tableau.com/profile/emily2933#!/
2. try to execute a javascript which returns a promise via the remote debugging port

What is the expected behavior?

What went wrong?
I'm having issues trying to execute some JavaScript remotely (I'm using the chrome-remote-interface here https://github.com/cyrus-and/chrome-remote-interface).

Some simple JS like the following script is enough to reproduce this:

"new Promise(resolve => { setTimeout(() => { resolve(document.documentElement.outerHTML); }, 5000); })"

I think the website is using a Promise polyfill which overwrites the Promise native object. That probably triggers an error here https://github.com/v8/v8/blob/master/src/inspector/v8-runtime-agent-impl.cc#L193

Would there be a way to execute some asynchronous JS remotely on websites that use Promise polyfills?

Did this work before? N/A 

Chrome version: 60.0.3112.90  Channel: stable
OS Version: Linux 3f7a9b6dd1a6 4.9.36-moby
Flash Version:
 

Comment 1 by woxxom@gmail.com, Aug 14 2017

You can access the native Promise API via iframe "hack":

((ok, err) => {
  var iframe = document.head.appendChild(document.createElement('iframe'));
  var Promise = iframe.contentWindow.Promise;
  iframe.remove();
  return new Promise(ok, err);
})(resolve => { setTimeout(() => { resolve(document.documentElement.outerHTML); }, 5000); })
Awesome, it worked like a charm! Thank you =)

Comment 3 by l...@chromium.org, Aug 14 2017

Owner: kozyatinskiy@chromium.org
Status: Assigned (was: Unconfirmed)
Thanks for the report, and thanks to commenter #2 for the clever workaround.  In the site you linked, it looks like Bluebird.js overwrites window.Promise with its own implementation.  This likely affects any page with a promise library that overwrites the native Promise.

kozy@, could you please take a look into ideas that address the general case?  Perhaps automatically wrapping return values in native promises?
Project Member

Comment 4 by bugdroid1@chromium.org, Aug 15 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4b2c8f0a3d4a1e739feec88c21675d568f80027e

commit 4b2c8f0a3d4a1e739feec88c21675d568f80027e
Author: Alexey Kozyatinskiy <kozyatinskiy@chromium.org>
Date: Tue Aug 15 00:17:09 2017

[DevTools] disable tests before V8 roll

V8 roll will change awaitPromise semantic.

TBR=dgozman@chromium.org

Bug:  chromium:755104 
Change-Id: I7cdf41e2273e40b4069edc7f96fa3a6653734c60
Reviewed-on: https://chromium-review.googlesource.com/614741
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#494259}
[modify] https://crrev.com/4b2c8f0a3d4a1e739feec88c21675d568f80027e/third_party/WebKit/LayoutTests/TestExpectations
[modify] https://crrev.com/4b2c8f0a3d4a1e739feec88c21675d568f80027e/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-callFunctionOn-async-expected.txt
[modify] https://crrev.com/4b2c8f0a3d4a1e739feec88c21675d568f80027e/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-callFunctionOn-async.js
[modify] https://crrev.com/4b2c8f0a3d4a1e739feec88c21675d568f80027e/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-evaluate-async-expected.txt
[modify] https://crrev.com/4b2c8f0a3d4a1e739feec88c21675d568f80027e/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-evaluate-async.js
[modify] https://crrev.com/4b2c8f0a3d4a1e739feec88c21675d568f80027e/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-runScript-async-expected.txt
[modify] https://crrev.com/4b2c8f0a3d4a1e739feec88c21675d568f80027e/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-runScript-async.js

Project Member

Comment 5 by bugdroid1@chromium.org, Aug 15 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/6ceee5369846ec2c95e9262bf6f55dd07749e8e8

commit 6ceee5369846ec2c95e9262bf6f55dd07749e8e8
Author: Alexey Kozyatinskiy <kozyatinskiy@chromium.org>
Date: Tue Aug 15 01:35:29 2017

[inspector] aligned Runtime.evaluate(awaitPromise: true) with await semantic

This one allows us to support custom promises implementation.
With awaitPromise flag Runtime.evaluate awaits
Promise.resolve(<expression result>).
This also allows to await for any non-Promise value, similar to await
expression, which is more convenient for most protocol users.

R=dgozman@chromium.org

Bug:  chromium:755104 
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Iee798b33b6fb7de7d393372e164c0481d1bbf7eb
Reviewed-on: https://chromium-review.googlesource.com/614308
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47354}
[modify] https://crrev.com/6ceee5369846ec2c95e9262bf6f55dd07749e8e8/src/inspector/injected-script.cc
[modify] https://crrev.com/6ceee5369846ec2c95e9262bf6f55dd07749e8e8/src/inspector/injected-script.h
[modify] https://crrev.com/6ceee5369846ec2c95e9262bf6f55dd07749e8e8/src/inspector/js_protocol.json
[modify] https://crrev.com/6ceee5369846ec2c95e9262bf6f55dd07749e8e8/src/inspector/v8-runtime-agent-impl.cc
[modify] https://crrev.com/6ceee5369846ec2c95e9262bf6f55dd07749e8e8/test/inspector/runtime/call-function-on-async-expected.txt
[modify] https://crrev.com/6ceee5369846ec2c95e9262bf6f55dd07749e8e8/test/inspector/runtime/call-function-on-async.js
[modify] https://crrev.com/6ceee5369846ec2c95e9262bf6f55dd07749e8e8/test/inspector/runtime/evaluate-async-expected.txt
[modify] https://crrev.com/6ceee5369846ec2c95e9262bf6f55dd07749e8e8/test/inspector/runtime/evaluate-async.js
[modify] https://crrev.com/6ceee5369846ec2c95e9262bf6f55dd07749e8e8/test/inspector/runtime/run-script-async-expected.txt
[modify] https://crrev.com/6ceee5369846ec2c95e9262bf6f55dd07749e8e8/test/inspector/runtime/run-script-async.js

Project Member

Comment 6 by bugdroid1@chromium.org, Aug 15 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2d336b8bb3d67aa23a63fd0be1fe8fe76145c6e2

commit 2d336b8bb3d67aa23a63fd0be1fe8fe76145c6e2
Author: Alexey Kozyatinskiy <kozyatinskiy@chromium.org>
Date: Tue Aug 15 18:58:48 2017

[DevTools] reenable tests

Roll with awaitPromise semantic change was rolled.

TBR=dgozman@chromium.org

Bug:  chromium:755104 
Change-Id: I61551f6e5d88189da13680586a5e34013b121af0
Reviewed-on: https://chromium-review.googlesource.com/615524
Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#494473}
[modify] https://crrev.com/2d336b8bb3d67aa23a63fd0be1fe8fe76145c6e2/third_party/WebKit/LayoutTests/TestExpectations

Status: Fixed (was: Assigned)

Sign in to add a comment