Title: [216035] trunk
Revision
216035
Author
[email protected]
Date
2017-05-01 15:24:37 -0700 (Mon, 01 May 2017)

Log Message

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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (216034 => 216035)


--- trunk/LayoutTests/ChangeLog	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/ChangeLog	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,5 +1,39 @@
 2017-05-01  Joseph Pecoraro  <[email protected]>
 
+        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.
+
+        * 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.
+
+2017-05-01  Joseph Pecoraro  <[email protected]>
+
         LayoutTest/imported/w3c/web-platform-tests/resource-timing/rt-revalidate-requests.html is a flaky failure.
         https://bugs.webkit.org/show_bug.cgi?id=171511
 

Modified: trunk/LayoutTests/fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt (216034 => 216035)


--- trunk/LayoutTests/fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: [object DOMError]
+CONSOLE MESSAGE: Unhandled Promise Rejection: [object DOMError]
 PASS video.srcObject = stream did not throw exception.
 PASS video.duration is Number.POSITIVE_INFINITY
 PASS video.srcObject = null did not throw exception.

Modified: trunk/LayoutTests/http/tests/security/video-cross-origin-caching-expected.txt (216034 => 216035)


--- trunk/LayoutTests/http/tests/security/video-cross-origin-caching-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/http/tests/security/video-cross-origin-caching-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: [object DOMError]
+CONSOLE MESSAGE: Unhandled Promise Rejection: [object DOMError]
 
 This test passes if you do not see a CORS error.
 

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (216034 => 216035)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,3 +1,24 @@
+2017-05-01  Joseph Pecoraro  <[email protected]>
+
+        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.
+
+        * 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.
+
 2017-04-29  Joseph Pecoraro  <[email protected]>
 
         Zero out PerformanceResourceTiming properties for cached cross-origin responses without Timing-Allow-Origin

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/test_ecdh_bits-expected.txt (216034 => 216035)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/test_ecdh_bits-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/test_ecdh_bits-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: DataError (DOM Exception 30): Data provided to an operation does not meet requirements
+CONSOLE MESSAGE: line 198: Unhandled Promise Rejection: DataError (DOM Exception 30): Data provided to an operation does not meet requirements
 deriveBits Tests for ECDH
 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/test_ecdh_keys-expected.txt (216034 => 216035)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/test_ecdh_keys-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/test_ecdh_keys-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: DataError (DOM Exception 30): Data provided to an operation does not meet requirements
