2016-11-26 23:35:11 +00:00
|
|
|
/*
|
|
|
|
* This file is intended for vendors to implement
|
|
|
|
* code needed to integrate testharness.js tests with their own test systems.
|
|
|
|
*
|
|
|
|
* Typically such integration will attach callbacks when each test is
|
|
|
|
* has run, using add_result_callback(callback(test)), or when the whole test file has
|
|
|
|
* completed, using add_completion_callback(callback(tests, harness_status)).
|
|
|
|
*
|
|
|
|
* For more documentation about the callback functions and the
|
|
|
|
* parameters they are called with see testharness.js
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Setup for WebKit JavaScript tests
|
|
|
|
if (self.testRunner) {
|
|
|
|
testRunner.dumpAsText();
|
|
|
|
testRunner.waitUntilDone();
|
|
|
|
testRunner.setCanOpenWindows();
|
2017-05-17 17:23:20 +00:00
|
|
|
testRunner.grantWebNotificationPermission("http://localhost:8800");
|
2016-11-26 23:35:11 +00:00
|
|
|
// Let's restrict calling testharness timeout() to wptserve tests for the moment.
|
|
|
|
// That will limit the impact to a small number of tests.
|
|
|
|
// The risk is that testharness timeout() might be called to late on slow bots to finish properly.
|
2017-10-29 05:31:44 +00:00
|
|
|
if (testRunner.timeout && (location.port == 8800 || location.port == 9443))
|
2016-11-26 23:35:11 +00:00
|
|
|
setTimeout(timeout, testRunner.timeout * 0.9);
|
2018-04-06 20:05:46 +00:00
|
|
|
|
|
|
|
if (location.port == 8800 || location.port == 9443) {
|
2020-09-14 17:00:56 +00:00
|
|
|
if (self.internals) {
|
|
|
|
// Use 44100 sample rate by default instead of the hardware sample rate so that we get consistent results across machines.
|
|
|
|
internals.settings.setDefaultAudioContextSampleRate(44100);
|
|
|
|
}
|
2018-04-06 20:05:46 +00:00
|
|
|
}
|
2019-09-27 05:13:10 +00:00
|
|
|
|
|
|
|
if (testRunner.setStatisticsShouldDowngradeReferrer)
|
|
|
|
testRunner.setStatisticsShouldDowngradeReferrer(false, function() { });
|
2016-11-26 23:35:11 +00:00
|
|
|
}
|
|
|
|
|
2017-07-11 21:07:49 +00:00
|
|
|
if (self.internals && internals.setICECandidateFiltering)
|
2017-07-11 15:32:38 +00:00
|
|
|
internals.setICECandidateFiltering(false);
|
|
|
|
|
2016-11-26 23:35:11 +00:00
|
|
|
// Function used to convert the test status code into
|
|
|
|
// the corresponding string
|
|
|
|
function convertResult(resultStatus)
|
|
|
|
{
|
|
|
|
if(resultStatus == 0)
|
|
|
|
return("PASS");
|
|
|
|
else if(resultStatus == 1)
|
|
|
|
return("FAIL");
|
|
|
|
else if(resultStatus == 2)
|
|
|
|
return("TIMEOUT");
|
|
|
|
else
|
|
|
|
return("NOTRUN");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (self.testRunner) {
|
|
|
|
/* Disable the default output of testharness.js. The default output formats
|
|
|
|
* test results into an HTML table. When that table is dumped as text, no
|
|
|
|
* spacing between cells is preserved, and it is therefore not readable. By
|
|
|
|
* setting output to false, the HTML table will not be created
|
|
|
|
*/
|
|
|
|
setup({"output": false, "explicit_timeout": true});
|
|
|
|
|
Support for promise rejection events (unhandledrejection)
https://bugs.webkit.org/show_bug.cgi?id=150358
<rdar://problem/28441651>
Reviewed by Saam Barati.
Patch by Joseph Pecoraro and Yusuke Suzuki.
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/html/syntax/parsing/html5lib_innerHTML_adoption01-expected.txt:
* web-platform-tests/html/webappapis/scripting/events/body-exposed-window-event-handlers-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:
* web-platform-tests/user-timing/measure_exceptions_navigation_timing-expected.txt:
Rebaseline expectations to include unhandled promise rejection messages.
Also change how the test harness reports success or failure to use the values
immediately on completion and then allow a run loop cycle before completing
the test to gather the output.
* web-platform-tests/resource-timing/rt-resource-errors.html:
This is our own WPT test yet to be uploaded, so update the test to prevent
an unexpected unhandled rejection.
Source/JavaScriptCore:
Implement support for promise.[[PromiseIsHandled]] and the
HostPromiseRejectionTracker hook for HTML to track promise rejections:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
* builtins/BuiltinNames.h:
New private symbols.
* builtins/PromiseOperations.js:
(globalPrivate.newHandledRejectedPromise):
Utility to create a rejected promise with [[PromiseIsHandled]] to true.
(globalPrivate.rejectPromise):
(globalPrivate.initializePromise):
* builtins/PromisePrototype.js:
(then):
Implement standard behavior of [[PromiseIsHandled]] and the host hook.
* runtime/JSPromise.cpp:
(JSC::JSPromise::isHandled):
* runtime/JSPromise.h:
C++ accessors for the [[PromiseIsHandled]] state.
* bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
* bytecode/BytecodeIntrinsicRegistry.h:
Expose private values for the Reject / Handle enum values in built-ins.
* jsc.cpp:
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::promiseResolveFunction):
Add a new GlobalObjectMethodTable hook matching the promise rejection hook.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncHostPromiseRejectionTracker):
* runtime/JSGlobalObjectFunctions.h:
Plumb the builtin hook through to the optional GlobalObjectMethodTable hook.
* inspector/InjectedScriptSource.js:
(InjectedScript.prototype.createFakeValueDescriptor):
Silence possible rejected promises created internally via Web Inspector.
Source/WebCore:
Implement support for the `onunhandledrejection` and `rejectionhandled` events.
They dispatch a new PromiseRejectionEvent using the ES6 HostPromiseRejectionTracker hook:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
This is currently implemented only for Documents and not yet Web Workers.
Tests: js/dom/unhandled-promise-rejection-basic.html
js/dom/unhandled-promise-rejection-bindings-type-error.html
js/dom/unhandled-promise-rejection-console-no-report.html
js/dom/unhandled-promise-rejection-console-report.html
js/dom/unhandled-promise-rejection-handle-during-event.html
js/dom/unhandled-promise-rejection-handle-in-handler.html
js/dom/unhandled-promise-rejection-handle.html
js/dom/unhandled-promise-rejection-order.html
* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
New files.
* bindings/scripts/CodeGenerator.pm:
(IsPromiseType):
* bindings/scripts/CodeGeneratorJS.pm:
(AddToIncludesForIDLType):
(GetBaseIDLType):
Binding support for Promise<T> attributes.
* bindings/js/JSDOMConvert.h:
* bindings/js/JSDOMConvertPromise.h: Copied from Source/JavaScriptCore/runtime/JSPromise.h.
(WebCore::Converter<IDLPromise<T>>::convert):
(WebCore::JSConverter<IDLPromise<T>>::convert):
Promise<T> binding conversion is currently unimplemented, which only means
web developers creating their own PromiseRejectionEvent will not get
autowrapping of values assigned to `promise` in event initialization.
Engine generated events will have expected behavior.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::promiseRejectionTracker):
* bindings/js/JSDOMWindowBase.h:
* bindings/js/JSWorkerGlobalScopeBase.cpp:
Implement HostPromiseRejectionTracker hook for Document but not Worker.
Passes through to the ScriptExecutionContext's tracker.
* bindings/js/JSMainThreadExecState.cpp:
(WebCore::JSMainThreadExecState::didLeaveScriptContext):
* bindings/js/JSMainThreadExecState.h:
(WebCore::JSMainThreadExecState::~JSMainThreadExecState):
When completing script execution and performing microtasks notify
about rejected promises. Technically this should go inside of
performing a microtask checkpoint, except lacking EventLoop
concepts we use ScriptExecutionState.
* dom/EventNames.h:
* dom/EventNames.in:
* dom/PromiseRejectionEvent.cpp: Added.
(WebCore::PromiseRejectionEvent::PromiseRejectionEvent):
(WebCore::PromiseRejectionEvent::~PromiseRejectionEvent):
* dom/PromiseRejectionEvent.h: Added.
* dom/PromiseRejectionEvent.idl: Added.
New PromiseRejectionEvent event interface.
* dom/GlobalEventHandlers.idl:
New onunhandledrejection and onrejectionhandled.
* dom/RejectedPromiseTracker.cpp: Added.
(WebCore::RejectedPromise::RejectedPromise):
(WebCore::RejectedPromise::globalObject):
(WebCore::RejectedPromise::promise):
(WebCore::UnhandledPromise::UnhandledPromise):
(WebCore::UnhandledPromise::callStack):
(WebCore::RejectedPromiseTracker::RejectedPromiseTracker):
(WebCore::RejectedPromiseTracker::~RejectedPromiseTracker):
(WebCore::createScriptCallStackFromReason):
(WebCore::RejectedPromiseTracker::promiseRejected):
(WebCore::RejectedPromiseTracker::promiseHandled):
(WebCore::RejectedPromiseTracker::processQueueSoon):
(WebCore::RejectedPromiseTracker::reportUnhandledRejections):
(WebCore::RejectedPromiseTracker::reportRejectionHandled):
* dom/RejectedPromiseTracker.h: Added.
Track and report rejected promises. The promises are tracked weakly
allowing them to be collected before they are reported. When reporting
we dispatch PromiseRejectionEvent events, and if the default is not
prevented we log a message to the console.
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::reportUnhandledPromiseRejection):
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTrackerSlow):
* dom/ScriptExecutionContext.h:
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTracker):
Each ScriptExecutionContext can own a rejected promise tracker.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::pauseInternal):
https://html.spec.whatwg.org/multipage/embedded-content.html#internal-pause-steps
Internal pause steps say to timeupdate, pause, and rejecting pending play promises
should all happen in a queued task. Here the first two actions are already scheduled
on tasks, but rejecting play promises was not being done in a task, so this makes
that change.
* Modules/streams/ReadableStream.js:
(pipeThrough):
* Modules/streams/ReadableStreamInternals.js:
(readableStreamReaderGenericInitialize):
(readableStreamError):
(readableStreamReaderGenericRelease):
Satisfy parts of the Streams specification which state to set the
[[PromiseIsHandled]] internal state of promises created internally
by the Streams APIs. This prevents some internal promises from
appearing as unhandled promise rejections.
LayoutTests:
* js/dom/unhandled-promise-rejection-basic-expected.txt: Added.
* js/dom/unhandled-promise-rejection-basic.html: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error-expected.txt: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error.html: Added.
* js/dom/unhandled-promise-rejection-console-no-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-no-report.html: Added.
* js/dom/unhandled-promise-rejection-console-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-report.html: Added.
* js/dom/unhandled-promise-rejection-handle-during-event-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-during-event.html: Added.
* js/dom/unhandled-promise-rejection-handle-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler.html: Added.
* js/dom/unhandled-promise-rejection-handle.html: Added.
* js/dom/unhandled-promise-rejection-order-expected.txt: Added.
* js/dom/unhandled-promise-rejection-order.html: Added.
New tests specific to the `onunhandledrejection` and `onrejectionhandled` events.
* resources/testharnessreport.js:
(self.testRunner.add_completion_callback.sanitize):
(self.testRunner.add_completion_callback):
Report results immediately and then finish the test after a turn. This way
if the test ends with a pass, but may get unhandled rejections after
completing which should not make the test appear as if it failed. Some tests
have unhandled promise rejections but are expected to pass. Likewise some
tests perform cleanup in their own completion callbacks, which happen after
this initial completion callback, and we want to report results after all
the work is done as it may eliminate non-deterministic debug test output.
* TestExpectations:
Mark some tests as flakey that have sometimes have unhandled promise rejections.
These tests are all various imported tests that use the testharness.
* fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt:
* http/tests/security/video-cross-origin-caching-expected.txt:
* inspector/debugger/break-on-exception-throw-in-promise-expected.txt:
* inspector/debugger/break-on-uncaught-exception-throw-in-promise-expected.txt:
* inspector/worker/resources-in-worker-expected.txt:
* js/dom/dom-static-property-for-in-iteration-expected.txt:
* js/dom/global-constructors-attributes-dedicated-worker-expected.txt:
* js/promises-tests/promises-tests-2-2-6-expected.txt:
* platform/mac/inspector/model/remote-object-expected.txt:
* webrtc/libwebrtc/release-while-creating-offer-expected.txt:
* webrtc/libwebrtc/release-while-setting-local-description-expected.txt:
Update tests with unhandled promise rejection messages.
* media/W3C/audio/events/event_pause_manual.html:
* media/audio-playback-restriction-play-expected.txt:
* media/audio-playback-restriction-play.html:
* media/click-volume-bar-not-pausing.html:
* media/remote-control-command-is-user-gesture-expected.txt:
* media/remote-control-command-is-user-gesture.html:
* media/track/track-mode.html:
* media/video-autoplay-allowed-but-fullscreen-required.html:
* media/video-display-none-crash.html:
* media/video-main-content-deny-display-none.html:
* media/video-main-content-deny-not-in-dom.html:
* media/video-main-content-deny-not-visible.html:
* media/video-main-content-deny-obscured.html:
* media/video-main-content-deny-too-small.html:
* media/video-multiple-concurrent-playback-expected.txt:
* media/video-play-audio-require-user-gesture-expected.txt:
* media/video-play-audio-require-user-gesture.html:
* media/video-play-pause-events-expected.txt:
* media/video-play-pause-events.html:
* media/video-play-pause-exception-expected.txt:
* media/video-play-pause-exception.html:
* media/video-play-require-user-gesture-expected.txt:
* media/video-play-require-user-gesture.html:
* media/video-preload-expected.txt:
* media/video-preload.html:
* media/video-test.js:
(handlePromise.handle):
Snuff many possible unhandled promise rejections in media via media.play().
* streams/reference-implementation/pipe-to-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:
These stream tests are out of date and produce unhandled rejections.
* streams/shadowing-Promise.html:
Update non-imported tests to prevent unhandled rejection messages.
Canonical link: https://commits.webkit.org/188310@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215916 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-28 03:33:57 +00:00
|
|
|
/* Using a callback function, test results will be added to the page in a
|
2016-11-26 23:35:11 +00:00
|
|
|
* manner that allows dumpAsText to produce readable test results
|
|
|
|
*/
|
|
|
|
add_completion_callback(function (tests, harness_status) {
|
Support for promise rejection events (unhandledrejection)
https://bugs.webkit.org/show_bug.cgi?id=150358
<rdar://problem/28441651>
Reviewed by Saam Barati.
Patch by Joseph Pecoraro and Yusuke Suzuki.
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/html/syntax/parsing/html5lib_innerHTML_adoption01-expected.txt:
* web-platform-tests/html/webappapis/scripting/events/body-exposed-window-event-handlers-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:
* web-platform-tests/user-timing/measure_exceptions_navigation_timing-expected.txt:
Rebaseline expectations to include unhandled promise rejection messages.
Also change how the test harness reports success or failure to use the values
immediately on completion and then allow a run loop cycle before completing
the test to gather the output.
* web-platform-tests/resource-timing/rt-resource-errors.html:
This is our own WPT test yet to be uploaded, so update the test to prevent
an unexpected unhandled rejection.
Source/JavaScriptCore:
Implement support for promise.[[PromiseIsHandled]] and the
HostPromiseRejectionTracker hook for HTML to track promise rejections:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
* builtins/BuiltinNames.h:
New private symbols.
* builtins/PromiseOperations.js:
(globalPrivate.newHandledRejectedPromise):
Utility to create a rejected promise with [[PromiseIsHandled]] to true.
(globalPrivate.rejectPromise):
(globalPrivate.initializePromise):
* builtins/PromisePrototype.js:
(then):
Implement standard behavior of [[PromiseIsHandled]] and the host hook.
* runtime/JSPromise.cpp:
(JSC::JSPromise::isHandled):
* runtime/JSPromise.h:
C++ accessors for the [[PromiseIsHandled]] state.
* bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
* bytecode/BytecodeIntrinsicRegistry.h:
Expose private values for the Reject / Handle enum values in built-ins.
* jsc.cpp:
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::promiseResolveFunction):
Add a new GlobalObjectMethodTable hook matching the promise rejection hook.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncHostPromiseRejectionTracker):
* runtime/JSGlobalObjectFunctions.h:
Plumb the builtin hook through to the optional GlobalObjectMethodTable hook.
* inspector/InjectedScriptSource.js:
(InjectedScript.prototype.createFakeValueDescriptor):
Silence possible rejected promises created internally via Web Inspector.
Source/WebCore:
Implement support for the `onunhandledrejection` and `rejectionhandled` events.
They dispatch a new PromiseRejectionEvent using the ES6 HostPromiseRejectionTracker hook:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
This is currently implemented only for Documents and not yet Web Workers.
Tests: js/dom/unhandled-promise-rejection-basic.html
js/dom/unhandled-promise-rejection-bindings-type-error.html
js/dom/unhandled-promise-rejection-console-no-report.html
js/dom/unhandled-promise-rejection-console-report.html
js/dom/unhandled-promise-rejection-handle-during-event.html
js/dom/unhandled-promise-rejection-handle-in-handler.html
js/dom/unhandled-promise-rejection-handle.html
js/dom/unhandled-promise-rejection-order.html
* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
New files.
* bindings/scripts/CodeGenerator.pm:
(IsPromiseType):
* bindings/scripts/CodeGeneratorJS.pm:
(AddToIncludesForIDLType):
(GetBaseIDLType):
Binding support for Promise<T> attributes.
* bindings/js/JSDOMConvert.h:
* bindings/js/JSDOMConvertPromise.h: Copied from Source/JavaScriptCore/runtime/JSPromise.h.
(WebCore::Converter<IDLPromise<T>>::convert):
(WebCore::JSConverter<IDLPromise<T>>::convert):
Promise<T> binding conversion is currently unimplemented, which only means
web developers creating their own PromiseRejectionEvent will not get
autowrapping of values assigned to `promise` in event initialization.
Engine generated events will have expected behavior.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::promiseRejectionTracker):
* bindings/js/JSDOMWindowBase.h:
* bindings/js/JSWorkerGlobalScopeBase.cpp:
Implement HostPromiseRejectionTracker hook for Document but not Worker.
Passes through to the ScriptExecutionContext's tracker.
* bindings/js/JSMainThreadExecState.cpp:
(WebCore::JSMainThreadExecState::didLeaveScriptContext):
* bindings/js/JSMainThreadExecState.h:
(WebCore::JSMainThreadExecState::~JSMainThreadExecState):
When completing script execution and performing microtasks notify
about rejected promises. Technically this should go inside of
performing a microtask checkpoint, except lacking EventLoop
concepts we use ScriptExecutionState.
* dom/EventNames.h:
* dom/EventNames.in:
* dom/PromiseRejectionEvent.cpp: Added.
(WebCore::PromiseRejectionEvent::PromiseRejectionEvent):
(WebCore::PromiseRejectionEvent::~PromiseRejectionEvent):
* dom/PromiseRejectionEvent.h: Added.
* dom/PromiseRejectionEvent.idl: Added.
New PromiseRejectionEvent event interface.
* dom/GlobalEventHandlers.idl:
New onunhandledrejection and onrejectionhandled.
* dom/RejectedPromiseTracker.cpp: Added.
(WebCore::RejectedPromise::RejectedPromise):
(WebCore::RejectedPromise::globalObject):
(WebCore::RejectedPromise::promise):
(WebCore::UnhandledPromise::UnhandledPromise):
(WebCore::UnhandledPromise::callStack):
(WebCore::RejectedPromiseTracker::RejectedPromiseTracker):
(WebCore::RejectedPromiseTracker::~RejectedPromiseTracker):
(WebCore::createScriptCallStackFromReason):
(WebCore::RejectedPromiseTracker::promiseRejected):
(WebCore::RejectedPromiseTracker::promiseHandled):
(WebCore::RejectedPromiseTracker::processQueueSoon):
(WebCore::RejectedPromiseTracker::reportUnhandledRejections):
(WebCore::RejectedPromiseTracker::reportRejectionHandled):
* dom/RejectedPromiseTracker.h: Added.
Track and report rejected promises. The promises are tracked weakly
allowing them to be collected before they are reported. When reporting
we dispatch PromiseRejectionEvent events, and if the default is not
prevented we log a message to the console.
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::reportUnhandledPromiseRejection):
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTrackerSlow):
* dom/ScriptExecutionContext.h:
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTracker):
Each ScriptExecutionContext can own a rejected promise tracker.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::pauseInternal):
https://html.spec.whatwg.org/multipage/embedded-content.html#internal-pause-steps
Internal pause steps say to timeupdate, pause, and rejecting pending play promises
should all happen in a queued task. Here the first two actions are already scheduled
on tasks, but rejecting play promises was not being done in a task, so this makes
that change.
* Modules/streams/ReadableStream.js:
(pipeThrough):
* Modules/streams/ReadableStreamInternals.js:
(readableStreamReaderGenericInitialize):
(readableStreamError):
(readableStreamReaderGenericRelease):
Satisfy parts of the Streams specification which state to set the
[[PromiseIsHandled]] internal state of promises created internally
by the Streams APIs. This prevents some internal promises from
appearing as unhandled promise rejections.
LayoutTests:
* js/dom/unhandled-promise-rejection-basic-expected.txt: Added.
* js/dom/unhandled-promise-rejection-basic.html: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error-expected.txt: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error.html: Added.
* js/dom/unhandled-promise-rejection-console-no-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-no-report.html: Added.
* js/dom/unhandled-promise-rejection-console-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-report.html: Added.
* js/dom/unhandled-promise-rejection-handle-during-event-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-during-event.html: Added.
* js/dom/unhandled-promise-rejection-handle-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler.html: Added.
* js/dom/unhandled-promise-rejection-handle.html: Added.
* js/dom/unhandled-promise-rejection-order-expected.txt: Added.
* js/dom/unhandled-promise-rejection-order.html: Added.
New tests specific to the `onunhandledrejection` and `onrejectionhandled` events.
* resources/testharnessreport.js:
(self.testRunner.add_completion_callback.sanitize):
(self.testRunner.add_completion_callback):
Report results immediately and then finish the test after a turn. This way
if the test ends with a pass, but may get unhandled rejections after
completing which should not make the test appear as if it failed. Some tests
have unhandled promise rejections but are expected to pass. Likewise some
tests perform cleanup in their own completion callbacks, which happen after
this initial completion callback, and we want to report results after all
the work is done as it may eliminate non-deterministic debug test output.
* TestExpectations:
Mark some tests as flakey that have sometimes have unhandled promise rejections.
These tests are all various imported tests that use the testharness.
* fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt:
* http/tests/security/video-cross-origin-caching-expected.txt:
* inspector/debugger/break-on-exception-throw-in-promise-expected.txt:
* inspector/debugger/break-on-uncaught-exception-throw-in-promise-expected.txt:
* inspector/worker/resources-in-worker-expected.txt:
* js/dom/dom-static-property-for-in-iteration-expected.txt:
* js/dom/global-constructors-attributes-dedicated-worker-expected.txt:
* js/promises-tests/promises-tests-2-2-6-expected.txt:
* platform/mac/inspector/model/remote-object-expected.txt:
* webrtc/libwebrtc/release-while-creating-offer-expected.txt:
* webrtc/libwebrtc/release-while-setting-local-description-expected.txt:
Update tests with unhandled promise rejection messages.
* media/W3C/audio/events/event_pause_manual.html:
* media/audio-playback-restriction-play-expected.txt:
* media/audio-playback-restriction-play.html:
* media/click-volume-bar-not-pausing.html:
* media/remote-control-command-is-user-gesture-expected.txt:
* media/remote-control-command-is-user-gesture.html:
* media/track/track-mode.html:
* media/video-autoplay-allowed-but-fullscreen-required.html:
* media/video-display-none-crash.html:
* media/video-main-content-deny-display-none.html:
* media/video-main-content-deny-not-in-dom.html:
* media/video-main-content-deny-not-visible.html:
* media/video-main-content-deny-obscured.html:
* media/video-main-content-deny-too-small.html:
* media/video-multiple-concurrent-playback-expected.txt:
* media/video-play-audio-require-user-gesture-expected.txt:
* media/video-play-audio-require-user-gesture.html:
* media/video-play-pause-events-expected.txt:
* media/video-play-pause-events.html:
* media/video-play-pause-exception-expected.txt:
* media/video-play-pause-exception.html:
* media/video-play-require-user-gesture-expected.txt:
* media/video-play-require-user-gesture.html:
* media/video-preload-expected.txt:
* media/video-preload.html:
* media/video-test.js:
(handlePromise.handle):
Snuff many possible unhandled promise rejections in media via media.play().
* streams/reference-implementation/pipe-to-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:
These stream tests are out of date and produce unhandled rejections.
* streams/shadowing-Promise.html:
Update non-imported tests to prevent unhandled rejection messages.
Canonical link: https://commits.webkit.org/188310@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215916 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-28 03:33:57 +00:00
|
|
|
var resultStr = "\n";
|
2016-11-26 23:35:11 +00:00
|
|
|
|
Support for promise rejection events (unhandledrejection)
https://bugs.webkit.org/show_bug.cgi?id=150358
<rdar://problem/28441651>
Reviewed by Saam Barati.
Patch by Joseph Pecoraro and Yusuke Suzuki.
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/html/syntax/parsing/html5lib_innerHTML_adoption01-expected.txt:
* web-platform-tests/html/webappapis/scripting/events/body-exposed-window-event-handlers-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:
* web-platform-tests/user-timing/measure_exceptions_navigation_timing-expected.txt:
Rebaseline expectations to include unhandled promise rejection messages.
Also change how the test harness reports success or failure to use the values
immediately on completion and then allow a run loop cycle before completing
the test to gather the output.
* web-platform-tests/resource-timing/rt-resource-errors.html:
This is our own WPT test yet to be uploaded, so update the test to prevent
an unexpected unhandled rejection.
Source/JavaScriptCore:
Implement support for promise.[[PromiseIsHandled]] and the
HostPromiseRejectionTracker hook for HTML to track promise rejections:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
* builtins/BuiltinNames.h:
New private symbols.
* builtins/PromiseOperations.js:
(globalPrivate.newHandledRejectedPromise):
Utility to create a rejected promise with [[PromiseIsHandled]] to true.
(globalPrivate.rejectPromise):
(globalPrivate.initializePromise):
* builtins/PromisePrototype.js:
(then):
Implement standard behavior of [[PromiseIsHandled]] and the host hook.
* runtime/JSPromise.cpp:
(JSC::JSPromise::isHandled):
* runtime/JSPromise.h:
C++ accessors for the [[PromiseIsHandled]] state.
* bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
* bytecode/BytecodeIntrinsicRegistry.h:
Expose private values for the Reject / Handle enum values in built-ins.
* jsc.cpp:
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::promiseResolveFunction):
Add a new GlobalObjectMethodTable hook matching the promise rejection hook.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncHostPromiseRejectionTracker):
* runtime/JSGlobalObjectFunctions.h:
Plumb the builtin hook through to the optional GlobalObjectMethodTable hook.
* inspector/InjectedScriptSource.js:
(InjectedScript.prototype.createFakeValueDescriptor):
Silence possible rejected promises created internally via Web Inspector.
Source/WebCore:
Implement support for the `onunhandledrejection` and `rejectionhandled` events.
They dispatch a new PromiseRejectionEvent using the ES6 HostPromiseRejectionTracker hook:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
This is currently implemented only for Documents and not yet Web Workers.
Tests: js/dom/unhandled-promise-rejection-basic.html
js/dom/unhandled-promise-rejection-bindings-type-error.html
js/dom/unhandled-promise-rejection-console-no-report.html
js/dom/unhandled-promise-rejection-console-report.html
js/dom/unhandled-promise-rejection-handle-during-event.html
js/dom/unhandled-promise-rejection-handle-in-handler.html
js/dom/unhandled-promise-rejection-handle.html
js/dom/unhandled-promise-rejection-order.html
* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
New files.
* bindings/scripts/CodeGenerator.pm:
(IsPromiseType):
* bindings/scripts/CodeGeneratorJS.pm:
(AddToIncludesForIDLType):
(GetBaseIDLType):
Binding support for Promise<T> attributes.
* bindings/js/JSDOMConvert.h:
* bindings/js/JSDOMConvertPromise.h: Copied from Source/JavaScriptCore/runtime/JSPromise.h.
(WebCore::Converter<IDLPromise<T>>::convert):
(WebCore::JSConverter<IDLPromise<T>>::convert):
Promise<T> binding conversion is currently unimplemented, which only means
web developers creating their own PromiseRejectionEvent will not get
autowrapping of values assigned to `promise` in event initialization.
Engine generated events will have expected behavior.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::promiseRejectionTracker):
* bindings/js/JSDOMWindowBase.h:
* bindings/js/JSWorkerGlobalScopeBase.cpp:
Implement HostPromiseRejectionTracker hook for Document but not Worker.
Passes through to the ScriptExecutionContext's tracker.
* bindings/js/JSMainThreadExecState.cpp:
(WebCore::JSMainThreadExecState::didLeaveScriptContext):
* bindings/js/JSMainThreadExecState.h:
(WebCore::JSMainThreadExecState::~JSMainThreadExecState):
When completing script execution and performing microtasks notify
about rejected promises. Technically this should go inside of
performing a microtask checkpoint, except lacking EventLoop
concepts we use ScriptExecutionState.
* dom/EventNames.h:
* dom/EventNames.in:
* dom/PromiseRejectionEvent.cpp: Added.
(WebCore::PromiseRejectionEvent::PromiseRejectionEvent):
(WebCore::PromiseRejectionEvent::~PromiseRejectionEvent):
* dom/PromiseRejectionEvent.h: Added.
* dom/PromiseRejectionEvent.idl: Added.
New PromiseRejectionEvent event interface.
* dom/GlobalEventHandlers.idl:
New onunhandledrejection and onrejectionhandled.
* dom/RejectedPromiseTracker.cpp: Added.
(WebCore::RejectedPromise::RejectedPromise):
(WebCore::RejectedPromise::globalObject):
(WebCore::RejectedPromise::promise):
(WebCore::UnhandledPromise::UnhandledPromise):
(WebCore::UnhandledPromise::callStack):
(WebCore::RejectedPromiseTracker::RejectedPromiseTracker):
(WebCore::RejectedPromiseTracker::~RejectedPromiseTracker):
(WebCore::createScriptCallStackFromReason):
(WebCore::RejectedPromiseTracker::promiseRejected):
(WebCore::RejectedPromiseTracker::promiseHandled):
(WebCore::RejectedPromiseTracker::processQueueSoon):
(WebCore::RejectedPromiseTracker::reportUnhandledRejections):
(WebCore::RejectedPromiseTracker::reportRejectionHandled):
* dom/RejectedPromiseTracker.h: Added.
Track and report rejected promises. The promises are tracked weakly
allowing them to be collected before they are reported. When reporting
we dispatch PromiseRejectionEvent events, and if the default is not
prevented we log a message to the console.
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::reportUnhandledPromiseRejection):
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTrackerSlow):
* dom/ScriptExecutionContext.h:
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTracker):
Each ScriptExecutionContext can own a rejected promise tracker.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::pauseInternal):
https://html.spec.whatwg.org/multipage/embedded-content.html#internal-pause-steps
Internal pause steps say to timeupdate, pause, and rejecting pending play promises
should all happen in a queued task. Here the first two actions are already scheduled
on tasks, but rejecting play promises was not being done in a task, so this makes
that change.
* Modules/streams/ReadableStream.js:
(pipeThrough):
* Modules/streams/ReadableStreamInternals.js:
(readableStreamReaderGenericInitialize):
(readableStreamError):
(readableStreamReaderGenericRelease):
Satisfy parts of the Streams specification which state to set the
[[PromiseIsHandled]] internal state of promises created internally
by the Streams APIs. This prevents some internal promises from
appearing as unhandled promise rejections.
LayoutTests:
* js/dom/unhandled-promise-rejection-basic-expected.txt: Added.
* js/dom/unhandled-promise-rejection-basic.html: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error-expected.txt: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error.html: Added.
* js/dom/unhandled-promise-rejection-console-no-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-no-report.html: Added.
* js/dom/unhandled-promise-rejection-console-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-report.html: Added.
* js/dom/unhandled-promise-rejection-handle-during-event-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-during-event.html: Added.
* js/dom/unhandled-promise-rejection-handle-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler.html: Added.
* js/dom/unhandled-promise-rejection-handle.html: Added.
* js/dom/unhandled-promise-rejection-order-expected.txt: Added.
* js/dom/unhandled-promise-rejection-order.html: Added.
New tests specific to the `onunhandledrejection` and `onrejectionhandled` events.
* resources/testharnessreport.js:
(self.testRunner.add_completion_callback.sanitize):
(self.testRunner.add_completion_callback):
Report results immediately and then finish the test after a turn. This way
if the test ends with a pass, but may get unhandled rejections after
completing which should not make the test appear as if it failed. Some tests
have unhandled promise rejections but are expected to pass. Likewise some
tests perform cleanup in their own completion callbacks, which happen after
this initial completion callback, and we want to report results after all
the work is done as it may eliminate non-deterministic debug test output.
* TestExpectations:
Mark some tests as flakey that have sometimes have unhandled promise rejections.
These tests are all various imported tests that use the testharness.
* fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt:
* http/tests/security/video-cross-origin-caching-expected.txt:
* inspector/debugger/break-on-exception-throw-in-promise-expected.txt:
* inspector/debugger/break-on-uncaught-exception-throw-in-promise-expected.txt:
* inspector/worker/resources-in-worker-expected.txt:
* js/dom/dom-static-property-for-in-iteration-expected.txt:
* js/dom/global-constructors-attributes-dedicated-worker-expected.txt:
* js/promises-tests/promises-tests-2-2-6-expected.txt:
* platform/mac/inspector/model/remote-object-expected.txt:
* webrtc/libwebrtc/release-while-creating-offer-expected.txt:
* webrtc/libwebrtc/release-while-setting-local-description-expected.txt:
Update tests with unhandled promise rejection messages.
* media/W3C/audio/events/event_pause_manual.html:
* media/audio-playback-restriction-play-expected.txt:
* media/audio-playback-restriction-play.html:
* media/click-volume-bar-not-pausing.html:
* media/remote-control-command-is-user-gesture-expected.txt:
* media/remote-control-command-is-user-gesture.html:
* media/track/track-mode.html:
* media/video-autoplay-allowed-but-fullscreen-required.html:
* media/video-display-none-crash.html:
* media/video-main-content-deny-display-none.html:
* media/video-main-content-deny-not-in-dom.html:
* media/video-main-content-deny-not-visible.html:
* media/video-main-content-deny-obscured.html:
* media/video-main-content-deny-too-small.html:
* media/video-multiple-concurrent-playback-expected.txt:
* media/video-play-audio-require-user-gesture-expected.txt:
* media/video-play-audio-require-user-gesture.html:
* media/video-play-pause-events-expected.txt:
* media/video-play-pause-events.html:
* media/video-play-pause-exception-expected.txt:
* media/video-play-pause-exception.html:
* media/video-play-require-user-gesture-expected.txt:
* media/video-play-require-user-gesture.html:
* media/video-preload-expected.txt:
* media/video-preload.html:
* media/video-test.js:
(handlePromise.handle):
Snuff many possible unhandled promise rejections in media via media.play().
* streams/reference-implementation/pipe-to-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:
These stream tests are out of date and produce unhandled rejections.
* streams/shadowing-Promise.html:
Update non-imported tests to prevent unhandled rejection messages.
Canonical link: https://commits.webkit.org/188310@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215916 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-28 03:33:57 +00:00
|
|
|
// Sanitizes the given text for display in test results.
|
|
|
|
function sanitize(text) {
|
|
|
|
if (!text) {
|
|
|
|
return "";
|
2016-11-26 23:35:11 +00:00
|
|
|
}
|
Support for promise rejection events (unhandledrejection)
https://bugs.webkit.org/show_bug.cgi?id=150358
<rdar://problem/28441651>
Reviewed by Saam Barati.
Patch by Joseph Pecoraro and Yusuke Suzuki.
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/html/syntax/parsing/html5lib_innerHTML_adoption01-expected.txt:
* web-platform-tests/html/webappapis/scripting/events/body-exposed-window-event-handlers-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:
* web-platform-tests/user-timing/measure_exceptions_navigation_timing-expected.txt:
Rebaseline expectations to include unhandled promise rejection messages.
Also change how the test harness reports success or failure to use the values
immediately on completion and then allow a run loop cycle before completing
the test to gather the output.
* web-platform-tests/resource-timing/rt-resource-errors.html:
This is our own WPT test yet to be uploaded, so update the test to prevent
an unexpected unhandled rejection.
Source/JavaScriptCore:
Implement support for promise.[[PromiseIsHandled]] and the
HostPromiseRejectionTracker hook for HTML to track promise rejections:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
* builtins/BuiltinNames.h:
New private symbols.
* builtins/PromiseOperations.js:
(globalPrivate.newHandledRejectedPromise):
Utility to create a rejected promise with [[PromiseIsHandled]] to true.
(globalPrivate.rejectPromise):
(globalPrivate.initializePromise):
* builtins/PromisePrototype.js:
(then):
Implement standard behavior of [[PromiseIsHandled]] and the host hook.
* runtime/JSPromise.cpp:
(JSC::JSPromise::isHandled):
* runtime/JSPromise.h:
C++ accessors for the [[PromiseIsHandled]] state.
* bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
* bytecode/BytecodeIntrinsicRegistry.h:
Expose private values for the Reject / Handle enum values in built-ins.
* jsc.cpp:
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::promiseResolveFunction):
Add a new GlobalObjectMethodTable hook matching the promise rejection hook.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncHostPromiseRejectionTracker):
* runtime/JSGlobalObjectFunctions.h:
Plumb the builtin hook through to the optional GlobalObjectMethodTable hook.
* inspector/InjectedScriptSource.js:
(InjectedScript.prototype.createFakeValueDescriptor):
Silence possible rejected promises created internally via Web Inspector.
Source/WebCore:
Implement support for the `onunhandledrejection` and `rejectionhandled` events.
They dispatch a new PromiseRejectionEvent using the ES6 HostPromiseRejectionTracker hook:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
This is currently implemented only for Documents and not yet Web Workers.
Tests: js/dom/unhandled-promise-rejection-basic.html
js/dom/unhandled-promise-rejection-bindings-type-error.html
js/dom/unhandled-promise-rejection-console-no-report.html
js/dom/unhandled-promise-rejection-console-report.html
js/dom/unhandled-promise-rejection-handle-during-event.html
js/dom/unhandled-promise-rejection-handle-in-handler.html
js/dom/unhandled-promise-rejection-handle.html
js/dom/unhandled-promise-rejection-order.html
* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
New files.
* bindings/scripts/CodeGenerator.pm:
(IsPromiseType):
* bindings/scripts/CodeGeneratorJS.pm:
(AddToIncludesForIDLType):
(GetBaseIDLType):
Binding support for Promise<T> attributes.
* bindings/js/JSDOMConvert.h:
* bindings/js/JSDOMConvertPromise.h: Copied from Source/JavaScriptCore/runtime/JSPromise.h.
(WebCore::Converter<IDLPromise<T>>::convert):
(WebCore::JSConverter<IDLPromise<T>>::convert):
Promise<T> binding conversion is currently unimplemented, which only means
web developers creating their own PromiseRejectionEvent will not get
autowrapping of values assigned to `promise` in event initialization.
Engine generated events will have expected behavior.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::promiseRejectionTracker):
* bindings/js/JSDOMWindowBase.h:
* bindings/js/JSWorkerGlobalScopeBase.cpp:
Implement HostPromiseRejectionTracker hook for Document but not Worker.
Passes through to the ScriptExecutionContext's tracker.
* bindings/js/JSMainThreadExecState.cpp:
(WebCore::JSMainThreadExecState::didLeaveScriptContext):
* bindings/js/JSMainThreadExecState.h:
(WebCore::JSMainThreadExecState::~JSMainThreadExecState):
When completing script execution and performing microtasks notify
about rejected promises. Technically this should go inside of
performing a microtask checkpoint, except lacking EventLoop
concepts we use ScriptExecutionState.
* dom/EventNames.h:
* dom/EventNames.in:
* dom/PromiseRejectionEvent.cpp: Added.
(WebCore::PromiseRejectionEvent::PromiseRejectionEvent):
(WebCore::PromiseRejectionEvent::~PromiseRejectionEvent):
* dom/PromiseRejectionEvent.h: Added.
* dom/PromiseRejectionEvent.idl: Added.
New PromiseRejectionEvent event interface.
* dom/GlobalEventHandlers.idl:
New onunhandledrejection and onrejectionhandled.
* dom/RejectedPromiseTracker.cpp: Added.
(WebCore::RejectedPromise::RejectedPromise):
(WebCore::RejectedPromise::globalObject):
(WebCore::RejectedPromise::promise):
(WebCore::UnhandledPromise::UnhandledPromise):
(WebCore::UnhandledPromise::callStack):
(WebCore::RejectedPromiseTracker::RejectedPromiseTracker):
(WebCore::RejectedPromiseTracker::~RejectedPromiseTracker):
(WebCore::createScriptCallStackFromReason):
(WebCore::RejectedPromiseTracker::promiseRejected):
(WebCore::RejectedPromiseTracker::promiseHandled):
(WebCore::RejectedPromiseTracker::processQueueSoon):
(WebCore::RejectedPromiseTracker::reportUnhandledRejections):
(WebCore::RejectedPromiseTracker::reportRejectionHandled):
* dom/RejectedPromiseTracker.h: Added.
Track and report rejected promises. The promises are tracked weakly
allowing them to be collected before they are reported. When reporting
we dispatch PromiseRejectionEvent events, and if the default is not
prevented we log a message to the console.
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::reportUnhandledPromiseRejection):
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTrackerSlow):
* dom/ScriptExecutionContext.h:
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTracker):
Each ScriptExecutionContext can own a rejected promise tracker.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::pauseInternal):
https://html.spec.whatwg.org/multipage/embedded-content.html#internal-pause-steps
Internal pause steps say to timeupdate, pause, and rejecting pending play promises
should all happen in a queued task. Here the first two actions are already scheduled
on tasks, but rejecting play promises was not being done in a task, so this makes
that change.
* Modules/streams/ReadableStream.js:
(pipeThrough):
* Modules/streams/ReadableStreamInternals.js:
(readableStreamReaderGenericInitialize):
(readableStreamError):
(readableStreamReaderGenericRelease):
Satisfy parts of the Streams specification which state to set the
[[PromiseIsHandled]] internal state of promises created internally
by the Streams APIs. This prevents some internal promises from
appearing as unhandled promise rejections.
LayoutTests:
* js/dom/unhandled-promise-rejection-basic-expected.txt: Added.
* js/dom/unhandled-promise-rejection-basic.html: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error-expected.txt: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error.html: Added.
* js/dom/unhandled-promise-rejection-console-no-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-no-report.html: Added.
* js/dom/unhandled-promise-rejection-console-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-report.html: Added.
* js/dom/unhandled-promise-rejection-handle-during-event-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-during-event.html: Added.
* js/dom/unhandled-promise-rejection-handle-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler.html: Added.
* js/dom/unhandled-promise-rejection-handle.html: Added.
* js/dom/unhandled-promise-rejection-order-expected.txt: Added.
* js/dom/unhandled-promise-rejection-order.html: Added.
New tests specific to the `onunhandledrejection` and `onrejectionhandled` events.
* resources/testharnessreport.js:
(self.testRunner.add_completion_callback.sanitize):
(self.testRunner.add_completion_callback):
Report results immediately and then finish the test after a turn. This way
if the test ends with a pass, but may get unhandled rejections after
completing which should not make the test appear as if it failed. Some tests
have unhandled promise rejections but are expected to pass. Likewise some
tests perform cleanup in their own completion callbacks, which happen after
this initial completion callback, and we want to report results after all
the work is done as it may eliminate non-deterministic debug test output.
* TestExpectations:
Mark some tests as flakey that have sometimes have unhandled promise rejections.
These tests are all various imported tests that use the testharness.
* fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt:
* http/tests/security/video-cross-origin-caching-expected.txt:
* inspector/debugger/break-on-exception-throw-in-promise-expected.txt:
* inspector/debugger/break-on-uncaught-exception-throw-in-promise-expected.txt:
* inspector/worker/resources-in-worker-expected.txt:
* js/dom/dom-static-property-for-in-iteration-expected.txt:
* js/dom/global-constructors-attributes-dedicated-worker-expected.txt:
* js/promises-tests/promises-tests-2-2-6-expected.txt:
* platform/mac/inspector/model/remote-object-expected.txt:
* webrtc/libwebrtc/release-while-creating-offer-expected.txt:
* webrtc/libwebrtc/release-while-setting-local-description-expected.txt:
Update tests with unhandled promise rejection messages.
* media/W3C/audio/events/event_pause_manual.html:
* media/audio-playback-restriction-play-expected.txt:
* media/audio-playback-restriction-play.html:
* media/click-volume-bar-not-pausing.html:
* media/remote-control-command-is-user-gesture-expected.txt:
* media/remote-control-command-is-user-gesture.html:
* media/track/track-mode.html:
* media/video-autoplay-allowed-but-fullscreen-required.html:
* media/video-display-none-crash.html:
* media/video-main-content-deny-display-none.html:
* media/video-main-content-deny-not-in-dom.html:
* media/video-main-content-deny-not-visible.html:
* media/video-main-content-deny-obscured.html:
* media/video-main-content-deny-too-small.html:
* media/video-multiple-concurrent-playback-expected.txt:
* media/video-play-audio-require-user-gesture-expected.txt:
* media/video-play-audio-require-user-gesture.html:
* media/video-play-pause-events-expected.txt:
* media/video-play-pause-events.html:
* media/video-play-pause-exception-expected.txt:
* media/video-play-pause-exception.html:
* media/video-play-require-user-gesture-expected.txt:
* media/video-play-require-user-gesture.html:
* media/video-preload-expected.txt:
* media/video-preload.html:
* media/video-test.js:
(handlePromise.handle):
Snuff many possible unhandled promise rejections in media via media.play().
* streams/reference-implementation/pipe-to-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:
These stream tests are out of date and produce unhandled rejections.
* streams/shadowing-Promise.html:
Update non-imported tests to prevent unhandled rejection messages.
Canonical link: https://commits.webkit.org/188310@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215916 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-28 03:33:57 +00:00
|
|
|
text = text.replace(/\0/g, "\\0");
|
|
|
|
return text.replace(/\r/g, "\\r");
|
|
|
|
}
|
2016-11-26 23:35:11 +00:00
|
|
|
|
Support for promise rejection events (unhandledrejection)
https://bugs.webkit.org/show_bug.cgi?id=150358
<rdar://problem/28441651>
Reviewed by Saam Barati.
Patch by Joseph Pecoraro and Yusuke Suzuki.
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/html/syntax/parsing/html5lib_innerHTML_adoption01-expected.txt:
* web-platform-tests/html/webappapis/scripting/events/body-exposed-window-event-handlers-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:
* web-platform-tests/user-timing/measure_exceptions_navigation_timing-expected.txt:
Rebaseline expectations to include unhandled promise rejection messages.
Also change how the test harness reports success or failure to use the values
immediately on completion and then allow a run loop cycle before completing
the test to gather the output.
* web-platform-tests/resource-timing/rt-resource-errors.html:
This is our own WPT test yet to be uploaded, so update the test to prevent
an unexpected unhandled rejection.
Source/JavaScriptCore:
Implement support for promise.[[PromiseIsHandled]] and the
HostPromiseRejectionTracker hook for HTML to track promise rejections:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
* builtins/BuiltinNames.h:
New private symbols.
* builtins/PromiseOperations.js:
(globalPrivate.newHandledRejectedPromise):
Utility to create a rejected promise with [[PromiseIsHandled]] to true.
(globalPrivate.rejectPromise):
(globalPrivate.initializePromise):
* builtins/PromisePrototype.js:
(then):
Implement standard behavior of [[PromiseIsHandled]] and the host hook.
* runtime/JSPromise.cpp:
(JSC::JSPromise::isHandled):
* runtime/JSPromise.h:
C++ accessors for the [[PromiseIsHandled]] state.
* bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
* bytecode/BytecodeIntrinsicRegistry.h:
Expose private values for the Reject / Handle enum values in built-ins.
* jsc.cpp:
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::promiseResolveFunction):
Add a new GlobalObjectMethodTable hook matching the promise rejection hook.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncHostPromiseRejectionTracker):
* runtime/JSGlobalObjectFunctions.h:
Plumb the builtin hook through to the optional GlobalObjectMethodTable hook.
* inspector/InjectedScriptSource.js:
(InjectedScript.prototype.createFakeValueDescriptor):
Silence possible rejected promises created internally via Web Inspector.
Source/WebCore:
Implement support for the `onunhandledrejection` and `rejectionhandled` events.
They dispatch a new PromiseRejectionEvent using the ES6 HostPromiseRejectionTracker hook:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
This is currently implemented only for Documents and not yet Web Workers.
Tests: js/dom/unhandled-promise-rejection-basic.html
js/dom/unhandled-promise-rejection-bindings-type-error.html
js/dom/unhandled-promise-rejection-console-no-report.html
js/dom/unhandled-promise-rejection-console-report.html
js/dom/unhandled-promise-rejection-handle-during-event.html
js/dom/unhandled-promise-rejection-handle-in-handler.html
js/dom/unhandled-promise-rejection-handle.html
js/dom/unhandled-promise-rejection-order.html
* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
New files.
* bindings/scripts/CodeGenerator.pm:
(IsPromiseType):
* bindings/scripts/CodeGeneratorJS.pm:
(AddToIncludesForIDLType):
(GetBaseIDLType):
Binding support for Promise<T> attributes.
* bindings/js/JSDOMConvert.h:
* bindings/js/JSDOMConvertPromise.h: Copied from Source/JavaScriptCore/runtime/JSPromise.h.
(WebCore::Converter<IDLPromise<T>>::convert):
(WebCore::JSConverter<IDLPromise<T>>::convert):
Promise<T> binding conversion is currently unimplemented, which only means
web developers creating their own PromiseRejectionEvent will not get
autowrapping of values assigned to `promise` in event initialization.
Engine generated events will have expected behavior.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::promiseRejectionTracker):
* bindings/js/JSDOMWindowBase.h:
* bindings/js/JSWorkerGlobalScopeBase.cpp:
Implement HostPromiseRejectionTracker hook for Document but not Worker.
Passes through to the ScriptExecutionContext's tracker.
* bindings/js/JSMainThreadExecState.cpp:
(WebCore::JSMainThreadExecState::didLeaveScriptContext):
* bindings/js/JSMainThreadExecState.h:
(WebCore::JSMainThreadExecState::~JSMainThreadExecState):
When completing script execution and performing microtasks notify
about rejected promises. Technically this should go inside of
performing a microtask checkpoint, except lacking EventLoop
concepts we use ScriptExecutionState.
* dom/EventNames.h:
* dom/EventNames.in:
* dom/PromiseRejectionEvent.cpp: Added.
(WebCore::PromiseRejectionEvent::PromiseRejectionEvent):
(WebCore::PromiseRejectionEvent::~PromiseRejectionEvent):
* dom/PromiseRejectionEvent.h: Added.
* dom/PromiseRejectionEvent.idl: Added.
New PromiseRejectionEvent event interface.
* dom/GlobalEventHandlers.idl:
New onunhandledrejection and onrejectionhandled.
* dom/RejectedPromiseTracker.cpp: Added.
(WebCore::RejectedPromise::RejectedPromise):
(WebCore::RejectedPromise::globalObject):
(WebCore::RejectedPromise::promise):
(WebCore::UnhandledPromise::UnhandledPromise):
(WebCore::UnhandledPromise::callStack):
(WebCore::RejectedPromiseTracker::RejectedPromiseTracker):
(WebCore::RejectedPromiseTracker::~RejectedPromiseTracker):
(WebCore::createScriptCallStackFromReason):
(WebCore::RejectedPromiseTracker::promiseRejected):
(WebCore::RejectedPromiseTracker::promiseHandled):
(WebCore::RejectedPromiseTracker::processQueueSoon):
(WebCore::RejectedPromiseTracker::reportUnhandledRejections):
(WebCore::RejectedPromiseTracker::reportRejectionHandled):
* dom/RejectedPromiseTracker.h: Added.
Track and report rejected promises. The promises are tracked weakly
allowing them to be collected before they are reported. When reporting
we dispatch PromiseRejectionEvent events, and if the default is not
prevented we log a message to the console.
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::reportUnhandledPromiseRejection):
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTrackerSlow):
* dom/ScriptExecutionContext.h:
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTracker):
Each ScriptExecutionContext can own a rejected promise tracker.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::pauseInternal):
https://html.spec.whatwg.org/multipage/embedded-content.html#internal-pause-steps
Internal pause steps say to timeupdate, pause, and rejecting pending play promises
should all happen in a queued task. Here the first two actions are already scheduled
on tasks, but rejecting play promises was not being done in a task, so this makes
that change.
* Modules/streams/ReadableStream.js:
(pipeThrough):
* Modules/streams/ReadableStreamInternals.js:
(readableStreamReaderGenericInitialize):
(readableStreamError):
(readableStreamReaderGenericRelease):
Satisfy parts of the Streams specification which state to set the
[[PromiseIsHandled]] internal state of promises created internally
by the Streams APIs. This prevents some internal promises from
appearing as unhandled promise rejections.
LayoutTests:
* js/dom/unhandled-promise-rejection-basic-expected.txt: Added.
* js/dom/unhandled-promise-rejection-basic.html: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error-expected.txt: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error.html: Added.
* js/dom/unhandled-promise-rejection-console-no-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-no-report.html: Added.
* js/dom/unhandled-promise-rejection-console-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-report.html: Added.
* js/dom/unhandled-promise-rejection-handle-during-event-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-during-event.html: Added.
* js/dom/unhandled-promise-rejection-handle-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler.html: Added.
* js/dom/unhandled-promise-rejection-handle.html: Added.
* js/dom/unhandled-promise-rejection-order-expected.txt: Added.
* js/dom/unhandled-promise-rejection-order.html: Added.
New tests specific to the `onunhandledrejection` and `onrejectionhandled` events.
* resources/testharnessreport.js:
(self.testRunner.add_completion_callback.sanitize):
(self.testRunner.add_completion_callback):
Report results immediately and then finish the test after a turn. This way
if the test ends with a pass, but may get unhandled rejections after
completing which should not make the test appear as if it failed. Some tests
have unhandled promise rejections but are expected to pass. Likewise some
tests perform cleanup in their own completion callbacks, which happen after
this initial completion callback, and we want to report results after all
the work is done as it may eliminate non-deterministic debug test output.
* TestExpectations:
Mark some tests as flakey that have sometimes have unhandled promise rejections.
These tests are all various imported tests that use the testharness.
* fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt:
* http/tests/security/video-cross-origin-caching-expected.txt:
* inspector/debugger/break-on-exception-throw-in-promise-expected.txt:
* inspector/debugger/break-on-uncaught-exception-throw-in-promise-expected.txt:
* inspector/worker/resources-in-worker-expected.txt:
* js/dom/dom-static-property-for-in-iteration-expected.txt:
* js/dom/global-constructors-attributes-dedicated-worker-expected.txt:
* js/promises-tests/promises-tests-2-2-6-expected.txt:
* platform/mac/inspector/model/remote-object-expected.txt:
* webrtc/libwebrtc/release-while-creating-offer-expected.txt:
* webrtc/libwebrtc/release-while-setting-local-description-expected.txt:
Update tests with unhandled promise rejection messages.
* media/W3C/audio/events/event_pause_manual.html:
* media/audio-playback-restriction-play-expected.txt:
* media/audio-playback-restriction-play.html:
* media/click-volume-bar-not-pausing.html:
* media/remote-control-command-is-user-gesture-expected.txt:
* media/remote-control-command-is-user-gesture.html:
* media/track/track-mode.html:
* media/video-autoplay-allowed-but-fullscreen-required.html:
* media/video-display-none-crash.html:
* media/video-main-content-deny-display-none.html:
* media/video-main-content-deny-not-in-dom.html:
* media/video-main-content-deny-not-visible.html:
* media/video-main-content-deny-obscured.html:
* media/video-main-content-deny-too-small.html:
* media/video-multiple-concurrent-playback-expected.txt:
* media/video-play-audio-require-user-gesture-expected.txt:
* media/video-play-audio-require-user-gesture.html:
* media/video-play-pause-events-expected.txt:
* media/video-play-pause-events.html:
* media/video-play-pause-exception-expected.txt:
* media/video-play-pause-exception.html:
* media/video-play-require-user-gesture-expected.txt:
* media/video-play-require-user-gesture.html:
* media/video-preload-expected.txt:
* media/video-preload.html:
* media/video-test.js:
(handlePromise.handle):
Snuff many possible unhandled promise rejections in media via media.play().
* streams/reference-implementation/pipe-to-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:
These stream tests are out of date and produce unhandled rejections.
* streams/shadowing-Promise.html:
Update non-imported tests to prevent unhandled rejection messages.
Canonical link: https://commits.webkit.org/188310@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215916 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-28 03:33:57 +00:00
|
|
|
if(harness_status.status != 0)
|
|
|
|
resultStr += "Harness Error (" + convertResult(harness_status.status) + "), message = " + harness_status.message + "\n\n";
|
2016-11-26 23:35:11 +00:00
|
|
|
|
2020-11-04 16:09:57 +00:00
|
|
|
// Truncate decimal values from output in webaudio tests to avoid test flakiness due to floating point precision issues.
|
2020-11-16 16:40:58 +00:00
|
|
|
const isWebAudioTest = document.URL.indexOf('/webaudio') >= 0;
|
2020-09-16 22:31:44 +00:00
|
|
|
|
Support for promise rejection events (unhandledrejection)
https://bugs.webkit.org/show_bug.cgi?id=150358
<rdar://problem/28441651>
Reviewed by Saam Barati.
Patch by Joseph Pecoraro and Yusuke Suzuki.
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/html/syntax/parsing/html5lib_innerHTML_adoption01-expected.txt:
* web-platform-tests/html/webappapis/scripting/events/body-exposed-window-event-handlers-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:
* web-platform-tests/user-timing/measure_exceptions_navigation_timing-expected.txt:
Rebaseline expectations to include unhandled promise rejection messages.
Also change how the test harness reports success or failure to use the values
immediately on completion and then allow a run loop cycle before completing
the test to gather the output.
* web-platform-tests/resource-timing/rt-resource-errors.html:
This is our own WPT test yet to be uploaded, so update the test to prevent
an unexpected unhandled rejection.
Source/JavaScriptCore:
Implement support for promise.[[PromiseIsHandled]] and the
HostPromiseRejectionTracker hook for HTML to track promise rejections:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
* builtins/BuiltinNames.h:
New private symbols.
* builtins/PromiseOperations.js:
(globalPrivate.newHandledRejectedPromise):
Utility to create a rejected promise with [[PromiseIsHandled]] to true.
(globalPrivate.rejectPromise):
(globalPrivate.initializePromise):
* builtins/PromisePrototype.js:
(then):
Implement standard behavior of [[PromiseIsHandled]] and the host hook.
* runtime/JSPromise.cpp:
(JSC::JSPromise::isHandled):
* runtime/JSPromise.h:
C++ accessors for the [[PromiseIsHandled]] state.
* bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
* bytecode/BytecodeIntrinsicRegistry.h:
Expose private values for the Reject / Handle enum values in built-ins.
* jsc.cpp:
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::promiseResolveFunction):
Add a new GlobalObjectMethodTable hook matching the promise rejection hook.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncHostPromiseRejectionTracker):
* runtime/JSGlobalObjectFunctions.h:
Plumb the builtin hook through to the optional GlobalObjectMethodTable hook.
* inspector/InjectedScriptSource.js:
(InjectedScript.prototype.createFakeValueDescriptor):
Silence possible rejected promises created internally via Web Inspector.
Source/WebCore:
Implement support for the `onunhandledrejection` and `rejectionhandled` events.
They dispatch a new PromiseRejectionEvent using the ES6 HostPromiseRejectionTracker hook:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
This is currently implemented only for Documents and not yet Web Workers.
Tests: js/dom/unhandled-promise-rejection-basic.html
js/dom/unhandled-promise-rejection-bindings-type-error.html
js/dom/unhandled-promise-rejection-console-no-report.html
js/dom/unhandled-promise-rejection-console-report.html
js/dom/unhandled-promise-rejection-handle-during-event.html
js/dom/unhandled-promise-rejection-handle-in-handler.html
js/dom/unhandled-promise-rejection-handle.html
js/dom/unhandled-promise-rejection-order.html
* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
New files.
* bindings/scripts/CodeGenerator.pm:
(IsPromiseType):
* bindings/scripts/CodeGeneratorJS.pm:
(AddToIncludesForIDLType):
(GetBaseIDLType):
Binding support for Promise<T> attributes.
* bindings/js/JSDOMConvert.h:
* bindings/js/JSDOMConvertPromise.h: Copied from Source/JavaScriptCore/runtime/JSPromise.h.
(WebCore::Converter<IDLPromise<T>>::convert):
(WebCore::JSConverter<IDLPromise<T>>::convert):
Promise<T> binding conversion is currently unimplemented, which only means
web developers creating their own PromiseRejectionEvent will not get
autowrapping of values assigned to `promise` in event initialization.
Engine generated events will have expected behavior.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::promiseRejectionTracker):
* bindings/js/JSDOMWindowBase.h:
* bindings/js/JSWorkerGlobalScopeBase.cpp:
Implement HostPromiseRejectionTracker hook for Document but not Worker.
Passes through to the ScriptExecutionContext's tracker.
* bindings/js/JSMainThreadExecState.cpp:
(WebCore::JSMainThreadExecState::didLeaveScriptContext):
* bindings/js/JSMainThreadExecState.h:
(WebCore::JSMainThreadExecState::~JSMainThreadExecState):
When completing script execution and performing microtasks notify
about rejected promises. Technically this should go inside of
performing a microtask checkpoint, except lacking EventLoop
concepts we use ScriptExecutionState.
* dom/EventNames.h:
* dom/EventNames.in:
* dom/PromiseRejectionEvent.cpp: Added.
(WebCore::PromiseRejectionEvent::PromiseRejectionEvent):
(WebCore::PromiseRejectionEvent::~PromiseRejectionEvent):
* dom/PromiseRejectionEvent.h: Added.
* dom/PromiseRejectionEvent.idl: Added.
New PromiseRejectionEvent event interface.
* dom/GlobalEventHandlers.idl:
New onunhandledrejection and onrejectionhandled.
* dom/RejectedPromiseTracker.cpp: Added.
(WebCore::RejectedPromise::RejectedPromise):
(WebCore::RejectedPromise::globalObject):
(WebCore::RejectedPromise::promise):
(WebCore::UnhandledPromise::UnhandledPromise):
(WebCore::UnhandledPromise::callStack):
(WebCore::RejectedPromiseTracker::RejectedPromiseTracker):
(WebCore::RejectedPromiseTracker::~RejectedPromiseTracker):
(WebCore::createScriptCallStackFromReason):
(WebCore::RejectedPromiseTracker::promiseRejected):
(WebCore::RejectedPromiseTracker::promiseHandled):
(WebCore::RejectedPromiseTracker::processQueueSoon):
(WebCore::RejectedPromiseTracker::reportUnhandledRejections):
(WebCore::RejectedPromiseTracker::reportRejectionHandled):
* dom/RejectedPromiseTracker.h: Added.
Track and report rejected promises. The promises are tracked weakly
allowing them to be collected before they are reported. When reporting
we dispatch PromiseRejectionEvent events, and if the default is not
prevented we log a message to the console.
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::reportUnhandledPromiseRejection):
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTrackerSlow):
* dom/ScriptExecutionContext.h:
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTracker):
Each ScriptExecutionContext can own a rejected promise tracker.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::pauseInternal):
https://html.spec.whatwg.org/multipage/embedded-content.html#internal-pause-steps
Internal pause steps say to timeupdate, pause, and rejecting pending play promises
should all happen in a queued task. Here the first two actions are already scheduled
on tasks, but rejecting play promises was not being done in a task, so this makes
that change.
* Modules/streams/ReadableStream.js:
(pipeThrough):
* Modules/streams/ReadableStreamInternals.js:
(readableStreamReaderGenericInitialize):
(readableStreamError):
(readableStreamReaderGenericRelease):
Satisfy parts of the Streams specification which state to set the
[[PromiseIsHandled]] internal state of promises created internally
by the Streams APIs. This prevents some internal promises from
appearing as unhandled promise rejections.
LayoutTests:
* js/dom/unhandled-promise-rejection-basic-expected.txt: Added.
* js/dom/unhandled-promise-rejection-basic.html: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error-expected.txt: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error.html: Added.
* js/dom/unhandled-promise-rejection-console-no-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-no-report.html: Added.
* js/dom/unhandled-promise-rejection-console-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-report.html: Added.
* js/dom/unhandled-promise-rejection-handle-during-event-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-during-event.html: Added.
* js/dom/unhandled-promise-rejection-handle-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler.html: Added.
* js/dom/unhandled-promise-rejection-handle.html: Added.
* js/dom/unhandled-promise-rejection-order-expected.txt: Added.
* js/dom/unhandled-promise-rejection-order.html: Added.
New tests specific to the `onunhandledrejection` and `onrejectionhandled` events.
* resources/testharnessreport.js:
(self.testRunner.add_completion_callback.sanitize):
(self.testRunner.add_completion_callback):
Report results immediately and then finish the test after a turn. This way
if the test ends with a pass, but may get unhandled rejections after
completing which should not make the test appear as if it failed. Some tests
have unhandled promise rejections but are expected to pass. Likewise some
tests perform cleanup in their own completion callbacks, which happen after
this initial completion callback, and we want to report results after all
the work is done as it may eliminate non-deterministic debug test output.
* TestExpectations:
Mark some tests as flakey that have sometimes have unhandled promise rejections.
These tests are all various imported tests that use the testharness.
* fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt:
* http/tests/security/video-cross-origin-caching-expected.txt:
* inspector/debugger/break-on-exception-throw-in-promise-expected.txt:
* inspector/debugger/break-on-uncaught-exception-throw-in-promise-expected.txt:
* inspector/worker/resources-in-worker-expected.txt:
* js/dom/dom-static-property-for-in-iteration-expected.txt:
* js/dom/global-constructors-attributes-dedicated-worker-expected.txt:
* js/promises-tests/promises-tests-2-2-6-expected.txt:
* platform/mac/inspector/model/remote-object-expected.txt:
* webrtc/libwebrtc/release-while-creating-offer-expected.txt:
* webrtc/libwebrtc/release-while-setting-local-description-expected.txt:
Update tests with unhandled promise rejection messages.
* media/W3C/audio/events/event_pause_manual.html:
* media/audio-playback-restriction-play-expected.txt:
* media/audio-playback-restriction-play.html:
* media/click-volume-bar-not-pausing.html:
* media/remote-control-command-is-user-gesture-expected.txt:
* media/remote-control-command-is-user-gesture.html:
* media/track/track-mode.html:
* media/video-autoplay-allowed-but-fullscreen-required.html:
* media/video-display-none-crash.html:
* media/video-main-content-deny-display-none.html:
* media/video-main-content-deny-not-in-dom.html:
* media/video-main-content-deny-not-visible.html:
* media/video-main-content-deny-obscured.html:
* media/video-main-content-deny-too-small.html:
* media/video-multiple-concurrent-playback-expected.txt:
* media/video-play-audio-require-user-gesture-expected.txt:
* media/video-play-audio-require-user-gesture.html:
* media/video-play-pause-events-expected.txt:
* media/video-play-pause-events.html:
* media/video-play-pause-exception-expected.txt:
* media/video-play-pause-exception.html:
* media/video-play-require-user-gesture-expected.txt:
* media/video-play-require-user-gesture.html:
* media/video-preload-expected.txt:
* media/video-preload.html:
* media/video-test.js:
(handlePromise.handle):
Snuff many possible unhandled promise rejections in media via media.play().
* streams/reference-implementation/pipe-to-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:
These stream tests are out of date and produce unhandled rejections.
* streams/shadowing-Promise.html:
Update non-imported tests to prevent unhandled rejection messages.
Canonical link: https://commits.webkit.org/188310@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215916 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-28 03:33:57 +00:00
|
|
|
for (var i = 0; i < tests.length; i++) {
|
|
|
|
var message = sanitize(tests[i].message);
|
|
|
|
if (tests[i].status == 1 && !tests[i].dumpStack) {
|
|
|
|
// Remove stack for failed tests for proper string comparison without file paths.
|
|
|
|
// For a test to dump the stack set its dumpStack attribute to true.
|
|
|
|
var stackIndex = message.indexOf("(stack:");
|
|
|
|
if (stackIndex > 0)
|
|
|
|
message = message.substr(0, stackIndex);
|
2016-11-26 23:35:11 +00:00
|
|
|
}
|
2020-09-16 22:31:44 +00:00
|
|
|
|
|
|
|
let testName = tests[i].name;
|
2020-11-16 16:40:58 +00:00
|
|
|
if (isWebAudioTest) {
|
2020-09-16 22:31:44 +00:00
|
|
|
testName = testName.replace(/\[[0-9.,\-e]*[0-9]\.[0-9]{7,}[0-9.,\-e]*\]/, "[expected array]");
|
2020-11-04 16:09:57 +00:00
|
|
|
testName = testName.replace(/[0-9]\.[0-9]{7,}/g, (match, offset, string) => {
|
|
|
|
return parseFloat(match).toFixed(6);
|
|
|
|
});
|
2020-11-16 16:40:58 +00:00
|
|
|
testName = testName.replace(/ \(contains [0-9]+ different values\)./, ".");
|
2020-11-18 20:02:50 +00:00
|
|
|
testName = testName.replace(/ \(contains 1 different value\)./, ".");
|
|
|
|
testName = testName.replace(/: Actual Tail Frame [0-9]+ is greater than or equal to [0-9]+./, ".");
|
2020-11-04 16:09:57 +00:00
|
|
|
}
|
2020-09-16 22:31:44 +00:00
|
|
|
|
|
|
|
resultStr += convertResult(tests[i].status) + " " + sanitize(testName) + " " + message + "\n";
|
Support for promise rejection events (unhandledrejection)
https://bugs.webkit.org/show_bug.cgi?id=150358
<rdar://problem/28441651>
Reviewed by Saam Barati.
Patch by Joseph Pecoraro and Yusuke Suzuki.
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/html/syntax/parsing/html5lib_innerHTML_adoption01-expected.txt:
* web-platform-tests/html/webappapis/scripting/events/body-exposed-window-event-handlers-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:
* web-platform-tests/user-timing/measure_exceptions_navigation_timing-expected.txt:
Rebaseline expectations to include unhandled promise rejection messages.
Also change how the test harness reports success or failure to use the values
immediately on completion and then allow a run loop cycle before completing
the test to gather the output.
* web-platform-tests/resource-timing/rt-resource-errors.html:
This is our own WPT test yet to be uploaded, so update the test to prevent
an unexpected unhandled rejection.
Source/JavaScriptCore:
Implement support for promise.[[PromiseIsHandled]] and the
HostPromiseRejectionTracker hook for HTML to track promise rejections:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
* builtins/BuiltinNames.h:
New private symbols.
* builtins/PromiseOperations.js:
(globalPrivate.newHandledRejectedPromise):
Utility to create a rejected promise with [[PromiseIsHandled]] to true.
(globalPrivate.rejectPromise):
(globalPrivate.initializePromise):
* builtins/PromisePrototype.js:
(then):
Implement standard behavior of [[PromiseIsHandled]] and the host hook.
* runtime/JSPromise.cpp:
(JSC::JSPromise::isHandled):
* runtime/JSPromise.h:
C++ accessors for the [[PromiseIsHandled]] state.
* bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
* bytecode/BytecodeIntrinsicRegistry.h:
Expose private values for the Reject / Handle enum values in built-ins.
* jsc.cpp:
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::promiseResolveFunction):
Add a new GlobalObjectMethodTable hook matching the promise rejection hook.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncHostPromiseRejectionTracker):
* runtime/JSGlobalObjectFunctions.h:
Plumb the builtin hook through to the optional GlobalObjectMethodTable hook.
* inspector/InjectedScriptSource.js:
(InjectedScript.prototype.createFakeValueDescriptor):
Silence possible rejected promises created internally via Web Inspector.
Source/WebCore:
Implement support for the `onunhandledrejection` and `rejectionhandled` events.
They dispatch a new PromiseRejectionEvent using the ES6 HostPromiseRejectionTracker hook:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
This is currently implemented only for Documents and not yet Web Workers.
Tests: js/dom/unhandled-promise-rejection-basic.html
js/dom/unhandled-promise-rejection-bindings-type-error.html
js/dom/unhandled-promise-rejection-console-no-report.html
js/dom/unhandled-promise-rejection-console-report.html
js/dom/unhandled-promise-rejection-handle-during-event.html
js/dom/unhandled-promise-rejection-handle-in-handler.html
js/dom/unhandled-promise-rejection-handle.html
js/dom/unhandled-promise-rejection-order.html
* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
New files.
* bindings/scripts/CodeGenerator.pm:
(IsPromiseType):
* bindings/scripts/CodeGeneratorJS.pm:
(AddToIncludesForIDLType):
(GetBaseIDLType):
Binding support for Promise<T> attributes.
* bindings/js/JSDOMConvert.h:
* bindings/js/JSDOMConvertPromise.h: Copied from Source/JavaScriptCore/runtime/JSPromise.h.
(WebCore::Converter<IDLPromise<T>>::convert):
(WebCore::JSConverter<IDLPromise<T>>::convert):
Promise<T> binding conversion is currently unimplemented, which only means
web developers creating their own PromiseRejectionEvent will not get
autowrapping of values assigned to `promise` in event initialization.
Engine generated events will have expected behavior.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::promiseRejectionTracker):
* bindings/js/JSDOMWindowBase.h:
* bindings/js/JSWorkerGlobalScopeBase.cpp:
Implement HostPromiseRejectionTracker hook for Document but not Worker.
Passes through to the ScriptExecutionContext's tracker.
* bindings/js/JSMainThreadExecState.cpp:
(WebCore::JSMainThreadExecState::didLeaveScriptContext):
* bindings/js/JSMainThreadExecState.h:
(WebCore::JSMainThreadExecState::~JSMainThreadExecState):
When completing script execution and performing microtasks notify
about rejected promises. Technically this should go inside of
performing a microtask checkpoint, except lacking EventLoop
concepts we use ScriptExecutionState.
* dom/EventNames.h:
* dom/EventNames.in:
* dom/PromiseRejectionEvent.cpp: Added.
(WebCore::PromiseRejectionEvent::PromiseRejectionEvent):
(WebCore::PromiseRejectionEvent::~PromiseRejectionEvent):
* dom/PromiseRejectionEvent.h: Added.
* dom/PromiseRejectionEvent.idl: Added.
New PromiseRejectionEvent event interface.
* dom/GlobalEventHandlers.idl:
New onunhandledrejection and onrejectionhandled.
* dom/RejectedPromiseTracker.cpp: Added.
(WebCore::RejectedPromise::RejectedPromise):
(WebCore::RejectedPromise::globalObject):
(WebCore::RejectedPromise::promise):
(WebCore::UnhandledPromise::UnhandledPromise):
(WebCore::UnhandledPromise::callStack):
(WebCore::RejectedPromiseTracker::RejectedPromiseTracker):
(WebCore::RejectedPromiseTracker::~RejectedPromiseTracker):
(WebCore::createScriptCallStackFromReason):
(WebCore::RejectedPromiseTracker::promiseRejected):
(WebCore::RejectedPromiseTracker::promiseHandled):
(WebCore::RejectedPromiseTracker::processQueueSoon):
(WebCore::RejectedPromiseTracker::reportUnhandledRejections):
(WebCore::RejectedPromiseTracker::reportRejectionHandled):
* dom/RejectedPromiseTracker.h: Added.
Track and report rejected promises. The promises are tracked weakly
allowing them to be collected before they are reported. When reporting
we dispatch PromiseRejectionEvent events, and if the default is not
prevented we log a message to the console.
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::reportUnhandledPromiseRejection):
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTrackerSlow):
* dom/ScriptExecutionContext.h:
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTracker):
Each ScriptExecutionContext can own a rejected promise tracker.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::pauseInternal):
https://html.spec.whatwg.org/multipage/embedded-content.html#internal-pause-steps
Internal pause steps say to timeupdate, pause, and rejecting pending play promises
should all happen in a queued task. Here the first two actions are already scheduled
on tasks, but rejecting play promises was not being done in a task, so this makes
that change.
* Modules/streams/ReadableStream.js:
(pipeThrough):
* Modules/streams/ReadableStreamInternals.js:
(readableStreamReaderGenericInitialize):
(readableStreamError):
(readableStreamReaderGenericRelease):
Satisfy parts of the Streams specification which state to set the
[[PromiseIsHandled]] internal state of promises created internally
by the Streams APIs. This prevents some internal promises from
appearing as unhandled promise rejections.
LayoutTests:
* js/dom/unhandled-promise-rejection-basic-expected.txt: Added.
* js/dom/unhandled-promise-rejection-basic.html: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error-expected.txt: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error.html: Added.
* js/dom/unhandled-promise-rejection-console-no-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-no-report.html: Added.
* js/dom/unhandled-promise-rejection-console-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-report.html: Added.
* js/dom/unhandled-promise-rejection-handle-during-event-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-during-event.html: Added.
* js/dom/unhandled-promise-rejection-handle-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler.html: Added.
* js/dom/unhandled-promise-rejection-handle.html: Added.
* js/dom/unhandled-promise-rejection-order-expected.txt: Added.
* js/dom/unhandled-promise-rejection-order.html: Added.
New tests specific to the `onunhandledrejection` and `onrejectionhandled` events.
* resources/testharnessreport.js:
(self.testRunner.add_completion_callback.sanitize):
(self.testRunner.add_completion_callback):
Report results immediately and then finish the test after a turn. This way
if the test ends with a pass, but may get unhandled rejections after
completing which should not make the test appear as if it failed. Some tests
have unhandled promise rejections but are expected to pass. Likewise some
tests perform cleanup in their own completion callbacks, which happen after
this initial completion callback, and we want to report results after all
the work is done as it may eliminate non-deterministic debug test output.
* TestExpectations:
Mark some tests as flakey that have sometimes have unhandled promise rejections.
These tests are all various imported tests that use the testharness.
* fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt:
* http/tests/security/video-cross-origin-caching-expected.txt:
* inspector/debugger/break-on-exception-throw-in-promise-expected.txt:
* inspector/debugger/break-on-uncaught-exception-throw-in-promise-expected.txt:
* inspector/worker/resources-in-worker-expected.txt:
* js/dom/dom-static-property-for-in-iteration-expected.txt:
* js/dom/global-constructors-attributes-dedicated-worker-expected.txt:
* js/promises-tests/promises-tests-2-2-6-expected.txt:
* platform/mac/inspector/model/remote-object-expected.txt:
* webrtc/libwebrtc/release-while-creating-offer-expected.txt:
* webrtc/libwebrtc/release-while-setting-local-description-expected.txt:
Update tests with unhandled promise rejection messages.
* media/W3C/audio/events/event_pause_manual.html:
* media/audio-playback-restriction-play-expected.txt:
* media/audio-playback-restriction-play.html:
* media/click-volume-bar-not-pausing.html:
* media/remote-control-command-is-user-gesture-expected.txt:
* media/remote-control-command-is-user-gesture.html:
* media/track/track-mode.html:
* media/video-autoplay-allowed-but-fullscreen-required.html:
* media/video-display-none-crash.html:
* media/video-main-content-deny-display-none.html:
* media/video-main-content-deny-not-in-dom.html:
* media/video-main-content-deny-not-visible.html:
* media/video-main-content-deny-obscured.html:
* media/video-main-content-deny-too-small.html:
* media/video-multiple-concurrent-playback-expected.txt:
* media/video-play-audio-require-user-gesture-expected.txt:
* media/video-play-audio-require-user-gesture.html:
* media/video-play-pause-events-expected.txt:
* media/video-play-pause-events.html:
* media/video-play-pause-exception-expected.txt:
* media/video-play-pause-exception.html:
* media/video-play-require-user-gesture-expected.txt:
* media/video-play-require-user-gesture.html:
* media/video-preload-expected.txt:
* media/video-preload.html:
* media/video-test.js:
(handlePromise.handle):
Snuff many possible unhandled promise rejections in media via media.play().
* streams/reference-implementation/pipe-to-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:
These stream tests are out of date and produce unhandled rejections.
* streams/shadowing-Promise.html:
Update non-imported tests to prevent unhandled rejection messages.
Canonical link: https://commits.webkit.org/188310@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215916 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-28 03:33:57 +00:00
|
|
|
}
|
2016-11-26 23:35:11 +00:00
|
|
|
|
2019-10-30 17:20:17 +00:00
|
|
|
var results = document.createElementNS("http://www.w3.org/1999/xhtml", "pre");
|
Support for promise rejection events (unhandledrejection)
https://bugs.webkit.org/show_bug.cgi?id=150358
<rdar://problem/28441651>
Reviewed by Saam Barati.
Patch by Joseph Pecoraro and Yusuke Suzuki.
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/html/syntax/parsing/html5lib_innerHTML_adoption01-expected.txt:
* web-platform-tests/html/webappapis/scripting/events/body-exposed-window-event-handlers-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:
* web-platform-tests/user-timing/measure_exceptions_navigation_timing-expected.txt:
Rebaseline expectations to include unhandled promise rejection messages.
Also change how the test harness reports success or failure to use the values
immediately on completion and then allow a run loop cycle before completing
the test to gather the output.
* web-platform-tests/resource-timing/rt-resource-errors.html:
This is our own WPT test yet to be uploaded, so update the test to prevent
an unexpected unhandled rejection.
Source/JavaScriptCore:
Implement support for promise.[[PromiseIsHandled]] and the
HostPromiseRejectionTracker hook for HTML to track promise rejections:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
* builtins/BuiltinNames.h:
New private symbols.
* builtins/PromiseOperations.js:
(globalPrivate.newHandledRejectedPromise):
Utility to create a rejected promise with [[PromiseIsHandled]] to true.
(globalPrivate.rejectPromise):
(globalPrivate.initializePromise):
* builtins/PromisePrototype.js:
(then):
Implement standard behavior of [[PromiseIsHandled]] and the host hook.
* runtime/JSPromise.cpp:
(JSC::JSPromise::isHandled):
* runtime/JSPromise.h:
C++ accessors for the [[PromiseIsHandled]] state.
* bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
* bytecode/BytecodeIntrinsicRegistry.h:
Expose private values for the Reject / Handle enum values in built-ins.
* jsc.cpp:
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::promiseResolveFunction):
Add a new GlobalObjectMethodTable hook matching the promise rejection hook.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncHostPromiseRejectionTracker):
* runtime/JSGlobalObjectFunctions.h:
Plumb the builtin hook through to the optional GlobalObjectMethodTable hook.
* inspector/InjectedScriptSource.js:
(InjectedScript.prototype.createFakeValueDescriptor):
Silence possible rejected promises created internally via Web Inspector.
Source/WebCore:
Implement support for the `onunhandledrejection` and `rejectionhandled` events.
They dispatch a new PromiseRejectionEvent using the ES6 HostPromiseRejectionTracker hook:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
This is currently implemented only for Documents and not yet Web Workers.
Tests: js/dom/unhandled-promise-rejection-basic.html
js/dom/unhandled-promise-rejection-bindings-type-error.html
js/dom/unhandled-promise-rejection-console-no-report.html
js/dom/unhandled-promise-rejection-console-report.html
js/dom/unhandled-promise-rejection-handle-during-event.html
js/dom/unhandled-promise-rejection-handle-in-handler.html
js/dom/unhandled-promise-rejection-handle.html
js/dom/unhandled-promise-rejection-order.html
* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
New files.
* bindings/scripts/CodeGenerator.pm:
(IsPromiseType):
* bindings/scripts/CodeGeneratorJS.pm:
(AddToIncludesForIDLType):
(GetBaseIDLType):
Binding support for Promise<T> attributes.
* bindings/js/JSDOMConvert.h:
* bindings/js/JSDOMConvertPromise.h: Copied from Source/JavaScriptCore/runtime/JSPromise.h.
(WebCore::Converter<IDLPromise<T>>::convert):
(WebCore::JSConverter<IDLPromise<T>>::convert):
Promise<T> binding conversion is currently unimplemented, which only means
web developers creating their own PromiseRejectionEvent will not get
autowrapping of values assigned to `promise` in event initialization.
Engine generated events will have expected behavior.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::promiseRejectionTracker):
* bindings/js/JSDOMWindowBase.h:
* bindings/js/JSWorkerGlobalScopeBase.cpp:
Implement HostPromiseRejectionTracker hook for Document but not Worker.
Passes through to the ScriptExecutionContext's tracker.
* bindings/js/JSMainThreadExecState.cpp:
(WebCore::JSMainThreadExecState::didLeaveScriptContext):
* bindings/js/JSMainThreadExecState.h:
(WebCore::JSMainThreadExecState::~JSMainThreadExecState):
When completing script execution and performing microtasks notify
about rejected promises. Technically this should go inside of
performing a microtask checkpoint, except lacking EventLoop
concepts we use ScriptExecutionState.
* dom/EventNames.h:
* dom/EventNames.in:
* dom/PromiseRejectionEvent.cpp: Added.
(WebCore::PromiseRejectionEvent::PromiseRejectionEvent):
(WebCore::PromiseRejectionEvent::~PromiseRejectionEvent):
* dom/PromiseRejectionEvent.h: Added.
* dom/PromiseRejectionEvent.idl: Added.
New PromiseRejectionEvent event interface.
* dom/GlobalEventHandlers.idl:
New onunhandledrejection and onrejectionhandled.
* dom/RejectedPromiseTracker.cpp: Added.
(WebCore::RejectedPromise::RejectedPromise):
(WebCore::RejectedPromise::globalObject):
(WebCore::RejectedPromise::promise):
(WebCore::UnhandledPromise::UnhandledPromise):
(WebCore::UnhandledPromise::callStack):
(WebCore::RejectedPromiseTracker::RejectedPromiseTracker):
(WebCore::RejectedPromiseTracker::~RejectedPromiseTracker):
(WebCore::createScriptCallStackFromReason):
(WebCore::RejectedPromiseTracker::promiseRejected):
(WebCore::RejectedPromiseTracker::promiseHandled):
(WebCore::RejectedPromiseTracker::processQueueSoon):
(WebCore::RejectedPromiseTracker::reportUnhandledRejections):
(WebCore::RejectedPromiseTracker::reportRejectionHandled):
* dom/RejectedPromiseTracker.h: Added.
Track and report rejected promises. The promises are tracked weakly
allowing them to be collected before they are reported. When reporting
we dispatch PromiseRejectionEvent events, and if the default is not
prevented we log a message to the console.
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::reportUnhandledPromiseRejection):
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTrackerSlow):
* dom/ScriptExecutionContext.h:
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTracker):
Each ScriptExecutionContext can own a rejected promise tracker.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::pauseInternal):
https://html.spec.whatwg.org/multipage/embedded-content.html#internal-pause-steps
Internal pause steps say to timeupdate, pause, and rejecting pending play promises
should all happen in a queued task. Here the first two actions are already scheduled
on tasks, but rejecting play promises was not being done in a task, so this makes
that change.
* Modules/streams/ReadableStream.js:
(pipeThrough):
* Modules/streams/ReadableStreamInternals.js:
(readableStreamReaderGenericInitialize):
(readableStreamError):
(readableStreamReaderGenericRelease):
Satisfy parts of the Streams specification which state to set the
[[PromiseIsHandled]] internal state of promises created internally
by the Streams APIs. This prevents some internal promises from
appearing as unhandled promise rejections.
LayoutTests:
* js/dom/unhandled-promise-rejection-basic-expected.txt: Added.
* js/dom/unhandled-promise-rejection-basic.html: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error-expected.txt: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error.html: Added.
* js/dom/unhandled-promise-rejection-console-no-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-no-report.html: Added.
* js/dom/unhandled-promise-rejection-console-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-report.html: Added.
* js/dom/unhandled-promise-rejection-handle-during-event-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-during-event.html: Added.
* js/dom/unhandled-promise-rejection-handle-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler.html: Added.
* js/dom/unhandled-promise-rejection-handle.html: Added.
* js/dom/unhandled-promise-rejection-order-expected.txt: Added.
* js/dom/unhandled-promise-rejection-order.html: Added.
New tests specific to the `onunhandledrejection` and `onrejectionhandled` events.
* resources/testharnessreport.js:
(self.testRunner.add_completion_callback.sanitize):
(self.testRunner.add_completion_callback):
Report results immediately and then finish the test after a turn. This way
if the test ends with a pass, but may get unhandled rejections after
completing which should not make the test appear as if it failed. Some tests
have unhandled promise rejections but are expected to pass. Likewise some
tests perform cleanup in their own completion callbacks, which happen after
this initial completion callback, and we want to report results after all
the work is done as it may eliminate non-deterministic debug test output.
* TestExpectations:
Mark some tests as flakey that have sometimes have unhandled promise rejections.
These tests are all various imported tests that use the testharness.
* fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt:
* http/tests/security/video-cross-origin-caching-expected.txt:
* inspector/debugger/break-on-exception-throw-in-promise-expected.txt:
* inspector/debugger/break-on-uncaught-exception-throw-in-promise-expected.txt:
* inspector/worker/resources-in-worker-expected.txt:
* js/dom/dom-static-property-for-in-iteration-expected.txt:
* js/dom/global-constructors-attributes-dedicated-worker-expected.txt:
* js/promises-tests/promises-tests-2-2-6-expected.txt:
* platform/mac/inspector/model/remote-object-expected.txt:
* webrtc/libwebrtc/release-while-creating-offer-expected.txt:
* webrtc/libwebrtc/release-while-setting-local-description-expected.txt:
Update tests with unhandled promise rejection messages.
* media/W3C/audio/events/event_pause_manual.html:
* media/audio-playback-restriction-play-expected.txt:
* media/audio-playback-restriction-play.html:
* media/click-volume-bar-not-pausing.html:
* media/remote-control-command-is-user-gesture-expected.txt:
* media/remote-control-command-is-user-gesture.html:
* media/track/track-mode.html:
* media/video-autoplay-allowed-but-fullscreen-required.html:
* media/video-display-none-crash.html:
* media/video-main-content-deny-display-none.html:
* media/video-main-content-deny-not-in-dom.html:
* media/video-main-content-deny-not-visible.html:
* media/video-main-content-deny-obscured.html:
* media/video-main-content-deny-too-small.html:
* media/video-multiple-concurrent-playback-expected.txt:
* media/video-play-audio-require-user-gesture-expected.txt:
* media/video-play-audio-require-user-gesture.html:
* media/video-play-pause-events-expected.txt:
* media/video-play-pause-events.html:
* media/video-play-pause-exception-expected.txt:
* media/video-play-pause-exception.html:
* media/video-play-require-user-gesture-expected.txt:
* media/video-play-require-user-gesture.html:
* media/video-preload-expected.txt:
* media/video-preload.html:
* media/video-test.js:
(handlePromise.handle):
Snuff many possible unhandled promise rejections in media via media.play().
* streams/reference-implementation/pipe-to-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:
These stream tests are out of date and produce unhandled rejections.
* streams/shadowing-Promise.html:
Update non-imported tests to prevent unhandled rejection messages.
Canonical link: https://commits.webkit.org/188310@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215916 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-28 03:33:57 +00:00
|
|
|
results.innerText = resultStr;
|
2019-10-30 17:20:17 +00:00
|
|
|
|
Support for promise rejection events (unhandledrejection)
https://bugs.webkit.org/show_bug.cgi?id=150358
<rdar://problem/28441651>
Reviewed by Saam Barati.
Patch by Joseph Pecoraro and Yusuke Suzuki.
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/html/syntax/parsing/html5lib_innerHTML_adoption01-expected.txt:
* web-platform-tests/html/webappapis/scripting/events/body-exposed-window-event-handlers-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:
* web-platform-tests/user-timing/measure_exceptions_navigation_timing-expected.txt:
Rebaseline expectations to include unhandled promise rejection messages.
Also change how the test harness reports success or failure to use the values
immediately on completion and then allow a run loop cycle before completing
the test to gather the output.
* web-platform-tests/resource-timing/rt-resource-errors.html:
This is our own WPT test yet to be uploaded, so update the test to prevent
an unexpected unhandled rejection.
Source/JavaScriptCore:
Implement support for promise.[[PromiseIsHandled]] and the
HostPromiseRejectionTracker hook for HTML to track promise rejections:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
* builtins/BuiltinNames.h:
New private symbols.
* builtins/PromiseOperations.js:
(globalPrivate.newHandledRejectedPromise):
Utility to create a rejected promise with [[PromiseIsHandled]] to true.
(globalPrivate.rejectPromise):
(globalPrivate.initializePromise):
* builtins/PromisePrototype.js:
(then):
Implement standard behavior of [[PromiseIsHandled]] and the host hook.
* runtime/JSPromise.cpp:
(JSC::JSPromise::isHandled):
* runtime/JSPromise.h:
C++ accessors for the [[PromiseIsHandled]] state.
* bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
* bytecode/BytecodeIntrinsicRegistry.h:
Expose private values for the Reject / Handle enum values in built-ins.
* jsc.cpp:
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::promiseResolveFunction):
Add a new GlobalObjectMethodTable hook matching the promise rejection hook.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncHostPromiseRejectionTracker):
* runtime/JSGlobalObjectFunctions.h:
Plumb the builtin hook through to the optional GlobalObjectMethodTable hook.
* inspector/InjectedScriptSource.js:
(InjectedScript.prototype.createFakeValueDescriptor):
Silence possible rejected promises created internally via Web Inspector.
Source/WebCore:
Implement support for the `onunhandledrejection` and `rejectionhandled` events.
They dispatch a new PromiseRejectionEvent using the ES6 HostPromiseRejectionTracker hook:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
This is currently implemented only for Documents and not yet Web Workers.
Tests: js/dom/unhandled-promise-rejection-basic.html
js/dom/unhandled-promise-rejection-bindings-type-error.html
js/dom/unhandled-promise-rejection-console-no-report.html
js/dom/unhandled-promise-rejection-console-report.html
js/dom/unhandled-promise-rejection-handle-during-event.html
js/dom/unhandled-promise-rejection-handle-in-handler.html
js/dom/unhandled-promise-rejection-handle.html
js/dom/unhandled-promise-rejection-order.html
* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
New files.
* bindings/scripts/CodeGenerator.pm:
(IsPromiseType):
* bindings/scripts/CodeGeneratorJS.pm:
(AddToIncludesForIDLType):
(GetBaseIDLType):
Binding support for Promise<T> attributes.
* bindings/js/JSDOMConvert.h:
* bindings/js/JSDOMConvertPromise.h: Copied from Source/JavaScriptCore/runtime/JSPromise.h.
(WebCore::Converter<IDLPromise<T>>::convert):
(WebCore::JSConverter<IDLPromise<T>>::convert):
Promise<T> binding conversion is currently unimplemented, which only means
web developers creating their own PromiseRejectionEvent will not get
autowrapping of values assigned to `promise` in event initialization.
Engine generated events will have expected behavior.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::promiseRejectionTracker):
* bindings/js/JSDOMWindowBase.h:
* bindings/js/JSWorkerGlobalScopeBase.cpp:
Implement HostPromiseRejectionTracker hook for Document but not Worker.
Passes through to the ScriptExecutionContext's tracker.
* bindings/js/JSMainThreadExecState.cpp:
(WebCore::JSMainThreadExecState::didLeaveScriptContext):
* bindings/js/JSMainThreadExecState.h:
(WebCore::JSMainThreadExecState::~JSMainThreadExecState):
When completing script execution and performing microtasks notify
about rejected promises. Technically this should go inside of
performing a microtask checkpoint, except lacking EventLoop
concepts we use ScriptExecutionState.
* dom/EventNames.h:
* dom/EventNames.in:
* dom/PromiseRejectionEvent.cpp: Added.
(WebCore::PromiseRejectionEvent::PromiseRejectionEvent):
(WebCore::PromiseRejectionEvent::~PromiseRejectionEvent):
* dom/PromiseRejectionEvent.h: Added.
* dom/PromiseRejectionEvent.idl: Added.
New PromiseRejectionEvent event interface.
* dom/GlobalEventHandlers.idl:
New onunhandledrejection and onrejectionhandled.
* dom/RejectedPromiseTracker.cpp: Added.
(WebCore::RejectedPromise::RejectedPromise):
(WebCore::RejectedPromise::globalObject):
(WebCore::RejectedPromise::promise):
(WebCore::UnhandledPromise::UnhandledPromise):
(WebCore::UnhandledPromise::callStack):
(WebCore::RejectedPromiseTracker::RejectedPromiseTracker):
(WebCore::RejectedPromiseTracker::~RejectedPromiseTracker):
(WebCore::createScriptCallStackFromReason):
(WebCore::RejectedPromiseTracker::promiseRejected):
(WebCore::RejectedPromiseTracker::promiseHandled):
(WebCore::RejectedPromiseTracker::processQueueSoon):
(WebCore::RejectedPromiseTracker::reportUnhandledRejections):
(WebCore::RejectedPromiseTracker::reportRejectionHandled):
* dom/RejectedPromiseTracker.h: Added.
Track and report rejected promises. The promises are tracked weakly
allowing them to be collected before they are reported. When reporting
we dispatch PromiseRejectionEvent events, and if the default is not
prevented we log a message to the console.
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::reportUnhandledPromiseRejection):
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTrackerSlow):
* dom/ScriptExecutionContext.h:
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTracker):
Each ScriptExecutionContext can own a rejected promise tracker.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::pauseInternal):
https://html.spec.whatwg.org/multipage/embedded-content.html#internal-pause-steps
Internal pause steps say to timeupdate, pause, and rejecting pending play promises
should all happen in a queued task. Here the first two actions are already scheduled
on tasks, but rejecting play promises was not being done in a task, so this makes
that change.
* Modules/streams/ReadableStream.js:
(pipeThrough):
* Modules/streams/ReadableStreamInternals.js:
(readableStreamReaderGenericInitialize):
(readableStreamError):
(readableStreamReaderGenericRelease):
Satisfy parts of the Streams specification which state to set the
[[PromiseIsHandled]] internal state of promises created internally
by the Streams APIs. This prevents some internal promises from
appearing as unhandled promise rejections.
LayoutTests:
* js/dom/unhandled-promise-rejection-basic-expected.txt: Added.
* js/dom/unhandled-promise-rejection-basic.html: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error-expected.txt: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error.html: Added.
* js/dom/unhandled-promise-rejection-console-no-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-no-report.html: Added.
* js/dom/unhandled-promise-rejection-console-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-report.html: Added.
* js/dom/unhandled-promise-rejection-handle-during-event-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-during-event.html: Added.
* js/dom/unhandled-promise-rejection-handle-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler.html: Added.
* js/dom/unhandled-promise-rejection-handle.html: Added.
* js/dom/unhandled-promise-rejection-order-expected.txt: Added.
* js/dom/unhandled-promise-rejection-order.html: Added.
New tests specific to the `onunhandledrejection` and `onrejectionhandled` events.
* resources/testharnessreport.js:
(self.testRunner.add_completion_callback.sanitize):
(self.testRunner.add_completion_callback):
Report results immediately and then finish the test after a turn. This way
if the test ends with a pass, but may get unhandled rejections after
completing which should not make the test appear as if it failed. Some tests
have unhandled promise rejections but are expected to pass. Likewise some
tests perform cleanup in their own completion callbacks, which happen after
this initial completion callback, and we want to report results after all
the work is done as it may eliminate non-deterministic debug test output.
* TestExpectations:
Mark some tests as flakey that have sometimes have unhandled promise rejections.
These tests are all various imported tests that use the testharness.
* fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt:
* http/tests/security/video-cross-origin-caching-expected.txt:
* inspector/debugger/break-on-exception-throw-in-promise-expected.txt:
* inspector/debugger/break-on-uncaught-exception-throw-in-promise-expected.txt:
* inspector/worker/resources-in-worker-expected.txt:
* js/dom/dom-static-property-for-in-iteration-expected.txt:
* js/dom/global-constructors-attributes-dedicated-worker-expected.txt:
* js/promises-tests/promises-tests-2-2-6-expected.txt:
* platform/mac/inspector/model/remote-object-expected.txt:
* webrtc/libwebrtc/release-while-creating-offer-expected.txt:
* webrtc/libwebrtc/release-while-setting-local-description-expected.txt:
Update tests with unhandled promise rejection messages.
* media/W3C/audio/events/event_pause_manual.html:
* media/audio-playback-restriction-play-expected.txt:
* media/audio-playback-restriction-play.html:
* media/click-volume-bar-not-pausing.html:
* media/remote-control-command-is-user-gesture-expected.txt:
* media/remote-control-command-is-user-gesture.html:
* media/track/track-mode.html:
* media/video-autoplay-allowed-but-fullscreen-required.html:
* media/video-display-none-crash.html:
* media/video-main-content-deny-display-none.html:
* media/video-main-content-deny-not-in-dom.html:
* media/video-main-content-deny-not-visible.html:
* media/video-main-content-deny-obscured.html:
* media/video-main-content-deny-too-small.html:
* media/video-multiple-concurrent-playback-expected.txt:
* media/video-play-audio-require-user-gesture-expected.txt:
* media/video-play-audio-require-user-gesture.html:
* media/video-play-pause-events-expected.txt:
* media/video-play-pause-events.html:
* media/video-play-pause-exception-expected.txt:
* media/video-play-pause-exception.html:
* media/video-play-require-user-gesture-expected.txt:
* media/video-play-require-user-gesture.html:
* media/video-preload-expected.txt:
* media/video-preload.html:
* media/video-test.js:
(handlePromise.handle):
Snuff many possible unhandled promise rejections in media via media.play().
* streams/reference-implementation/pipe-to-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:
These stream tests are out of date and produce unhandled rejections.
* streams/shadowing-Promise.html:
Update non-imported tests to prevent unhandled rejection messages.
Canonical link: https://commits.webkit.org/188310@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215916 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-28 03:33:57 +00:00
|
|
|
var log = document.getElementById("log");
|
|
|
|
if (log)
|
|
|
|
log.appendChild(results);
|
2019-10-30 17:20:17 +00:00
|
|
|
else if (document.body)
|
Support for promise rejection events (unhandledrejection)
https://bugs.webkit.org/show_bug.cgi?id=150358
<rdar://problem/28441651>
Reviewed by Saam Barati.
Patch by Joseph Pecoraro and Yusuke Suzuki.
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/html/syntax/parsing/html5lib_innerHTML_adoption01-expected.txt:
* web-platform-tests/html/webappapis/scripting/events/body-exposed-window-event-handlers-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:
* web-platform-tests/user-timing/measure_exceptions_navigation_timing-expected.txt:
Rebaseline expectations to include unhandled promise rejection messages.
Also change how the test harness reports success or failure to use the values
immediately on completion and then allow a run loop cycle before completing
the test to gather the output.
* web-platform-tests/resource-timing/rt-resource-errors.html:
This is our own WPT test yet to be uploaded, so update the test to prevent
an unexpected unhandled rejection.
Source/JavaScriptCore:
Implement support for promise.[[PromiseIsHandled]] and the
HostPromiseRejectionTracker hook for HTML to track promise rejections:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
* builtins/BuiltinNames.h:
New private symbols.
* builtins/PromiseOperations.js:
(globalPrivate.newHandledRejectedPromise):
Utility to create a rejected promise with [[PromiseIsHandled]] to true.
(globalPrivate.rejectPromise):
(globalPrivate.initializePromise):
* builtins/PromisePrototype.js:
(then):
Implement standard behavior of [[PromiseIsHandled]] and the host hook.
* runtime/JSPromise.cpp:
(JSC::JSPromise::isHandled):
* runtime/JSPromise.h:
C++ accessors for the [[PromiseIsHandled]] state.
* bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
* bytecode/BytecodeIntrinsicRegistry.h:
Expose private values for the Reject / Handle enum values in built-ins.
* jsc.cpp:
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::promiseResolveFunction):
Add a new GlobalObjectMethodTable hook matching the promise rejection hook.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncHostPromiseRejectionTracker):
* runtime/JSGlobalObjectFunctions.h:
Plumb the builtin hook through to the optional GlobalObjectMethodTable hook.
* inspector/InjectedScriptSource.js:
(InjectedScript.prototype.createFakeValueDescriptor):
Silence possible rejected promises created internally via Web Inspector.
Source/WebCore:
Implement support for the `onunhandledrejection` and `rejectionhandled` events.
They dispatch a new PromiseRejectionEvent using the ES6 HostPromiseRejectionTracker hook:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
This is currently implemented only for Documents and not yet Web Workers.
Tests: js/dom/unhandled-promise-rejection-basic.html
js/dom/unhandled-promise-rejection-bindings-type-error.html
js/dom/unhandled-promise-rejection-console-no-report.html
js/dom/unhandled-promise-rejection-console-report.html
js/dom/unhandled-promise-rejection-handle-during-event.html
js/dom/unhandled-promise-rejection-handle-in-handler.html
js/dom/unhandled-promise-rejection-handle.html
js/dom/unhandled-promise-rejection-order.html
* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
New files.
* bindings/scripts/CodeGenerator.pm:
(IsPromiseType):
* bindings/scripts/CodeGeneratorJS.pm:
(AddToIncludesForIDLType):
(GetBaseIDLType):
Binding support for Promise<T> attributes.
* bindings/js/JSDOMConvert.h:
* bindings/js/JSDOMConvertPromise.h: Copied from Source/JavaScriptCore/runtime/JSPromise.h.
(WebCore::Converter<IDLPromise<T>>::convert):
(WebCore::JSConverter<IDLPromise<T>>::convert):
Promise<T> binding conversion is currently unimplemented, which only means
web developers creating their own PromiseRejectionEvent will not get
autowrapping of values assigned to `promise` in event initialization.
Engine generated events will have expected behavior.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::promiseRejectionTracker):
* bindings/js/JSDOMWindowBase.h:
* bindings/js/JSWorkerGlobalScopeBase.cpp:
Implement HostPromiseRejectionTracker hook for Document but not Worker.
Passes through to the ScriptExecutionContext's tracker.
* bindings/js/JSMainThreadExecState.cpp:
(WebCore::JSMainThreadExecState::didLeaveScriptContext):
* bindings/js/JSMainThreadExecState.h:
(WebCore::JSMainThreadExecState::~JSMainThreadExecState):
When completing script execution and performing microtasks notify
about rejected promises. Technically this should go inside of
performing a microtask checkpoint, except lacking EventLoop
concepts we use ScriptExecutionState.
* dom/EventNames.h:
* dom/EventNames.in:
* dom/PromiseRejectionEvent.cpp: Added.
(WebCore::PromiseRejectionEvent::PromiseRejectionEvent):
(WebCore::PromiseRejectionEvent::~PromiseRejectionEvent):
* dom/PromiseRejectionEvent.h: Added.
* dom/PromiseRejectionEvent.idl: Added.
New PromiseRejectionEvent event interface.
* dom/GlobalEventHandlers.idl:
New onunhandledrejection and onrejectionhandled.
* dom/RejectedPromiseTracker.cpp: Added.
(WebCore::RejectedPromise::RejectedPromise):
(WebCore::RejectedPromise::globalObject):
(WebCore::RejectedPromise::promise):
(WebCore::UnhandledPromise::UnhandledPromise):
(WebCore::UnhandledPromise::callStack):
(WebCore::RejectedPromiseTracker::RejectedPromiseTracker):
(WebCore::RejectedPromiseTracker::~RejectedPromiseTracker):
(WebCore::createScriptCallStackFromReason):
(WebCore::RejectedPromiseTracker::promiseRejected):
(WebCore::RejectedPromiseTracker::promiseHandled):
(WebCore::RejectedPromiseTracker::processQueueSoon):
(WebCore::RejectedPromiseTracker::reportUnhandledRejections):
(WebCore::RejectedPromiseTracker::reportRejectionHandled):
* dom/RejectedPromiseTracker.h: Added.
Track and report rejected promises. The promises are tracked weakly
allowing them to be collected before they are reported. When reporting
we dispatch PromiseRejectionEvent events, and if the default is not
prevented we log a message to the console.
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::reportUnhandledPromiseRejection):
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTrackerSlow):
* dom/ScriptExecutionContext.h:
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTracker):
Each ScriptExecutionContext can own a rejected promise tracker.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::pauseInternal):
https://html.spec.whatwg.org/multipage/embedded-content.html#internal-pause-steps
Internal pause steps say to timeupdate, pause, and rejecting pending play promises
should all happen in a queued task. Here the first two actions are already scheduled
on tasks, but rejecting play promises was not being done in a task, so this makes
that change.
* Modules/streams/ReadableStream.js:
(pipeThrough):
* Modules/streams/ReadableStreamInternals.js:
(readableStreamReaderGenericInitialize):
(readableStreamError):
(readableStreamReaderGenericRelease):
Satisfy parts of the Streams specification which state to set the
[[PromiseIsHandled]] internal state of promises created internally
by the Streams APIs. This prevents some internal promises from
appearing as unhandled promise rejections.
LayoutTests:
* js/dom/unhandled-promise-rejection-basic-expected.txt: Added.
* js/dom/unhandled-promise-rejection-basic.html: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error-expected.txt: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error.html: Added.
* js/dom/unhandled-promise-rejection-console-no-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-no-report.html: Added.
* js/dom/unhandled-promise-rejection-console-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-report.html: Added.
* js/dom/unhandled-promise-rejection-handle-during-event-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-during-event.html: Added.
* js/dom/unhandled-promise-rejection-handle-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler.html: Added.
* js/dom/unhandled-promise-rejection-handle.html: Added.
* js/dom/unhandled-promise-rejection-order-expected.txt: Added.
* js/dom/unhandled-promise-rejection-order.html: Added.
New tests specific to the `onunhandledrejection` and `onrejectionhandled` events.
* resources/testharnessreport.js:
(self.testRunner.add_completion_callback.sanitize):
(self.testRunner.add_completion_callback):
Report results immediately and then finish the test after a turn. This way
if the test ends with a pass, but may get unhandled rejections after
completing which should not make the test appear as if it failed. Some tests
have unhandled promise rejections but are expected to pass. Likewise some
tests perform cleanup in their own completion callbacks, which happen after
this initial completion callback, and we want to report results after all
the work is done as it may eliminate non-deterministic debug test output.
* TestExpectations:
Mark some tests as flakey that have sometimes have unhandled promise rejections.
These tests are all various imported tests that use the testharness.
* fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt:
* http/tests/security/video-cross-origin-caching-expected.txt:
* inspector/debugger/break-on-exception-throw-in-promise-expected.txt:
* inspector/debugger/break-on-uncaught-exception-throw-in-promise-expected.txt:
* inspector/worker/resources-in-worker-expected.txt:
* js/dom/dom-static-property-for-in-iteration-expected.txt:
* js/dom/global-constructors-attributes-dedicated-worker-expected.txt:
* js/promises-tests/promises-tests-2-2-6-expected.txt:
* platform/mac/inspector/model/remote-object-expected.txt:
* webrtc/libwebrtc/release-while-creating-offer-expected.txt:
* webrtc/libwebrtc/release-while-setting-local-description-expected.txt:
Update tests with unhandled promise rejection messages.
* media/W3C/audio/events/event_pause_manual.html:
* media/audio-playback-restriction-play-expected.txt:
* media/audio-playback-restriction-play.html:
* media/click-volume-bar-not-pausing.html:
* media/remote-control-command-is-user-gesture-expected.txt:
* media/remote-control-command-is-user-gesture.html:
* media/track/track-mode.html:
* media/video-autoplay-allowed-but-fullscreen-required.html:
* media/video-display-none-crash.html:
* media/video-main-content-deny-display-none.html:
* media/video-main-content-deny-not-in-dom.html:
* media/video-main-content-deny-not-visible.html:
* media/video-main-content-deny-obscured.html:
* media/video-main-content-deny-too-small.html:
* media/video-multiple-concurrent-playback-expected.txt:
* media/video-play-audio-require-user-gesture-expected.txt:
* media/video-play-audio-require-user-gesture.html:
* media/video-play-pause-events-expected.txt:
* media/video-play-pause-events.html:
* media/video-play-pause-exception-expected.txt:
* media/video-play-pause-exception.html:
* media/video-play-require-user-gesture-expected.txt:
* media/video-play-require-user-gesture.html:
* media/video-preload-expected.txt:
* media/video-preload.html:
* media/video-test.js:
(handlePromise.handle):
Snuff many possible unhandled promise rejections in media via media.play().
* streams/reference-implementation/pipe-to-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:
These stream tests are out of date and produce unhandled rejections.
* streams/shadowing-Promise.html:
Update non-imported tests to prevent unhandled rejection messages.
Canonical link: https://commits.webkit.org/188310@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215916 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-28 03:33:57 +00:00
|
|
|
document.body.appendChild(results);
|
2019-10-30 17:20:17 +00:00
|
|
|
else {
|
|
|
|
var root = document.documentElement;
|
|
|
|
var is_html = root
|
|
|
|
&& root.namespaceURI == "http://www.w3.org/1999/xhtml"
|
|
|
|
&& root.localName == "html";
|
|
|
|
var is_svg = document.defaultView
|
|
|
|
&& "SVGSVGElement" in document.defaultView
|
|
|
|
&& root instanceof document.defaultView.SVGSVGElement;
|
|
|
|
|
|
|
|
if (is_svg) {
|
|
|
|
var foreignObject = document.createElementNS("http://www.w3.org/2000/svg", "foreignObject");
|
|
|
|
foreignObject.setAttribute("width", "100%");
|
|
|
|
foreignObject.setAttribute("height", "100%");
|
|
|
|
root.appendChild(foreignObject);
|
|
|
|
foreignObject.appendChild(results);
|
|
|
|
} else if (is_html) {
|
|
|
|
root.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "body"))
|
|
|
|
.appendChild(results);
|
|
|
|
} else {
|
|
|
|
root.appendChild(results);
|
|
|
|
}
|
|
|
|
}
|
2016-11-26 23:35:11 +00:00
|
|
|
|
Support for promise rejection events (unhandledrejection)
https://bugs.webkit.org/show_bug.cgi?id=150358
<rdar://problem/28441651>
Reviewed by Saam Barati.
Patch by Joseph Pecoraro and Yusuke Suzuki.
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/html/syntax/parsing/html5lib_innerHTML_adoption01-expected.txt:
* web-platform-tests/html/webappapis/scripting/events/body-exposed-window-event-handlers-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:
* web-platform-tests/user-timing/measure_exceptions_navigation_timing-expected.txt:
Rebaseline expectations to include unhandled promise rejection messages.
Also change how the test harness reports success or failure to use the values
immediately on completion and then allow a run loop cycle before completing
the test to gather the output.
* web-platform-tests/resource-timing/rt-resource-errors.html:
This is our own WPT test yet to be uploaded, so update the test to prevent
an unexpected unhandled rejection.
Source/JavaScriptCore:
Implement support for promise.[[PromiseIsHandled]] and the
HostPromiseRejectionTracker hook for HTML to track promise rejections:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
* builtins/BuiltinNames.h:
New private symbols.
* builtins/PromiseOperations.js:
(globalPrivate.newHandledRejectedPromise):
Utility to create a rejected promise with [[PromiseIsHandled]] to true.
(globalPrivate.rejectPromise):
(globalPrivate.initializePromise):
* builtins/PromisePrototype.js:
(then):
Implement standard behavior of [[PromiseIsHandled]] and the host hook.
* runtime/JSPromise.cpp:
(JSC::JSPromise::isHandled):
* runtime/JSPromise.h:
C++ accessors for the [[PromiseIsHandled]] state.
* bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
* bytecode/BytecodeIntrinsicRegistry.h:
Expose private values for the Reject / Handle enum values in built-ins.
* jsc.cpp:
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::promiseResolveFunction):
Add a new GlobalObjectMethodTable hook matching the promise rejection hook.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncHostPromiseRejectionTracker):
* runtime/JSGlobalObjectFunctions.h:
Plumb the builtin hook through to the optional GlobalObjectMethodTable hook.
* inspector/InjectedScriptSource.js:
(InjectedScript.prototype.createFakeValueDescriptor):
Silence possible rejected promises created internally via Web Inspector.
Source/WebCore:
Implement support for the `onunhandledrejection` and `rejectionhandled` events.
They dispatch a new PromiseRejectionEvent using the ES6 HostPromiseRejectionTracker hook:
https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
This is currently implemented only for Documents and not yet Web Workers.
Tests: js/dom/unhandled-promise-rejection-basic.html
js/dom/unhandled-promise-rejection-bindings-type-error.html
js/dom/unhandled-promise-rejection-console-no-report.html
js/dom/unhandled-promise-rejection-console-report.html
js/dom/unhandled-promise-rejection-handle-during-event.html
js/dom/unhandled-promise-rejection-handle-in-handler.html
js/dom/unhandled-promise-rejection-handle.html
js/dom/unhandled-promise-rejection-order.html
* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
New files.
* bindings/scripts/CodeGenerator.pm:
(IsPromiseType):
* bindings/scripts/CodeGeneratorJS.pm:
(AddToIncludesForIDLType):
(GetBaseIDLType):
Binding support for Promise<T> attributes.
* bindings/js/JSDOMConvert.h:
* bindings/js/JSDOMConvertPromise.h: Copied from Source/JavaScriptCore/runtime/JSPromise.h.
(WebCore::Converter<IDLPromise<T>>::convert):
(WebCore::JSConverter<IDLPromise<T>>::convert):
Promise<T> binding conversion is currently unimplemented, which only means
web developers creating their own PromiseRejectionEvent will not get
autowrapping of values assigned to `promise` in event initialization.
Engine generated events will have expected behavior.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::promiseRejectionTracker):
* bindings/js/JSDOMWindowBase.h:
* bindings/js/JSWorkerGlobalScopeBase.cpp:
Implement HostPromiseRejectionTracker hook for Document but not Worker.
Passes through to the ScriptExecutionContext's tracker.
* bindings/js/JSMainThreadExecState.cpp:
(WebCore::JSMainThreadExecState::didLeaveScriptContext):
* bindings/js/JSMainThreadExecState.h:
(WebCore::JSMainThreadExecState::~JSMainThreadExecState):
When completing script execution and performing microtasks notify
about rejected promises. Technically this should go inside of
performing a microtask checkpoint, except lacking EventLoop
concepts we use ScriptExecutionState.
* dom/EventNames.h:
* dom/EventNames.in:
* dom/PromiseRejectionEvent.cpp: Added.
(WebCore::PromiseRejectionEvent::PromiseRejectionEvent):
(WebCore::PromiseRejectionEvent::~PromiseRejectionEvent):
* dom/PromiseRejectionEvent.h: Added.
* dom/PromiseRejectionEvent.idl: Added.
New PromiseRejectionEvent event interface.
* dom/GlobalEventHandlers.idl:
New onunhandledrejection and onrejectionhandled.
* dom/RejectedPromiseTracker.cpp: Added.
(WebCore::RejectedPromise::RejectedPromise):
(WebCore::RejectedPromise::globalObject):
(WebCore::RejectedPromise::promise):
(WebCore::UnhandledPromise::UnhandledPromise):
(WebCore::UnhandledPromise::callStack):
(WebCore::RejectedPromiseTracker::RejectedPromiseTracker):
(WebCore::RejectedPromiseTracker::~RejectedPromiseTracker):
(WebCore::createScriptCallStackFromReason):
(WebCore::RejectedPromiseTracker::promiseRejected):
(WebCore::RejectedPromiseTracker::promiseHandled):
(WebCore::RejectedPromiseTracker::processQueueSoon):
(WebCore::RejectedPromiseTracker::reportUnhandledRejections):
(WebCore::RejectedPromiseTracker::reportRejectionHandled):
* dom/RejectedPromiseTracker.h: Added.
Track and report rejected promises. The promises are tracked weakly
allowing them to be collected before they are reported. When reporting
we dispatch PromiseRejectionEvent events, and if the default is not
prevented we log a message to the console.
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::reportUnhandledPromiseRejection):
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTrackerSlow):
* dom/ScriptExecutionContext.h:
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTracker):
Each ScriptExecutionContext can own a rejected promise tracker.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::pauseInternal):
https://html.spec.whatwg.org/multipage/embedded-content.html#internal-pause-steps
Internal pause steps say to timeupdate, pause, and rejecting pending play promises
should all happen in a queued task. Here the first two actions are already scheduled
on tasks, but rejecting play promises was not being done in a task, so this makes
that change.
* Modules/streams/ReadableStream.js:
(pipeThrough):
* Modules/streams/ReadableStreamInternals.js:
(readableStreamReaderGenericInitialize):
(readableStreamError):
(readableStreamReaderGenericRelease):
Satisfy parts of the Streams specification which state to set the
[[PromiseIsHandled]] internal state of promises created internally
by the Streams APIs. This prevents some internal promises from
appearing as unhandled promise rejections.
LayoutTests:
* js/dom/unhandled-promise-rejection-basic-expected.txt: Added.
* js/dom/unhandled-promise-rejection-basic.html: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error-expected.txt: Added.
* js/dom/unhandled-promise-rejection-bindings-type-error.html: Added.
* js/dom/unhandled-promise-rejection-console-no-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-no-report.html: Added.
* js/dom/unhandled-promise-rejection-console-report-expected.txt: Added.
* js/dom/unhandled-promise-rejection-console-report.html: Added.
* js/dom/unhandled-promise-rejection-handle-during-event-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-during-event.html: Added.
* js/dom/unhandled-promise-rejection-handle-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler-expected.txt: Added.
* js/dom/unhandled-promise-rejection-handle-in-handler.html: Added.
* js/dom/unhandled-promise-rejection-handle.html: Added.
* js/dom/unhandled-promise-rejection-order-expected.txt: Added.
* js/dom/unhandled-promise-rejection-order.html: Added.
New tests specific to the `onunhandledrejection` and `onrejectionhandled` events.
* resources/testharnessreport.js:
(self.testRunner.add_completion_callback.sanitize):
(self.testRunner.add_completion_callback):
Report results immediately and then finish the test after a turn. This way
if the test ends with a pass, but may get unhandled rejections after
completing which should not make the test appear as if it failed. Some tests
have unhandled promise rejections but are expected to pass. Likewise some
tests perform cleanup in their own completion callbacks, which happen after
this initial completion callback, and we want to report results after all
the work is done as it may eliminate non-deterministic debug test output.
* TestExpectations:
Mark some tests as flakey that have sometimes have unhandled promise rejections.
These tests are all various imported tests that use the testharness.
* fast/mediastream/MediaStream-MediaElement-setObject-null-expected.txt:
* http/tests/security/video-cross-origin-caching-expected.txt:
* inspector/debugger/break-on-exception-throw-in-promise-expected.txt:
* inspector/debugger/break-on-uncaught-exception-throw-in-promise-expected.txt:
* inspector/worker/resources-in-worker-expected.txt:
* js/dom/dom-static-property-for-in-iteration-expected.txt:
* js/dom/global-constructors-attributes-dedicated-worker-expected.txt:
* js/promises-tests/promises-tests-2-2-6-expected.txt:
* platform/mac/inspector/model/remote-object-expected.txt:
* webrtc/libwebrtc/release-while-creating-offer-expected.txt:
* webrtc/libwebrtc/release-while-setting-local-description-expected.txt:
Update tests with unhandled promise rejection messages.
* media/W3C/audio/events/event_pause_manual.html:
* media/audio-playback-restriction-play-expected.txt:
* media/audio-playback-restriction-play.html:
* media/click-volume-bar-not-pausing.html:
* media/remote-control-command-is-user-gesture-expected.txt:
* media/remote-control-command-is-user-gesture.html:
* media/track/track-mode.html:
* media/video-autoplay-allowed-but-fullscreen-required.html:
* media/video-display-none-crash.html:
* media/video-main-content-deny-display-none.html:
* media/video-main-content-deny-not-in-dom.html:
* media/video-main-content-deny-not-visible.html:
* media/video-main-content-deny-obscured.html:
* media/video-main-content-deny-too-small.html:
* media/video-multiple-concurrent-playback-expected.txt:
* media/video-play-audio-require-user-gesture-expected.txt:
* media/video-play-audio-require-user-gesture.html:
* media/video-play-pause-events-expected.txt:
* media/video-play-pause-events.html:
* media/video-play-pause-exception-expected.txt:
* media/video-play-pause-exception.html:
* media/video-play-require-user-gesture-expected.txt:
* media/video-play-require-user-gesture.html:
* media/video-preload-expected.txt:
* media/video-preload.html:
* media/video-test.js:
(handlePromise.handle):
Snuff many possible unhandled promise rejections in media via media.play().
* streams/reference-implementation/pipe-to-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:
These stream tests are out of date and produce unhandled rejections.
* streams/shadowing-Promise.html:
Update non-imported tests to prevent unhandled rejection messages.
Canonical link: https://commits.webkit.org/188310@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215916 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-28 03:33:57 +00:00
|
|
|
// Wait for any other completion callbacks, which may eliminate test elements
|
|
|
|
// from the page and therefore reduce the output.
|
|
|
|
setTimeout(function () {
|
2019-09-08 06:10:28 +00:00
|
|
|
testRunner.forceImmediateCompletion();
|
2016-11-26 23:35:11 +00:00
|
|
|
}, 0);
|
|
|
|
});
|
|
|
|
}
|