<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[205953] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/205953">205953</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-09-15 00:21:18 -0700 (Thu, 15 Sep 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>callPromiseFunction should be made usable for custom binding code
https://bugs.webkit.org/show_bug.cgi?id=161961
Patch by Youenn Fablet <youenn@apple.com> on 2016-09-15
Reviewed by Darin Adler.
Source/WebCore:
Covered by updated test.
* bindings/js/JSDOMBinding.h:
(WebCore::castThisValue): Utility function to cast this value to a specific type.
* bindings/js/JSDOMPromise.h:
(WebCore::callPromiseFunction): Updated to take real promise function as a template parameter
for improved efficiency. Added workerMode template parameter.
(WebCore::bindingPromiseFunctionAdapter): Function signature adaptor.
* bindings/js/JSMediaDevicesCustom.cpp:
(WebCore::JSMediaDevicesGetUserMediaPromiseFunction):
(WebCore::JSMediaDevices::getUserMedia): Making use of callPromiseFunction to properly handle exceptions.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation): Updated to use template parameter.
* bindings/scripts/test/JS/JSTestNode.cpp:
(WebCore::jsTestNodePrototypeFunctionTestWorkerPromise):
(WebCore::jsTestNodePrototypeFunctionTestWorkerPromisePromise):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjPrototypeFunctionTestPromiseFunction):
(WebCore::jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgument):
(WebCore::jsTestObjPrototypeFunctionTestPromiseFunctionWithException):
(WebCore::jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgument):
(WebCore::jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1):
(WebCore::jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2):
(WebCore::jsTestObjConstructorFunctionTestStaticPromiseFunction):
(WebCore::jsTestObjConstructorFunctionTestStaticPromiseFunctionWithException):
* bindings/scripts/test/TestNode.idl: Adding Worker promise binding test.
LayoutTests:
* fast/mediastream/MediaDevices-getUserMedia-expected.txt:
* fast/mediastream/MediaDevices-getUserMedia.html: Updated to expect a rejected promise in lieu of an exception.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastmediastreamMediaDevicesgetUserMediaexpectedtxt">trunk/LayoutTests/fast/mediastream/MediaDevices-getUserMedia-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastmediastreamMediaDevicesgetUserMediahtml">trunk/LayoutTests/fast/mediastream/MediaDevices-getUserMedia.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMBindingh">trunk/Source/WebCore/bindings/js/JSDOMBinding.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMPromiseh">trunk/Source/WebCore/bindings/js/JSDOMPromise.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSMediaDevicesCustomcpp">trunk/Source/WebCore/bindings/js/JSMediaDevicesCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestNodecpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestTestNodeidl">trunk/Source/WebCore/bindings/scripts/test/TestNode.idl</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (205952 => 205953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-09-15 06:57:12 UTC (rev 205952)
+++ trunk/LayoutTests/ChangeLog        2016-09-15 07:21:18 UTC (rev 205953)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-09-15 Youenn Fablet <youenn@apple.com>
+
+ callPromiseFunction should be made usable for custom binding code
+ https://bugs.webkit.org/show_bug.cgi?id=161961
+
+ Reviewed by Darin Adler.
+
+ * fast/mediastream/MediaDevices-getUserMedia-expected.txt:
+ * fast/mediastream/MediaDevices-getUserMedia.html: Updated to expect a rejected promise in lieu of an exception.
+
</ins><span class="cx"> 2016-09-14 Jiewen Tan <jiewen_tan@apple.com>
</span><span class="cx">
</span><span class="cx"> Unreviewed, update ios-simulator-wk1 test expectations after migrating to iOS 10
</span></span></pre></div>
<a id="trunkLayoutTestsfastmediastreamMediaDevicesgetUserMediaexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/mediastream/MediaDevices-getUserMedia-expected.txt (205952 => 205953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/mediastream/MediaDevices-getUserMedia-expected.txt        2016-09-15 06:57:12 UTC (rev 205952)
+++ trunk/LayoutTests/fast/mediastream/MediaDevices-getUserMedia-expected.txt        2016-09-15 07:21:18 UTC (rev 205953)
</span><span class="lines">@@ -3,10 +3,10 @@
</span><span class="cx"> On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
</span><span class="cx">
</span><span class="cx">
</span><del>-PASS navigator.mediaDevices.getUserMedia().then(invalidGotStream); threw exception TypeError: Not enough arguments.
</del><span class="cx"> PASS typeof navigator.mediaDevices.webkitGetUserMedia is 'undefined'
</span><span class="cx"> PASS navigator.mediaDevices.getUserMedia({audio:true}).then(gotStream1); did not throw exception.
</span><del>-PASS navigator.mediaDevices.getUserMedia({}) rejected with error: TypeError: Type error
</del><ins>+PASS navigator.mediaDevices.getUserMedia() rejected with error: TypeError: Not enough arguments
+PASS navigator.mediaDevices.getUserMedia({}) rejected with error: TypeError: Type error
</ins><span class="cx"> PASS Stream generated.
</span><span class="cx"> PASS stream.getAudioTracks().length is 1
</span><span class="cx"> PASS stream.getVideoTracks().length is 0
</span></span></pre></div>
<a id="trunkLayoutTestsfastmediastreamMediaDevicesgetUserMediahtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/mediastream/MediaDevices-getUserMedia.html (205952 => 205953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/mediastream/MediaDevices-getUserMedia.html        2016-09-15 06:57:12 UTC (rev 205952)
+++ trunk/LayoutTests/fast/mediastream/MediaDevices-getUserMedia.html        2016-09-15 07:21:18 UTC (rev 205953)
</span><span class="lines">@@ -136,9 +136,11 @@
</span><span class="cx"> shouldNotThrow("navigator.mediaDevices.getUserMedia({video:true}).then(gotStream2);")
</span><span class="cx"> }
</span><span class="cx">
</span><del>- shouldThrow("navigator.mediaDevices.getUserMedia().then(invalidGotStream);");
</del><ins>+ navigator.mediaDevices.getUserMedia().then(invalidGotStream, function(error) {
+ testPassed("navigator.mediaDevices.getUserMedia() rejected with error: " + error);
+ });
</ins><span class="cx"> navigator.mediaDevices.getUserMedia({}).then(invalidGotStream, function(error) {
</span><del>- testPassed(" navigator.mediaDevices.getUserMedia({}) rejected with error: " + error);
</del><ins>+ testPassed("navigator.mediaDevices.getUserMedia({}) rejected with error: " + error);
</ins><span class="cx"> });
</span><span class="cx"> shouldBe("typeof navigator.mediaDevices.webkitGetUserMedia", "'undefined'");
</span><span class="cx"> setUserMediaPermission(true);
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (205952 => 205953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-15 06:57:12 UTC (rev 205952)
+++ trunk/Source/WebCore/ChangeLog        2016-09-15 07:21:18 UTC (rev 205953)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2016-09-15 Youenn Fablet <youenn@apple.com>
+
+ callPromiseFunction should be made usable for custom binding code
+ https://bugs.webkit.org/show_bug.cgi?id=161961
+
+ Reviewed by Darin Adler.
+
+ Covered by updated test.
+
+ * bindings/js/JSDOMBinding.h:
+ (WebCore::castThisValue): Utility function to cast this value to a specific type.
+ * bindings/js/JSDOMPromise.h:
+ (WebCore::callPromiseFunction): Updated to take real promise function as a template parameter
+ for improved efficiency. Added workerMode template parameter.
+ (WebCore::bindingPromiseFunctionAdapter): Function signature adaptor.
+ * bindings/js/JSMediaDevicesCustom.cpp:
+ (WebCore::JSMediaDevicesGetUserMediaPromiseFunction):
+ (WebCore::JSMediaDevices::getUserMedia): Making use of callPromiseFunction to properly handle exceptions.
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateImplementation): Updated to use template parameter.
+ * bindings/scripts/test/JS/JSTestNode.cpp:
+ (WebCore::jsTestNodePrototypeFunctionTestWorkerPromise):
+ (WebCore::jsTestNodePrototypeFunctionTestWorkerPromisePromise):
+ * bindings/scripts/test/JS/JSTestObj.cpp:
+ (WebCore::jsTestObjPrototypeFunctionTestPromiseFunction):
+ (WebCore::jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgument):
+ (WebCore::jsTestObjPrototypeFunctionTestPromiseFunctionWithException):
+ (WebCore::jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgument):
+ (WebCore::jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1):
+ (WebCore::jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2):
+ (WebCore::jsTestObjConstructorFunctionTestStaticPromiseFunction):
+ (WebCore::jsTestObjConstructorFunctionTestStaticPromiseFunctionWithException):
+ * bindings/scripts/test/TestNode.idl: Adding Worker promise binding test.
+
</ins><span class="cx"> 2016-09-14 Jiewen Tan <jiewen_tan@apple.com>
</span><span class="cx">
</span><span class="cx"> WebCrypto algorithms should be exposed via KeyAlgorithm dictionary
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMBindingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (205952 => 205953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h        2016-09-15 06:57:12 UTC (rev 205952)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h        2016-09-15 07:21:18 UTC (rev 205953)
</span><span class="lines">@@ -173,6 +173,8 @@
</span><span class="cx">
</span><span class="cx"> template<typename DOMClass> JSC::JSValue wrap(JSC::ExecState*, JSDOMGlobalObject*, DOMClass&);
</span><span class="cx">
</span><ins>+template<typename JSClass> JSClass& castThisValue(JSC::ExecState&);
+
</ins><span class="cx"> void addImpureProperty(const AtomicString&);
</span><span class="cx">
</span><span class="cx"> const JSC::HashTable& getHashTableForGlobalData(JSC::VM&, const JSC::HashTable& staticTable);
</span><span class="lines">@@ -529,6 +531,14 @@
</span><span class="cx"> return toJSNewlyCreated(state, globalObject, Ref<DOMClass>(domObject));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+template<typename JSClass> inline JSClass& castThisValue(JSC::ExecState& state)
+{
+ auto thisValue = state.thisValue();
+ auto castedThis = JSC::jsDynamicCast<JSClass*>(thisValue);
+ ASSERT(castedThis);
+ return *castedThis;
+}
+
</ins><span class="cx"> inline int32_t finiteInt32Value(JSC::JSValue value, JSC::ExecState* exec, bool& okay)
</span><span class="cx"> {
</span><span class="cx"> double number = value.toNumber(exec);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMPromiseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMPromise.h (205952 => 205953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMPromise.h        2016-09-15 06:57:12 UTC (rev 205952)
+++ trunk/Source/WebCore/bindings/js/JSDOMPromise.h        2016-09-15 07:21:18 UTC (rev 205953)
</span><span class="lines">@@ -157,7 +157,12 @@
</span><span class="cx"> void fulfillPromiseWithArrayBuffer(Ref<DeferredWrapper>&&, const void*, size_t);
</span><span class="cx"> void rejectPromiseWithExceptionIfAny(JSC::ExecState&, JSDOMGlobalObject&, JSC::JSPromiseDeferred&);
</span><span class="cx">
</span><del>-inline JSC::JSValue callPromiseFunction(JSC::ExecState& state, JSC::EncodedJSValue promiseFunction(JSC::ExecState*, Ref<DeferredWrapper>&&))
</del><ins>+using PromiseFunction = void(JSC::ExecState&, Ref<DeferredWrapper>&&);
+
+enum class PromiseExecutionScope { WindowOnly, WindowOrWorker };
+
+template<PromiseFunction promiseFunction, PromiseExecutionScope executionScope>
+inline JSC::JSValue callPromiseFunction(JSC::ExecState& state)
</ins><span class="cx"> {
</span><span class="cx"> JSC::VM& vm = state.vm();
</span><span class="cx"> auto scope = DECLARE_CATCH_SCOPE(vm);
</span><span class="lines">@@ -166,10 +171,10 @@
</span><span class="cx"> JSC::JSPromiseDeferred* promiseDeferred = JSC::JSPromiseDeferred::create(&state, &globalObject);
</span><span class="cx">
</span><span class="cx"> // promiseDeferred can be null when terminating a Worker abruptly.
</span><del>- if (!promiseDeferred)
</del><ins>+ if (executionScope == PromiseExecutionScope::WindowOrWorker && !promiseDeferred)
</ins><span class="cx"> return JSC::jsUndefined();
</span><span class="cx">
</span><del>- promiseFunction(&state, DeferredWrapper::create(&state, &globalObject, promiseDeferred));
</del><ins>+ promiseFunction(state, DeferredWrapper::create(&state, &globalObject, promiseDeferred));
</ins><span class="cx">
</span><span class="cx"> rejectPromiseWithExceptionIfAny(state, globalObject, *promiseDeferred);
</span><span class="cx"> ASSERT_UNUSED(scope, !scope.exception());
</span><span class="lines">@@ -176,6 +181,19 @@
</span><span class="cx"> return promiseDeferred->promise();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+using BindingPromiseFunction = JSC::EncodedJSValue(JSC::ExecState*, Ref<DeferredWrapper>&&);
+template<BindingPromiseFunction bindingFunction>
+inline void bindingPromiseFunctionAdapter(JSC::ExecState& state, Ref<DeferredWrapper>&& promise)
+{
+ bindingFunction(&state, WTFMove(promise));
+}
+
+template<BindingPromiseFunction bindingPromiseFunction, PromiseExecutionScope executionScope>
+inline JSC::JSValue callPromiseFunction(JSC::ExecState& state)
+{
+ return callPromiseFunction<bindingPromiseFunctionAdapter<bindingPromiseFunction>, executionScope>(state);
+}
+
</ins><span class="cx"> // At the moment, Value cannot be a Ref<T> or RefPtr<T>, it should be a DOM class.
</span><span class="cx"> template <typename Value>
</span><span class="cx"> class DOMPromise {
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSMediaDevicesCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSMediaDevicesCustom.cpp (205952 => 205953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSMediaDevicesCustom.cpp        2016-09-15 06:57:12 UTC (rev 205952)
+++ trunk/Source/WebCore/bindings/js/JSMediaDevicesCustom.cpp        2016-09-15 07:21:18 UTC (rev 205953)
</span><span class="lines">@@ -340,13 +340,16 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-JSValue JSMediaDevices::getUserMedia(ExecState& state)
</del><ins>+static void JSMediaDevicesGetUserMediaPromiseFunction(ExecState& state, Ref<DeferredWrapper>&& promise)
</ins><span class="cx"> {
</span><span class="cx"> VM& vm = state.vm();
</span><span class="cx"> auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx">
</span><del>- if (UNLIKELY(state.argumentCount() < 1))
- return JSValue::decode(throwVMError(&state, scope, createNotEnoughArgumentsError(&state)));
</del><ins>+ if (UNLIKELY(state.argumentCount() < 1)) {
+ throwVMError(&state, scope, createNotEnoughArgumentsError(&state));
+ return;
+ }
+
</ins><span class="cx"> ExceptionCode ec = 0;
</span><span class="cx"> auto constraintsDictionary = Dictionary(&state, state.uncheckedArgument(0));
</span><span class="cx">
</span><span class="lines">@@ -374,12 +377,15 @@
</span><span class="cx">
</span><span class="cx"> auto audioConstraints = MediaConstraintsImpl::create(WTFMove(mandatoryAudioConstraints), WTFMove(advancedAudioConstraints), areAudioConstraintsValid);
</span><span class="cx"> auto videoConstraints = MediaConstraintsImpl::create(WTFMove(mandatoryVideoConstraints), WTFMove(advancedVideoConstraints), areVideoConstraintsValid);
</span><del>- JSC::JSPromiseDeferred* promiseDeferred = JSC::JSPromiseDeferred::create(&state, globalObject());
- wrapped().getUserMedia(WTFMove(audioConstraints), WTFMove(videoConstraints), DeferredWrapper::create(&state, globalObject(), promiseDeferred), ec);
</del><ins>+ castThisValue<JSMediaDevices>(state).wrapped().getUserMedia(WTFMove(audioConstraints), WTFMove(videoConstraints), WTFMove(promise), ec);
</ins><span class="cx"> setDOMException(&state, ec);
</span><del>- return promiseDeferred->promise();
</del><span class="cx"> }
</span><span class="cx">
</span><ins>+JSValue JSMediaDevices::getUserMedia(ExecState& state)
+{
+ return callPromiseFunction<JSMediaDevicesGetUserMediaPromiseFunction, PromiseExecutionScope::WindowOnly>(state);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (205952 => 205953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-09-15 06:57:12 UTC (rev 205952)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-09-15 07:21:18 UTC (rev 205953)
</span><span class="lines">@@ -3421,14 +3421,17 @@
</span><span class="cx"> if (IsReturningPromise($function) && !$isCustom) {
</span><span class="cx"> AddToImplIncludes("JSDOMPromise.h");
</span><span class="cx">
</span><ins>+ my $scope = $interface->extendedAttributes->{"Exposed"} ? "WindowOrWorker" : "WindowOnly";
</ins><span class="cx"> push(@implContent, <<END);
</span><span class="cx"> static EncodedJSValue ${functionName}Promise(ExecState*, Ref<DeferredWrapper>&&);
</span><ins>+
</ins><span class="cx"> ${functionReturn} ${functionName}(ExecState* state)
</span><span class="cx"> {
</span><del>- return JSValue::encode(callPromiseFunction(*state, ${functionName}Promise));
</del><ins>+ ASSERT(state);
+ return JSValue::encode(callPromiseFunction<${functionName}Promise, PromiseExecutionScope::${scope}>(*state));
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static inline EncodedJSValue ${functionName}Promise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
</del><ins>+static inline EncodedJSValue ${functionName}Promise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
</ins><span class="cx"> END
</span><span class="cx"> }
</span><span class="cx"> else {
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp (205952 => 205953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp        2016-09-15 06:57:12 UTC (rev 205952)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp        2016-09-15 07:21:18 UTC (rev 205953)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> #include "JSDOMBinding.h"
</span><span class="cx"> #include "JSDOMConstructor.h"
</span><span class="cx"> #include "JSDOMIterator.h"
</span><ins>+#include "JSDOMPromise.h"
</ins><span class="cx"> #include "RuntimeEnabledFeatures.h"
</span><span class="cx"> #include "URL.h"
</span><span class="cx"> #include <runtime/Error.h>
</span><span class="lines">@@ -37,6 +38,7 @@
</span><span class="cx">
</span><span class="cx"> // Functions
</span><span class="cx">
</span><ins>+JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionTestWorkerPromise(JSC::ExecState*);
</ins><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionSymbolIterator(JSC::ExecState*);
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionEntries(JSC::ExecState*);
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionKeys(JSC::ExecState*);
</span><span class="lines">@@ -108,6 +110,7 @@
</span><span class="cx"> {
</span><span class="cx"> { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNodeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNodeConstructor) } },
</span><span class="cx"> { "name", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNodeName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNodeName) } },
</span><ins>+ { "testWorkerPromise", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionTestWorkerPromise), (intptr_t) (0) } },
</ins><span class="cx"> { "entries", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionEntries), (intptr_t) (0) } },
</span><span class="cx"> { "keys", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionKeys), (intptr_t) (0) } },
</span><span class="cx"> { "values", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionValues), (intptr_t) (0) } },
</span><span class="lines">@@ -228,6 +231,28 @@
</span><span class="cx"> return getDOMConstructor<JSTestNodeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static EncodedJSValue jsTestNodePrototypeFunctionTestWorkerPromisePromise(ExecState*, Ref<DeferredWrapper>&&);
+EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionTestWorkerPromise(ExecState* state)
+{
+ ASSERT(state);
+ return JSValue::encode(callPromiseFunction<jsTestNodePrototypeFunctionTestWorkerPromisePromise, true>(*state));
+}
+
+static inline EncodedJSValue jsTestNodePrototypeFunctionTestWorkerPromisePromise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
+{
+ VM& vm = state->vm();
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ UNUSED_PARAM(throwScope);
+ JSValue thisValue = state->thisValue();
+ auto castedThis = jsDynamicCast<JSTestNode*>(thisValue);
+ if (UNLIKELY(!castedThis))
+ return throwThisTypeError(*state, throwScope, "TestNode", "testWorkerPromise");
+ ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestNode::info());
+ auto& impl = castedThis->wrapped();
+ impl.testWorkerPromise(WTFMove(deferredWrapper));
+ return JSValue::encode(jsUndefined());
+}
+
</ins><span class="cx"> using TestNodeIterator = JSDOMIterator<JSTestNode>;
</span><span class="cx"> using TestNodeIteratorPrototype = JSDOMIteratorPrototype<JSTestNode>;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (205952 => 205953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp        2016-09-15 06:57:12 UTC (rev 205952)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp        2016-09-15 07:21:18 UTC (rev 205953)
</span><span class="lines">@@ -7160,7 +7160,8 @@
</span><span class="cx"> static EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionPromise(ExecState*, Ref<DeferredWrapper>&&);
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestPromiseFunction(ExecState* state)
</span><span class="cx"> {
</span><del>- return JSValue::encode(callPromiseFunction(*state, jsTestObjPrototypeFunctionTestPromiseFunctionPromise));
</del><ins>+ ASSERT(state);
+ return JSValue::encode(callPromiseFunction<jsTestObjPrototypeFunctionTestPromiseFunctionPromise, false>(*state));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionPromise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
</span><span class="lines">@@ -7181,7 +7182,8 @@
</span><span class="cx"> static EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgumentPromise(ExecState*, Ref<DeferredWrapper>&&);
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgument(ExecState* state)
</span><span class="cx"> {
</span><del>- return JSValue::encode(callPromiseFunction(*state, jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgumentPromise));
</del><ins>+ ASSERT(state);
+ return JSValue::encode(callPromiseFunction<jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgumentPromise, false>(*state));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgumentPromise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
</span><span class="lines">@@ -7207,7 +7209,8 @@
</span><span class="cx"> static EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithExceptionPromise(ExecState*, Ref<DeferredWrapper>&&);
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestPromiseFunctionWithException(ExecState* state)
</span><span class="cx"> {
</span><del>- return JSValue::encode(callPromiseFunction(*state, jsTestObjPrototypeFunctionTestPromiseFunctionWithExceptionPromise));
</del><ins>+ ASSERT(state);
+ return JSValue::encode(callPromiseFunction<jsTestObjPrototypeFunctionTestPromiseFunctionWithExceptionPromise, false>(*state));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithExceptionPromise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
</span><span class="lines">@@ -7230,7 +7233,8 @@
</span><span class="cx"> static EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgumentPromise(ExecState*, Ref<DeferredWrapper>&&);
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgument(ExecState* state)
</span><span class="cx"> {
</span><del>- return JSValue::encode(callPromiseFunction(*state, jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgumentPromise));
</del><ins>+ ASSERT(state);
+ return JSValue::encode(callPromiseFunction<jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgumentPromise, false>(*state));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgumentPromise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
</span><span class="lines">@@ -7254,7 +7258,8 @@
</span><span class="cx"> static EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1Promise(ExecState*, Ref<DeferredWrapper>&&);
</span><span class="cx"> static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1(ExecState* state)
</span><span class="cx"> {
</span><del>- return JSValue::encode(callPromiseFunction(*state, jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1Promise));
</del><ins>+ ASSERT(state);
+ return JSValue::encode(callPromiseFunction<jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1Promise, false>(*state));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1Promise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
</span><span class="lines">@@ -7280,7 +7285,8 @@
</span><span class="cx"> static EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2Promise(ExecState*, Ref<DeferredWrapper>&&);
</span><span class="cx"> static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2(ExecState* state)
</span><span class="cx"> {
</span><del>- return JSValue::encode(callPromiseFunction(*state, jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2Promise));
</del><ins>+ ASSERT(state);
+ return JSValue::encode(callPromiseFunction<jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2Promise, false>(*state));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2Promise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
</span><span class="lines">@@ -7323,7 +7329,8 @@
</span><span class="cx"> static EncodedJSValue jsTestObjConstructorFunctionTestStaticPromiseFunctionPromise(ExecState*, Ref<DeferredWrapper>&&);
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionTestStaticPromiseFunction(ExecState* state)
</span><span class="cx"> {
</span><del>- return JSValue::encode(callPromiseFunction(*state, jsTestObjConstructorFunctionTestStaticPromiseFunctionPromise));
</del><ins>+ ASSERT(state);
+ return JSValue::encode(callPromiseFunction<jsTestObjConstructorFunctionTestStaticPromiseFunctionPromise, false>(*state));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static inline EncodedJSValue jsTestObjConstructorFunctionTestStaticPromiseFunctionPromise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
</span><span class="lines">@@ -7338,7 +7345,8 @@
</span><span class="cx"> static EncodedJSValue jsTestObjConstructorFunctionTestStaticPromiseFunctionWithExceptionPromise(ExecState*, Ref<DeferredWrapper>&&);
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionTestStaticPromiseFunctionWithException(ExecState* state)
</span><span class="cx"> {
</span><del>- return JSValue::encode(callPromiseFunction(*state, jsTestObjConstructorFunctionTestStaticPromiseFunctionWithExceptionPromise));
</del><ins>+ ASSERT(state);
+ return JSValue::encode(callPromiseFunction<jsTestObjConstructorFunctionTestStaticPromiseFunctionWithExceptionPromise, false>(*state));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static inline EncodedJSValue jsTestObjConstructorFunctionTestStaticPromiseFunctionWithExceptionPromise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestTestNodeidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/TestNode.idl (205952 => 205953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/TestNode.idl        2016-09-15 06:57:12 UTC (rev 205952)
+++ trunk/Source/WebCore/bindings/scripts/test/TestNode.idl        2016-09-15 07:21:18 UTC (rev 205953)
</span><span class="lines">@@ -21,9 +21,10 @@
</span><span class="cx"> [
</span><span class="cx"> Constructor,
</span><span class="cx"> ExportMacro=WEBCORE_TESTSUPPORT_EXPORT,
</span><ins>+ Exposed=(Window,Worker)
</ins><span class="cx"> ] interface TestNode : Node {
</span><span class="cx"> attribute DOMString name;
</span><span class="cx">
</span><span class="cx"> [EnabledAtRuntime=DOMIterator] iterable<TestNode>;
</span><ins>+ Promise testWorkerPromise();
</ins><span class="cx"> };
</span><del>-
</del></span></pre>
</div>
</div>
</body>
</html>