+CONSOLE MESSAGE: line 167: Unhandled Promise Rejection: DataError (DOM Exception 30): Data provided to an operation does not meet requirements
 deriveKey Tests for ECDH
 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/event_pause_noautoplay-expected.txt (216034 => 216035)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/event_pause_noautoplay-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/event_pause_noautoplay-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,5 +1,5 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: [object DOMError]
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: [object DOMError]
+CONSOLE MESSAGE: Unhandled Promise Rejection: [object DOMError]
+CONSOLE MESSAGE: Unhandled Promise Rejection: [object DOMError]
 spec reference
 
   

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/event_play_noautoplay-expected.txt (216034 => 216035)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/event_play_noautoplay-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/event_play_noautoplay-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,5 +1,5 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: [object DOMError]
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: [object DOMError]
+CONSOLE MESSAGE: Unhandled Promise Rejection: [object DOMError]
+CONSOLE MESSAGE: Unhandled Promise Rejection: [object DOMError]
 spec reference
 
   

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/paused_true_during_pause-expected.txt (216034 => 216035)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/paused_true_during_pause-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/paused_true_during_pause-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,5 +1,5 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: [object DOMError]
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: [object DOMError]
+CONSOLE MESSAGE: Unhandled Promise Rejection: [object DOMError]
+CONSOLE MESSAGE: Unhandled Promise Rejection: [object DOMError]
 spec reference
 
   

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/close-propagation-forward-expected.txt (216034 => 216035)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/close-propagation-forward-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/close-propagation-forward-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,19 +1,19 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
 
 Harness Error (FAIL), message = cancel() called on a reader owned by no readable stream
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/error-propagation-backward-expected.txt (216034 => 216035)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/error-propagation-backward-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/error-propagation-backward-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,5 +1,5 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error2: error2!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: line 12: Unhandled Promise Rejection: error2: error2!
+CONSOLE MESSAGE: Unhandled Promise Rejection: error1: error1!
 
 Harness Error (FAIL), message = error1!
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/error-propagation-forward-expected.txt (216034 => 216035)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/error-propagation-forward-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/error-propagation-forward-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,56 +1,56 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error2: error2!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error2: error2!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error2: error2!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error2: error2!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error2: error2!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: error1: error1!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 12: Unhandled Promise Rejection: error2: error2!
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 12: Unhandled Promise Rejection: error2: error2!
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 12: Unhandled Promise Rejection: error2: error2!
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 12: Unhandled Promise Rejection: error2: error2!
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 12: Unhandled Promise Rejection: error2: error2!
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: line 9: Unhandled Promise Rejection: error1: error1!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
 
 Harness Error (FAIL), message = cancel() called on a reader owned by no readable stream
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/flow-control-expected.txt (216034 => 216035)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/flow-control-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/flow-control-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: Error: assert_array_equals: close must always be called with the controller lengths differ, expected 1 got 0
+CONSOLE MESSAGE: Unhandled Promise Rejection: Error: assert_array_equals: close must always be called with the controller lengths differ, expected 1 got 0
 
 Harness Error (FAIL), message = assert_array_equals: close must always be called with the controller lengths differ, expected 1 got 0
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/general-expected.txt (216034 => 216035)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/general-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/general-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,16 +1,16 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: The WritableStream.ready getter can only be used on instances of WritableStream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 12: Unhandled Promise Rejection: TypeError: The WritableStream.ready getter can only be used on instances of WritableStream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
 CONSOLE MESSAGE: line 2684: TypeError: undefined is not an object (evaluating 'e.message')
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: undefined
+CONSOLE MESSAGE: Unhandled Promise Rejection: undefined
 CONSOLE MESSAGE: line 2684: TypeError: undefined is not an object (evaluating 'e.message')
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: undefined
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: undefined
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
 CONSOLE MESSAGE: line 2684: TypeError: undefined is not an object (evaluating 'e.message')
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: undefined
+CONSOLE MESSAGE: Unhandled Promise Rejection: undefined
 CONSOLE MESSAGE: line 2684: TypeError: undefined is not an object (evaluating 'e.message')
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: undefined
+CONSOLE MESSAGE: Unhandled Promise Rejection: undefined
 CONSOLE MESSAGE: line 2684: TypeError: undefined is not an object (evaluating 'e.message')
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: undefined
+CONSOLE MESSAGE: Unhandled Promise Rejection: undefined
 
 Harness Error (FAIL), message = The WritableStream.ready getter can only be used on instances of WritableStream
 

Added: trunk/LayoutTests/inspector/console/message-stack-trace-expected.txt (0 => 216035)


--- trunk/LayoutTests/inspector/console/message-stack-trace-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/console/message-stack-trace-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -0,0 +1,46 @@
+CONSOLE MESSAGE: line 18: error message
+CONSOLE MESSAGE: line 24: TypeError: undefined is not an object (evaluating '[].x.x')
+CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: rejection-1
+CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: rejection-2
+CONSOLE MESSAGE: line 40: Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating '[].x.x')
+Test for the Console.stackTrace in different cases.
+
+
+== Running test suite: Console.StackTrace
+-- Running test case: Console.StackTrace.ConsoleTrace
+CALL STACK:
+0: [F] (anonymous function)
+1: [F] triggerConsoleTrace
+
+-- Running test case: Console.StackTrace.ConsoleError
+CALL STACK:
+0: [F] (anonymous function)
+1: [F] triggerConsoleError
+
+-- Running test case: Console.StackTrace.UncaughtException
+Uncaught exception in test page: TypeError: undefined is not an object (evaluating '[].x.x') [message-stack-trace.html:24]
+CALL STACK:
+0: [F] (anonymous function)
+1: [F] triggerUncaughtException
+
+-- Running test case: Console.StackTrace.UnhandledPromiseRejection.PromiseReject
+CALL STACK:
+0: [N] (anonymous function)
+1: [N] rejectPromise
+2: [N] reject
+3: [F] triggerUnhandledRejectionPromiseReject
+
+-- Running test case: Console.StackTrace.UnhandledPromiseRejection.ExplicitReject
+CALL STACK:
+0: [N] (anonymous function)
+1: [N] rejectPromise
+2: [F] (anonymous function)
+3: [N] initializePromise
+4: [N] Promise
+5: [F] triggerUnhandledRejectionExplicit
+
+-- Running test case: Console.StackTrace.UnhandledPromiseRejection.ImplicitReject
+CALL STACK:
+0: [F] (anonymous function)
+1: [N] promiseReactionJob
+

