RejectedPromiseTracker should produce better callstacks and avoid capturing callstack...
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 May 2017 22:24:37 +0000 (22:24 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 May 2017 22:24:37 +0000 (22:24 +0000)
commitee4bbfe985d64dab8c8098c98220136ef95c125b
tree4cea7e4e5f539751781830fead85ba2a1bbd7386
parent378d1d899536922e7fe505c614d7b9d9de303707
RejectedPromiseTracker should produce better callstacks and avoid capturing callstacks unless there is a debugger/inspector
https://bugs.webkit.org/show_bug.cgi?id=171416
<rdar://problem/31899425>

Reviewed by Saam Barati and Brian Burg.

LayoutTests/imported/w3c:

* web-platform-tests/WebCryptoAPI/derive_bits_keys/test_ecdh_bits-expected.txt:
* web-platform-tests/WebCryptoAPI/derive_bits_keys/test_ecdh_keys-expected.txt:
* web-platform-tests/html/semantics/embedded-content/media-elements/event_pause_noautoplay-expected.txt:
* web-platform-tests/html/semantics/embedded-content/media-elements/event_play_noautoplay-expected.txt:
* web-platform-tests/html/semantics/embedded-content/media-elements/paused_true_during_pause-expected.txt:
* web-platform-tests/streams/piping/close-propagation-forward-expected.txt:
* web-platform-tests/streams/piping/error-propagation-backward-expected.txt:
* web-platform-tests/streams/piping/error-propagation-forward-expected.txt:
* web-platform-tests/streams/piping/flow-control-expected.txt:
* web-platform-tests/streams/piping/general-expected.txt:
Rebaseline results. Better stack trace for errors includes correct line numbers.
Explicit rejections with a value do not include backtraces without a debugger.

Source/WebCore:

Test: inspector/console/message-stack-trace.html

* dom/RejectedPromiseTracker.cpp:
(WebCore::UnhandledPromise::UnhandledPromise):
(WebCore::UnhandledPromise::callStack):
Switch to RefPtr to allow not capturing the stack.

(WebCore::createScriptCallStackFromReason):
Use the VM's lastException if the value in the exception is the
rejected promise value. Using the Exception call stack is important
because uncaught exceptions in promise rejections trigger a built-in
try/catch and re-enter JavaScript before passing the Error through
to the RejectionTracker. When possible, we don't want to capture the
new stack originating from the try/catch. Instead, we want the stack
from before the try/catch when the error was created.

* dom/ScriptExecutionContext.h:
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::reportUnhandledPromiseRejection):
Switch to a pointer since the stack could be empty.

LayoutTests:

* inspector/console/message-stack-trace-expected.txt: Added.
* inspector/console/message-stack-trace.html: Added.
Test console stack traces from various places where console messages
are generated and the stacks are important.

* inspector/console/resources/log-console-stack-trace.js: Added.
(TestPage.registerInitializer.logCallFrame):
(TestPage.registerInitializer.window.logConsoleMessageStackTrace):
Like the logger for Debugger StackTrace but for Console StackTrace.

* inspector/debugger/break-on-exception-throw-in-promise-expected.txt:
* inspector/debugger/break-on-uncaught-exception-throw-in-promise-expected.txt:
* fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt:
* http/tests/security/video-cross-origin-caching-expected.txt:
* js/dom/unhandled-promise-rejection-bindings-type-error-expected.txt:
* js/dom/unhandled-promise-rejection-console-report-expected.txt:
* js/promises-tests/promises-tests-2-2-6-expected.txt:
* streams/reference-implementation/pipe-to-options-expected.txt:
* streams/reference-implementation/readable-stream-templated-expected.txt:
* streams/reference-implementation/writable-stream-abort-expected.txt:
* streams/reference-implementation/writable-stream-expected.txt:
* webrtc/libwebrtc/release-while-creating-offer-expected.txt:
* webrtc/libwebrtc/release-while-setting-local-description-expected.txt:
Rebaseline results. Better stack trace for errors includes correct line numbers.
Explicit rejections with a value do not include backtraces without a debugger.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216035 268f45cc-cd09-0410-ab3c-d52691b4dbfc
32 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt
LayoutTests/http/tests/security/video-cross-origin-caching-expected.txt
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/test_ecdh_bits-expected.txt
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/test_ecdh_keys-expected.txt
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/event_pause_noautoplay-expected.txt
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/event_play_noautoplay-expected.txt
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/paused_true_during_pause-expected.txt
LayoutTests/imported/w3c/web-platform-tests/streams/piping/close-propagation-forward-expected.txt
LayoutTests/imported/w3c/web-platform-tests/streams/piping/error-propagation-backward-expected.txt
LayoutTests/imported/w3c/web-platform-tests/streams/piping/error-propagation-forward-expected.txt
LayoutTests/imported/w3c/web-platform-tests/streams/piping/flow-control-expected.txt
LayoutTests/imported/w3c/web-platform-tests/streams/piping/general-expected.txt
LayoutTests/inspector/console/message-stack-trace-expected.txt [new file with mode: 0644]
LayoutTests/inspector/console/message-stack-trace.html [new file with mode: 0644]
LayoutTests/inspector/console/resources/log-console-stack-trace.js [new file with mode: 0644]
LayoutTests/inspector/debugger/break-on-exception-throw-in-promise-expected.txt
LayoutTests/inspector/debugger/break-on-uncaught-exception-throw-in-promise-expected.txt
LayoutTests/js/dom/unhandled-promise-rejection-bindings-type-error-expected.txt
LayoutTests/js/dom/unhandled-promise-rejection-console-report-expected.txt
LayoutTests/js/promises-tests/promises-tests-2-2-6-expected.txt
LayoutTests/streams/reference-implementation/pipe-to-options-expected.txt
LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt
LayoutTests/streams/reference-implementation/writable-stream-abort-expected.txt
LayoutTests/streams/reference-implementation/writable-stream-expected.txt
LayoutTests/webrtc/libwebrtc/release-while-creating-offer-expected.txt
LayoutTests/webrtc/libwebrtc/release-while-setting-local-description-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/dom/RejectedPromiseTracker.cpp
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/dom/ScriptExecutionContext.h