Changeset 206011 in webkit
- Timestamp:
- Sep 16, 2016 12:51:37 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 deleted
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r206010 r206011 1 2016-09-16 Youenn Fablet <youenn@apple.com> 2 3 Custom promise-returning functions should not throw if callee has not the expected type 4 https://bugs.webkit.org/show_bug.cgi?id=162011 5 6 Reviewed by Sam Weinig. 7 8 * fast/mediastream/MediaDevices-getUserMedia-expected.txt: 9 * fast/mediastream/MediaDevices-getUserMedia.html: Enusing calling getUserMedia on something else than MediaDevices does not throw. 10 * http/tests/media/media-stream/disconnected-frame-already-expected.txt: 11 1 12 2016-09-16 Youenn Fablet <youenn@apple.com> 2 13 -
trunk/LayoutTests/fast/mediastream/MediaDevices-getUserMedia-expected.txt
r205953 r206011 8 8 PASS navigator.mediaDevices.getUserMedia() rejected with error: TypeError: Not enough arguments 9 9 PASS navigator.mediaDevices.getUserMedia({}) rejected with error: TypeError: Type error 10 PASS navigator.mediaDevices.getUserMedia.apply(undefined) rejected with error: TypeError: Can only call MediaDevices.getUserMedia on instances of MediaDevices 10 11 PASS Stream generated. 11 12 PASS stream.getAudioTracks().length is 1 -
trunk/LayoutTests/fast/mediastream/MediaDevices-getUserMedia.html
r205953 r206011 146 146 setUserMediaPermission(true); 147 147 shouldNotThrow("navigator.mediaDevices.getUserMedia({audio:true}).then(gotStream1);"); 148 navigator.mediaDevices.getUserMedia.apply(undefined, {audio:true}).then(invalidGotStream, function(error) { 149 testPassed("navigator.mediaDevices.getUserMedia.apply(undefined) rejected with error: " + error); 150 }); 148 151 149 152 window.jsTestIsAsync = true; -
trunk/LayoutTests/http/tests/media/media-stream/disconnected-frame-already-expected.txt
r191949 r206011 1 CONSOLE MESSAGE: line 24: TypeError: The implementation did not support the requested type of object or operation.1 CONSOLE MESSAGE: line 24: TypeError: Can only call Navigator.webkitGetUserMedia on instances of Navigator 2 2 Tests that when a getUserMedia request is made after its frame has been disconnected, no callbacks are made and no crash occurs. 3 3 -
trunk/Source/JavaScriptCore/ChangeLog
r205998 r206011 1 2016-09-16 Youenn Fablet <youenn@apple.com> 2 3 Custom promise-returning functions should not throw if callee has not the expected type 4 https://bugs.webkit.org/show_bug.cgi?id=162011 5 6 Reviewed by Sam Weinig. 7 8 * JavaScriptCore.xcodeproj/project.pbxproj: Making JSPromiseConstructor.h private 9 1 10 2016-09-15 Filip Pizlo <fpizlo@apple.com> 2 11 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r205666 r206011 1351 1351 7C184E1F17BEE22E007CB63A /* JSPromisePrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C184E1D17BEE22E007CB63A /* JSPromisePrototype.h */; }; 1352 1352 7C184E2217BEE240007CB63A /* JSPromiseConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C184E2017BEE240007CB63A /* JSPromiseConstructor.cpp */; }; 1353 7C184E2317BEE240007CB63A /* JSPromiseConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C184E2117BEE240007CB63A /* JSPromiseConstructor.h */; };1353 7C184E2317BEE240007CB63A /* JSPromiseConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C184E2117BEE240007CB63A /* JSPromiseConstructor.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1354 1354 7E4EE7090EBB7963005934AA /* StructureChain.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E4EE7080EBB7963005934AA /* StructureChain.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1355 1355 7E4EE70F0EBB7A5B005934AA /* StructureChain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E4EE70E0EBB7A5B005934AA /* StructureChain.cpp */; }; -
trunk/Source/WebCore/CMakeLists.txt
r206007 r206011 3659 3659 ${WEBCORE_DIR}/Modules/fetch/FetchResponse.js 3660 3660 ${WEBCORE_DIR}/Modules/fetch/WorkerGlobalScopeFetch.js 3661 ${WEBCORE_DIR}/Modules/mediastream/MediaDevices.js3662 3661 ${WEBCORE_DIR}/Modules/mediastream/NavigatorUserMedia.js 3663 3662 ${WEBCORE_DIR}/Modules/mediastream/RTCPeerConnection.js -
trunk/Source/WebCore/ChangeLog
r206010 r206011 1 2016-09-16 Youenn Fablet <youenn@apple.com> 2 3 Custom promise-returning functions should not throw if callee has not the expected type 4 https://bugs.webkit.org/show_bug.cgi?id=162011 5 6 Reviewed by Sam Weinig. 7 8 Covered by added test. 9 10 Updating code generator to handle this case. 11 Cleaning related getUserMedia implementation. 12 13 * CMakeLists.txt: Removing Modules/mediastream/MediaDevices.js. 14 * DerivedSources.make: Removing Modules/mediastream/MediaDevices.js. 15 * Modules/mediastream/MediaDevices.idl: Cleaning IDL definition 16 * Modules/mediastream/MediaDevices.js: Removing error throwing and so removing file. 17 * Modules/mediastream/NavigatorUserMedia.js: getUsermMediaFromJS to getUserMedia. 18 * WebCore.xcodeproj/project.pbxproj: Removing Modules/mediastream/MediaDevices.js. 19 * bindings/js/JSDOMPromise.cpp: 20 (WebCore::createRejectedPromiseWithTypeError): Helper routine. 21 * bindings/js/JSDOMPromise.h: 22 * bindings/js/WebCoreBuiltinNames.h: getUsermMediaFromJS to getUserMedia. 23 * bindings/scripts/CodeGeneratorJS.pm: 24 (GenerateImplementation): Rejecting promise in case of failing castedThis, but only for custom functions since 25 they are handled differently for non custom methods. 26 (GenerateFunctionCastedThis): 27 * bindings/scripts/test/JS/JSTestObj.cpp: 28 * bindings/scripts/test/JS/JSTestObj.h: 29 * bindings/scripts/test/TestObj.idl: Adding custom promise test. 30 1 31 2016-09-16 Youenn Fablet <youenn@apple.com> 2 32 -
trunk/Source/WebCore/DerivedSources.make
r205929 r206011 1285 1285 $(WebCore)/Modules/fetch/FetchResponse.js \ 1286 1286 ${WebCore}/Modules/fetch/WorkerGlobalScopeFetch.js \ 1287 $(WebCore)/Modules/mediastream/MediaDevices.js \1288 1287 $(WebCore)/Modules/mediastream/NavigatorUserMedia.js \ 1289 1288 $(WebCore)/Modules/mediastream/RTCPeerConnection.js \ -
trunk/Source/WebCore/Modules/mediastream/MediaDevices.idl
r204516 r206011 35 35 MediaTrackSupportedConstraints getSupportedConstraints(); 36 36 37 [ JSBuiltin] Promise getUserMedia(Dictionary options);37 [Custom, PrivateIdentifier, PublicIdentifier] Promise getUserMedia(Dictionary options); 38 38 [RaisesException] Promise enumerateDevices(); 39 40 [PrivateIdentifier, RaisesException, ImplementedAs=getUserMedia, Custom] Promise getUserMediaFromJS(Dictionary options);41 39 }; -
trunk/Source/WebCore/Modules/mediastream/NavigatorUserMedia.js
r196525 r206011 31 31 32 32 // FIXME: We should raise a DOM unsupported exception if there is no navigator and properly detect whether method is not called on a Navigator object. 33 if (!(this.mediaDevices && this.mediaDevices.@getUserMedia FromJS))34 throw new @TypeError("The implementation did not support the requested type of object or operation.");33 if (!(this.mediaDevices && this.mediaDevices.@getUserMedia)) 34 throw @makeThisTypeError("Navigator", "webkitGetUserMedia"); 35 35 36 36 if (arguments.length < 3) … … 45 45 throw new @TypeError("Argument 3 ('errorCallback') to Navigator.webkitGetUserMedia must be a function"); 46 46 47 this.mediaDevices.@getUserMedia FromJS(options).@then(successCallback, errorCallback);47 this.mediaDevices.@getUserMedia(options).@then(successCallback, errorCallback); 48 48 } -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r206007 r206011 10827 10827 9920398018B95BC600B39AF9 /* UserInputBridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserInputBridge.cpp; sourceTree = "<group>"; }; 10828 10828 9920398118B95BC600B39AF9 /* UserInputBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserInputBridge.h; sourceTree = "<group>"; }; 10829 9994E5D81BD843A300F2D835 /* MediaDevices.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = MediaDevices.js; sourceTree = "<group>"; };10830 10829 99C7CCB218C663E40032E413 /* MemoizedDOMResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoizedDOMResult.h; sourceTree = "<group>"; }; 10831 10830 99C7CCB418C6B8990032E413 /* MemoizedDOMResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoizedDOMResult.cpp; sourceTree = "<group>"; }; … … 14479 14478 5EA725CE1ACABCD900EAD17B /* MediaDevices.h */, 14480 14479 5EA725CF1ACABCD900EAD17B /* MediaDevices.idl */, 14481 9994E5D81BD843A300F2D835 /* MediaDevices.js */,14482 14480 07394EC71BAB2CCD00BE99CD /* MediaDevicesRequest.cpp */, 14483 14481 07394EC91BAB2CD700BE99CD /* MediaDevicesRequest.h */, -
trunk/Source/WebCore/bindings/js/JSDOMPromise.cpp
r205569 r206011 29 29 #include "ExceptionCode.h" 30 30 #include "JSDOMError.h" 31 #include <builtins/BuiltinNames.h> 31 32 #include <runtime/Exception.h> 32 33 #include <runtime/JSONObject.h> 34 #include <runtime/JSPromiseConstructor.h> 33 35 34 36 using namespace JSC; … … 113 115 } 114 116 117 JSC::EncodedJSValue createRejectedPromiseWithTypeError(JSC::ExecState& state, const String& errorMessage) 118 { 119 ASSERT(state.lexicalGlobalObject()); 120 auto& globalObject = *state.lexicalGlobalObject(); 121 122 auto promiseConstructor = globalObject.promiseConstructor(); 123 auto rejectFunction = promiseConstructor->get(&state, state.vm().propertyNames->builtinNames().rejectPrivateName()); 124 auto rejectionValue = createTypeError(&state, errorMessage); 125 126 CallData callData; 127 auto callType = getCallData(rejectFunction, callData); 128 ASSERT(callType != CallType::None); 129 130 MarkedArgumentBuffer arguments; 131 arguments.append(rejectionValue); 132 133 return JSValue::encode(call(&state, rejectFunction, callType, callData, promiseConstructor, arguments)); 134 } 135 115 136 static inline JSC::JSValue parseAsJSON(JSC::ExecState* state, const String& data) 116 137 { -
trunk/Source/WebCore/bindings/js/JSDOMPromise.h
r205953 r206011 157 157 void fulfillPromiseWithArrayBuffer(Ref<DeferredWrapper>&&, const void*, size_t); 158 158 void rejectPromiseWithExceptionIfAny(JSC::ExecState&, JSDOMGlobalObject&, JSC::JSPromiseDeferred&); 159 JSC::EncodedJSValue createRejectedPromiseWithTypeError(JSC::ExecState&, const String&); 159 160 160 161 using PromiseFunction = void(JSC::ExecState&, Ref<DeferredWrapper>&&); -
trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
r205348 r206011 49 49 macro(finishConsumingStream) \ 50 50 macro(firstReadCallback) \ 51 macro(getUserMedia FromJS) \51 macro(getUserMedia) \ 52 52 macro(getRemoteStreams) \ 53 53 macro(getSenders) \ -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r205953 r206011 3419 3419 my $functionImplementationName = $function->signature->extendedAttributes->{"ImplementedAs"} || $codeGenerator->WK_lcfirst($function->signature->name); 3420 3420 3421 if (IsReturningPromise($function)) { 3422 AddToImplIncludes("JSDOMPromise.h"); 3423 } 3421 3424 if (IsReturningPromise($function) && !$isCustom) { 3422 AddToImplIncludes("JSDOMPromise.h");3423 3425 3424 3426 my $scope = $interface->extendedAttributes->{"Exposed"} ? "WindowOrWorker" : "WindowOnly"; … … 3471 3473 } 3472 3474 } else { 3473 GenerateFunctionCastedThis($interface, $className, $function); 3475 my $shouldRejectCastedThis = $isCustom && IsReturningPromise($function); 3476 GenerateFunctionCastedThis($interface, $className, $function, $shouldRejectCastedThis); 3474 3477 3475 3478 if ($interface->extendedAttributes->{"CheckSecurity"} and !$function->signature->extendedAttributes->{"DoNotCheckSecurity"}) { … … 3761 3764 sub GenerateFunctionCastedThis 3762 3765 { 3763 my ($interface, $className, $function ) = @_;3766 my ($interface, $className, $function, $shouldRejectPromise) = @_; 3764 3767 3765 3768 if ($interface->extendedAttributes->{"CustomProxyToJSObject"}) { … … 3782 3785 my $domFunctionName = $function->signature->name; 3783 3786 push(@implContent, " if (UNLIKELY(!castedThis))\n"); 3784 push(@implContent, " return throwThisTypeError(*state, throwScope, \"$visibleInterfaceName\", \"$domFunctionName\");\n"); 3787 if ($shouldRejectPromise) { 3788 push(@implContent, " return createRejectedPromiseWithTypeError(*state, makeThisTypeErrorMessage(\"$visibleInterfaceName\", \"$domFunctionName\"));\n"); 3789 } else { 3790 push(@implContent, " return throwThisTypeError(*state, throwScope, \"$visibleInterfaceName\", \"$domFunctionName\");\n"); 3791 } 3785 3792 } 3786 3793 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r205964 r206011 810 810 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionTestStaticPromiseFunction(JSC::ExecState*); 811 811 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionTestStaticPromiseFunctionWithException(JSC::ExecState*); 812 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestCustomPromiseFunction(JSC::ExecState*); 812 813 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNeedsCustomElementReactionStack(JSC::ExecState*); 813 814 #if ENABLE(CONDITION1) || ENABLE(CONDITION2) … … 1412 1413 { "testPromiseFunctionWithOptionalIntArgument", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgument), (intptr_t) (0) } }, 1413 1414 { "testPromiseOverloadedFunction", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionTestPromiseOverloadedFunction), (intptr_t) (1) } }, 1415 { "testCustomPromiseFunction", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionTestCustomPromiseFunction), (intptr_t) (0) } }, 1414 1416 { "methodWithNeedsCustomElementReactionStack", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNeedsCustomElementReactionStack), (intptr_t) (0) } }, 1415 1417 #if ENABLE(CONDITION1) || ENABLE(CONDITION2) … … 7369 7371 } 7370 7372 7373 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestCustomPromiseFunction(ExecState* state) 7374 { 7375 VM& vm = state->vm(); 7376 auto throwScope = DECLARE_THROW_SCOPE(vm); 7377 UNUSED_PARAM(throwScope); 7378 JSValue thisValue = state->thisValue(); 7379 auto castedThis = jsDynamicCast<JSTestObj*>(thisValue); 7380 if (UNLIKELY(!castedThis)) 7381 return createRejectedPromiseWithTypeError(*state, makeThisTypeErrorMessage("TestObject", "testCustomPromiseFunction")); 7382 ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info()); 7383 return JSValue::encode(castedThis->testCustomPromiseFunction(*state)); 7384 } 7385 7371 7386 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNeedsCustomElementReactionStack(ExecState* state) 7372 7387 { -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h
r205458 r206011 66 66 JSC::JSValue customMethodWithArgs(JSC::ExecState&); 67 67 static JSC::JSValue classMethod2(JSC::ExecState&); 68 JSC::JSValue testCustomPromiseFunction(JSC::ExecState&); 68 69 public: 69 70 static const unsigned StructureFlags = JSC::HasStaticPropertyTable | JSC::InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | JSC::OverridesGetOwnPropertySlot | JSC::OverridesGetPropertyNames | Base::StructureFlags; -
trunk/Source/WebCore/bindings/scripts/test/TestObj.idl
r205061 r206011 389 389 static Promise testStaticPromiseFunction(); 390 390 [RaisesException] static Promise testStaticPromiseFunctionWithException(); 391 [Custom] Promise testCustomPromiseFunction(); 391 392 392 393 // PutForwards
Note: See TracChangeset
for help on using the changeset viewer.