Added: trunk/LayoutTests/inspector/console/message-stack-trace.html (0 => 216035)


--- trunk/LayoutTests/inspector/console/message-stack-trace.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/console/message-stack-trace.html	2017-05-01 22:24:37 UTC (rev 216035)
@@ -0,0 +1,131 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+TestPage.allowUncaughtExceptions = true;
+TestPage.needToSanitizeUncaughtExceptionURLs = true;
+
+function triggerConsoleTrace() {
+    (function() {
+        console.trace();
+    })();
+}
+
+function triggerConsoleError() {
+    (function() {
+        console.error("error message");
+    })();
+}
+
+function triggerUncaughtException() {
+    (function() {
+        [].x.x;
+    })();
+}
+
+function triggerUnhandledRejectionPromiseReject() {
+    window.promise1 = Promise.reject("rejection-1");
+}
+
+function triggerUnhandledRejectionExplicit() {
+    window.promise2 = new Promise((resolve, reject) => {
+        reject("rejection-2");
+    });
+}
+
+function triggerUnhandledRejectionImplicitWithException() {
+    window.promise3 = Promise.resolve().then(() => {
+        [].x.x;
+    });
+}
+
+
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("Console.StackTrace");
+
+    let messageChecker;
+    let untilPromiseResolver;
+
+    function untilMessageMatches(checker) {
+        messageChecker = checker;
+        return new Promise((resolve, reject) => {
+            untilPromiseResolver = resolve;
+        });
+    }
+
+    WebInspector.logManager.addEventListener(WebInspector.LogManager.Event.MessageAdded, (event) => {
+        let message = event.data.message;
+        InspectorTest.assert(message instanceof WebInspector.ConsoleMessage);
+        if (messageChecker && messageChecker(message)) {
+            messageChecker = null;
+            untilPromiseResolver(message);
+        }
+    });
+
+    function addTestCase({name, description, _expression_, condition}) {
+        suite.addTestCase({
+            name, description,
+            test(resolve, reject) {
+                InspectorTest.evaluateInPage(_expression_);
+                untilMessageMatches(condition).then((message) => {
+                    logConsoleMessageStackTrace(message);
+                }).then(resolve, reject);
+            }
+        });
+    }
+
+    // ----
+
+    addTestCase({
+        name: "Console.StackTrace.ConsoleTrace",
+        description: "StackTrace from console.trace().",
+        _expression_: `setTimeout(triggerConsoleTrace)`,
+        condition(message) { return message.type === WebInspector.ConsoleMessage.MessageType.Trace; },
+    });
+
+    addTestCase({
+        name: "Console.StackTrace.ConsoleError",
+        description: "StackTrace from console.error().",
+        _expression_: `setTimeout(triggerConsoleError)`,
+        condition(message) { return message.level === WebInspector.ConsoleMessage.MessageLevel.Error; },
+    });
+
+    addTestCase({
+        name: "Console.StackTrace.UncaughtException",
+        description: "StackTrace from an uncaught exception.",
+        _expression_: `setTimeout(triggerUncaughtException)`,
+        condition(message) { return message.level === WebInspector.ConsoleMessage.MessageLevel.Error; },
+    });
+
+    addTestCase({
+        name: "Console.StackTrace.UnhandledPromiseRejection.PromiseReject",
+        description: "StackTrace from an unhandled promise rejection via Promise.reject(...).",
+        _expression_: `setTimeout(triggerUnhandledRejectionPromiseReject)`,
+        condition(message) { return message.level === WebInspector.ConsoleMessage.MessageLevel.Error; },
+    });
+
+    addTestCase({
+        name: "Console.StackTrace.UnhandledPromiseRejection.ExplicitReject",
+        description: "StackTrace from an unhandled promise rejection via reject(...).",
+        _expression_: `setTimeout(triggerUnhandledRejectionExplicit)`,
+        condition(message) { return message.level === WebInspector.ConsoleMessage.MessageLevel.Error; },
+    });
+
+    addTestCase({
+        name: "Console.StackTrace.UnhandledPromiseRejection.ImplicitReject",
+        description: "StackTrace from an unhandled promise rejection due to an uncaught exception in a promise reaction.",
+        _expression_: `setTimeout(triggerUnhandledRejectionImplicitWithException)`,
+        condition(message) { return message.level === WebInspector.ConsoleMessage.MessageLevel.Error; },
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Test for the Console.stackTrace in different cases.</p>
+</body>
+</html>

Added: trunk/LayoutTests/inspector/console/resources/log-console-stack-trace.js (0 => 216035)


--- trunk/LayoutTests/inspector/console/resources/log-console-stack-trace.js	                        (rev 0)
+++ trunk/LayoutTests/inspector/console/resources/log-console-stack-trace.js	2017-05-01 22:24:37 UTC (rev 216035)
@@ -0,0 +1,49 @@
+TestPage.registerInitializer(() => {
+    window.logConsoleMessageStackTrace = function(consoleMessage) {
+        let stackTrace = consoleMessage.stackTrace;
+        let foundAsyncBoundary = false;
+        let callFrameIndex = 0;
+
+        function logCallFrame(callFrame, isAsyncBoundary) {
+            let label = callFrame.functionName || "(anonymous function)";
+            if (isAsyncBoundary)
+                InspectorTest.log(`${callFrameIndex}: --- ${label} ---`);
+            else {
+                let code = callFrame.nativeCode ? "N" : (callFrame.programCode ? "P" : "F");
+                InspectorTest.log(`${callFrameIndex}: [${code}] ${label}`);
+            }
+            callFrameIndex++;
+        }
+
+        InspectorTest.log("CALL STACK:");
+
+        while (stackTrace) {
+            let callFrames = stackTrace.callFrames;
+            let topCallFrameIsBoundary = stackTrace.topCallFrameIsBoundary;
+            let truncated = stackTrace.truncated;
+            stackTrace = stackTrace.parentStackTrace;
+            if (!callFrames || !callFrames.length)
+                continue;
+
+            if (topCallFrameIsBoundary) {
+                if (!foundAsyncBoundary) {
+                    InspectorTest.log("ASYNC CALL STACK:");
+                    foundAsyncBoundary = true;
+                }
+                logCallFrame(callFrames[0], true);
+            }
+
+            for (let i = topCallFrameIsBoundary ? 1 : 0; i < callFrames.length; ++i) {
+                let callFrame = callFrames[i];
+                logCallFrame(callFrame);
+
+                // Skip call frames after the test harness entry point.
+                if (callFrame.programCode)
+                    break;
+            }
+
+            if (truncated)
+                InspectorTest.log("(remaining call frames truncated)");
+        }
+    }
+});

Modified: trunk/LayoutTests/inspector/debugger/break-on-exception-throw-in-promise-expected.txt (216034 => 216035)


--- trunk/LayoutTests/inspector/debugger/break-on-exception-throw-in-promise-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/inspector/debugger/break-on-exception-throw-in-promise-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,12 +1,12 @@
 CONSOLE MESSAGE: line 36: testThrowingInPromise
 CONSOLE MESSAGE: line 38: in promise
 CONSOLE MESSAGE: line 7: throwing TestError
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TestError
+CONSOLE MESSAGE: line 8: Unhandled Promise Rejection: TestError
 CONSOLE MESSAGE: line 55: testThrowingInPromiseThen
 CONSOLE MESSAGE: line 57: in promise
 CONSOLE MESSAGE: line 60: in promise.then
 CONSOLE MESSAGE: line 7: throwing TestError
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TestError
+CONSOLE MESSAGE: line 8: Unhandled Promise Rejection: TestError
 CONSOLE MESSAGE: line 66: testThrowingInPromiseThenWithCatch
 CONSOLE MESSAGE: line 68: in promise
 CONSOLE MESSAGE: line 71: in promise.then
@@ -22,7 +22,7 @@
 CONSOLE MESSAGE: line 82: in promise
 CONSOLE MESSAGE: line 7: throwing TestError
 CONSOLE MESSAGE: line 85: in promise.catch
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TestError
+CONSOLE MESSAGE: line 86: Unhandled Promise Rejection: TestError
 Checking pause locations within Promises when pausing on all exceptions.
 
 

Modified: trunk/LayoutTests/inspector/debugger/break-on-uncaught-exception-throw-in-promise-expected.txt (216034 => 216035)


--- trunk/LayoutTests/inspector/debugger/break-on-uncaught-exception-throw-in-promise-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/inspector/debugger/break-on-uncaught-exception-throw-in-promise-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,12 +1,12 @@
 CONSOLE MESSAGE: line 36: testThrowingInPromise
 CONSOLE MESSAGE: line 38: in promise
 CONSOLE MESSAGE: line 7: throwing TestError
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TestError
+CONSOLE MESSAGE: line 8: Unhandled Promise Rejection: TestError
 CONSOLE MESSAGE: line 55: testThrowingInPromiseThen
 CONSOLE MESSAGE: line 57: in promise
 CONSOLE MESSAGE: line 60: in promise.then
 CONSOLE MESSAGE: line 7: throwing TestError
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TestError
+CONSOLE MESSAGE: line 8: Unhandled Promise Rejection: TestError
 CONSOLE MESSAGE: line 66: testThrowingInPromiseThenWithCatch
 CONSOLE MESSAGE: line 68: in promise
 CONSOLE MESSAGE: line 71: in promise.then
@@ -22,7 +22,7 @@
 CONSOLE MESSAGE: line 82: in promise
 CONSOLE MESSAGE: line 7: throwing TestError
 CONSOLE MESSAGE: line 85: in promise.catch
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TestError
+CONSOLE MESSAGE: line 86: Unhandled Promise Rejection: TestError
 Checking no pauses within Promises when pausing on uncaught exceptions.
 
 

Modified: trunk/LayoutTests/js/dom/unhandled-promise-rejection-bindings-type-error-expected.txt (216034 => 216035)


--- trunk/LayoutTests/js/dom/unhandled-promise-rejection-bindings-type-error-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/js/dom/unhandled-promise-rejection-bindings-type-error-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: The PromiseRejectionEvent.promise getter can only be used on instances of PromiseRejectionEvent
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: The PromiseRejectionEvent.promise getter can only be used on instances of PromiseRejectionEvent
 Test rejected promises are returned from bindings and trigger unhandledrejection.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".

Modified: trunk/LayoutTests/js/dom/unhandled-promise-rejection-console-report-expected.txt (216034 => 216035)


--- trunk/LayoutTests/js/dom/unhandled-promise-rejection-console-report-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/js/dom/unhandled-promise-rejection-console-report-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,6 +1,6 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: 0
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: 1
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: 2
+CONSOLE MESSAGE: Unhandled Promise Rejection: 0
+CONSOLE MESSAGE: Unhandled Promise Rejection: 1
+CONSOLE MESSAGE: Unhandled Promise Rejection: 2
 Test unhandled promise rejection event produces console messages. The test passes when you see 3 console messages for unhandled promise rejections.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".

Modified: trunk/LayoutTests/js/promises-tests/promises-tests-2-2-6-expected.txt (216034 => 216035)


--- trunk/LayoutTests/js/promises-tests/promises-tests-2-2-6-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/js/promises-tests/promises-tests-2-2-6-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,9 +1,9 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: [object Object]
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: [object Object]
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: [object Object]
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: [object Object]
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: [object Object]
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: [object Object]
+CONSOLE MESSAGE: line 6077: Unhandled Promise Rejection: [object Object]
+CONSOLE MESSAGE: line 6077: Unhandled Promise Rejection: [object Object]
+CONSOLE MESSAGE: line 6077: Unhandled Promise Rejection: [object Object]
+CONSOLE MESSAGE: line 6077: Unhandled Promise Rejection: [object Object]
+CONSOLE MESSAGE: line 6077: Unhandled Promise Rejection: [object Object]
+CONSOLE MESSAGE: line 6077: Unhandled Promise Rejection: [object Object]
 Test Promise with Promise A+ tests 2.2.6.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".

Modified: trunk/LayoutTests/streams/reference-implementation/pipe-to-options-expected.txt (216034 => 216035)


--- trunk/LayoutTests/streams/reference-implementation/pipe-to-options-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/streams/reference-implementation/pipe-to-options-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,7 +1,7 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: Error: destination error
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: Error: destination error
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: Error: destination error
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: Error: destination error
+CONSOLE MESSAGE: Unhandled Promise Rejection: Error: destination error
+CONSOLE MESSAGE: Unhandled Promise Rejection: Error: destination error
+CONSOLE MESSAGE: Unhandled Promise Rejection: Error: destination error
+CONSOLE MESSAGE: Unhandled Promise Rejection: Error: destination error
 
 Harness Error (FAIL), message = destination error
 

Modified: trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt (216034 => 216035)


--- trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,19 +1,19 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: Error: boo!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: Error: boo!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: Error: boo!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: Error: boo!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: Error: boo!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: Error: !!!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: Error: !!!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: Error: !!!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: Error: !!!
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 361: Unhandled Promise Rejection: Error: boo!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 361: Unhandled Promise Rejection: Error: boo!
+CONSOLE MESSAGE: line 361: Unhandled Promise Rejection: Error: boo!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 361: Unhandled Promise Rejection: Error: boo!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: line 361: Unhandled Promise Rejection: Error: boo!
+CONSOLE MESSAGE: Unhandled Promise Rejection: Error: !!!
+CONSOLE MESSAGE: Unhandled Promise Rejection: Error: !!!
+CONSOLE MESSAGE: Unhandled Promise Rejection: Error: !!!
+CONSOLE MESSAGE: Unhandled Promise Rejection: Error: !!!
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: cancel() called on a reader owned by no readable stream
 
 Harness Error (FAIL), message = cancel() called on a reader owned by no readable stream
 

Modified: trunk/LayoutTests/streams/reference-implementation/writable-stream-abort-expected.txt (216034 => 216035)


--- trunk/LayoutTests/streams/reference-implementation/writable-stream-abort-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/streams/reference-implementation/writable-stream-abort-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,30 +1,30 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: a
+CONSOLE MESSAGE: Unhandled Promise Rejection: a
 CONSOLE MESSAGE: line 2687: TypeError: undefined is not an object (evaluating 'e.message')
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: undefined
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: Error: Sorry, it just wasn't meant to be.
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: Error: Sorry, it just wasn't meant to be.
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: Error: Sorry, it just wasn't meant to be.
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: Error: Sorry, it just wasn't meant to be.
+CONSOLE MESSAGE: Unhandled Promise Rejection: undefined
+CONSOLE MESSAGE: Unhandled Promise Rejection: Error: Sorry, it just wasn't meant to be.
+CONSOLE MESSAGE: Unhandled Promise Rejection: Error: Sorry, it just wasn't meant to be.
+CONSOLE MESSAGE: Unhandled Promise Rejection: Error: Sorry, it just wasn't meant to be.
+CONSOLE MESSAGE: Unhandled Promise Rejection: Error: Sorry, it just wasn't meant to be.
 CONSOLE MESSAGE: line 2687: TypeError: undefined is not an object (evaluating 'e.message')
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: undefined
+CONSOLE MESSAGE: Unhandled Promise Rejection: undefined
 CONSOLE MESSAGE: line 2687: TypeError: undefined is not an object (evaluating 'e.message')
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: undefined
+CONSOLE MESSAGE: Unhandled Promise Rejection: undefined
 CONSOLE MESSAGE: line 2687: TypeError: undefined is not an object (evaluating 'e.message')
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: undefined
+CONSOLE MESSAGE: Unhandled Promise Rejection: undefined
 CONSOLE MESSAGE: line 2687: TypeError: undefined is not an object (evaluating 'e.message')
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: undefined
+CONSOLE MESSAGE: Unhandled Promise Rejection: undefined
 CONSOLE MESSAGE: line 2687: TypeError: undefined is not an object (evaluating 'e.message')
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: undefined
+CONSOLE MESSAGE: Unhandled Promise Rejection: undefined
 CONSOLE MESSAGE: line 2687: TypeError: undefined is not an object (evaluating 'e.message')
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: undefined
+CONSOLE MESSAGE: Unhandled Promise Rejection: undefined
 CONSOLE MESSAGE: line 2687: TypeError: undefined is not an object (evaluating 'e.message')
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: undefined
+CONSOLE MESSAGE: Unhandled Promise Rejection: undefined
 CONSOLE MESSAGE: line 2687: TypeError: undefined is not an object (evaluating 'e.message')
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: undefined
+CONSOLE MESSAGE: Unhandled Promise Rejection: undefined
 CONSOLE MESSAGE: line 2687: TypeError: undefined is not an object (evaluating 'e.message')
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: undefined
+CONSOLE MESSAGE: Unhandled Promise Rejection: undefined
 CONSOLE MESSAGE: line 2687: TypeError: undefined is not an object (evaluating 'e.message')
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: undefined
+CONSOLE MESSAGE: Unhandled Promise Rejection: undefined
 
 Harness Error (FAIL), message = TypeError: undefined is not an object (evaluating 'e.message')
 

Modified: trunk/LayoutTests/streams/reference-implementation/writable-stream-expected.txt (216034 => 216035)


--- trunk/LayoutTests/streams/reference-implementation/writable-stream-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/streams/reference-implementation/writable-stream-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,5 +1,5 @@
 CONSOLE MESSAGE: line 2687: TypeError: undefined is not an object (evaluating 'e.message')
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: undefined
+CONSOLE MESSAGE: Unhandled Promise Rejection: undefined
 
 Harness Error (FAIL), message = TypeError: undefined is not an object (evaluating 'e.message')
 

Modified: trunk/LayoutTests/webrtc/libwebrtc/release-while-creating-offer-expected.txt (216034 => 216035)


--- trunk/LayoutTests/webrtc/libwebrtc/release-while-creating-offer-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/webrtc/libwebrtc/release-while-creating-offer-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: Argument 1 ('candidate') to RTCPeerConnection.addIceCandidate must be an instance of RTCIceCandidate
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: Argument 1 ('candidate') to RTCPeerConnection.addIceCandidate must be an instance of RTCIceCandidate
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/webrtc/libwebrtc/release-while-setting-local-description-expected.txt (216034 => 216035)


--- trunk/LayoutTests/webrtc/libwebrtc/release-while-setting-local-description-expected.txt	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/LayoutTests/webrtc/libwebrtc/release-while-setting-local-description-expected.txt	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,5 +1,5 @@
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: TypeError: Argument 1 ('candidate') to RTCPeerConnection.addIceCandidate must be an instance of RTCIceCandidate
-CONSOLE MESSAGE: line 1: Unhandled Promise Rejection: InvalidStateError (DOM Exception 11): The object is in an invalid state.
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: Argument 1 ('candidate') to RTCPeerConnection.addIceCandidate must be an instance of RTCIceCandidate
+CONSOLE MESSAGE: Unhandled Promise Rejection: InvalidStateError (DOM Exception 11): The object is in an invalid state.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/Source/WebCore/ChangeLog (216034 => 216035)


--- trunk/Source/WebCore/ChangeLog	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/Source/WebCore/ChangeLog	2017-05-01 22:24:37 UTC (rev 216035)
@@ -1,3 +1,32 @@
+2017-05-01  Joseph Pecoraro  <[email protected]>
+
+        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.
+
+        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.
+
 2017-05-01  Jer Noble  <[email protected]>
 
         Unreviewed build fix after r216033.

Modified: trunk/Source/WebCore/dom/RejectedPromiseTracker.cpp (216034 => 216035)


--- trunk/Source/WebCore/dom/RejectedPromiseTracker.cpp	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/Source/WebCore/dom/RejectedPromiseTracker.cpp	2017-05-01 22:24:37 UTC (rev 216035)
@@ -78,19 +78,19 @@
 
 class UnhandledPromise : public RejectedPromise {
 public:
-    UnhandledPromise(VM& vm, JSDOMGlobalObject& globalObject, JSPromise& promise, Ref<ScriptCallStack>&& stack)
+    UnhandledPromise(VM& vm, JSDOMGlobalObject& globalObject, JSPromise& promise, RefPtr<ScriptCallStack>&& stack)
         : RejectedPromise(vm, globalObject, promise)
         , m_stack(WTFMove(stack))
     {
     }
 
-    ScriptCallStack& callStack()
+    ScriptCallStack* callStack()
     {
         return m_stack.get();
     }
 
 private:
-    Ref<ScriptCallStack> m_stack;
+    RefPtr<ScriptCallStack> m_stack;
 };
 
 
@@ -104,12 +104,21 @@
 {
 }
 
-static Ref<ScriptCallStack> createScriptCallStackFromReason(ExecState& state, JSValue reason)
+static RefPtr<ScriptCallStack> createScriptCallStackFromReason(ExecState& state, JSValue reason)
 {
     VM& vm = state.vm();
-    if (auto* exception = jsDynamicCast<JSC::Exception*>(vm, reason))
-        return createScriptCallStackFromException(&state, exception, ScriptCallStack::maxCallStackSizeToCapture);
-    return createScriptCallStack(&state, ScriptCallStack::maxCallStackSizeToCapture);
+
+    // Always capture a stack from the exception if this rejection was an exception.
+    if (auto* exception = vm.lastException()) {
+        if (exception->value() == reason)
+            return createScriptCallStackFromException(&state, exception, ScriptCallStack::maxCallStackSizeToCapture);
+    }
+
+    // Otherwise, only capture a stack if a debugger is open.
+    if (state.lexicalGlobalObject()->debugger())
+        return createScriptCallStack(&state, ScriptCallStack::maxCallStackSizeToCapture);
+
+    return nullptr;
 }
 
 void RejectedPromiseTracker::promiseRejected(ExecState& state, JSDOMGlobalObject& globalObject, JSPromise& promise)

Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.cpp (216034 => 216035)


--- trunk/Source/WebCore/dom/ScriptExecutionContext.cpp	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.cpp	2017-05-01 22:24:37 UTC (rev 216035)
@@ -382,7 +382,7 @@
         logExceptionToConsole(exception->m_errorMessage, exception->m_sourceURL, exception->m_lineNumber, exception->m_columnNumber, WTFMove(exception->m_callStack));
 }
 
-void ScriptExecutionContext::reportUnhandledPromiseRejection(JSC::ExecState& state, JSC::JSPromise& promise, Inspector::ScriptCallStack& callStack)
+void ScriptExecutionContext::reportUnhandledPromiseRejection(JSC::ExecState& state, JSC::JSPromise& promise, RefPtr<Inspector::ScriptCallStack>&& callStack)
 {
     JSC::VM& vm = state.vm();
     auto scope = DECLARE_CATCH_SCOPE(vm);
@@ -394,13 +394,15 @@
     JSC::JSValue result = promise.result(vm);
     String resultMessage = retrieveErrorMessage(state, vm, result, scope);
     String errorMessage = makeString("Unhandled Promise Rejection: ", resultMessage);
-    if (const ScriptCallFrame* callFrame = callStack.firstNonNativeCallFrame()) {
-        lineNumber = callFrame->lineNumber();
-        columnNumber = callFrame->columnNumber();
-        sourceURL = callFrame->sourceURL();
+    if (callStack) {
+        if (const ScriptCallFrame* callFrame = callStack->firstNonNativeCallFrame()) {
+            lineNumber = callFrame->lineNumber();
+            columnNumber = callFrame->columnNumber();
+            sourceURL = callFrame->sourceURL();
+        }
     }
 
-    logExceptionToConsole(errorMessage, sourceURL, lineNumber, columnNumber, &callStack);
+    logExceptionToConsole(errorMessage, sourceURL, lineNumber, columnNumber, WTFMove(callStack));
 }
 
 void ScriptExecutionContext::addConsoleMessage(MessageSource source, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, JSC::ExecState* state, unsigned long requestIdentifier)

Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.h (216034 => 216035)


--- trunk/Source/WebCore/dom/ScriptExecutionContext.h	2017-05-01 22:03:15 UTC (rev 216034)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.h	2017-05-01 22:24:37 UTC (rev 216035)
@@ -96,7 +96,7 @@
 
     bool sanitizeScriptError(String& errorMessage, int& lineNumber, int& columnNumber, String& sourceURL, JSC::Strong<JSC::Unknown>& error, CachedScript* = nullptr);
     void reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, JSC::Exception*, RefPtr<Inspector::ScriptCallStack>&&, CachedScript* = nullptr);
-    void reportUnhandledPromiseRejection(JSC::ExecState&, JSC::JSPromise&, Inspector::ScriptCallStack&);
+    void reportUnhandledPromiseRejection(JSC::ExecState&, JSC::JSPromise&, RefPtr<Inspector::ScriptCallStack>&&);
 
     void addConsoleMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0);
     virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) = 0;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to