Title: [159230] trunk
Revision
159230
Author
[email protected]
Date
2013-11-13 13:26:48 -0800 (Wed, 13 Nov 2013)

Log Message

Modifying RTCSessionDescription object construction to match the spec
https://bugs.webkit.org/show_bug.cgi?id=124212

Patch by Thiago de Barros Lacerda <[email protected]> on 2013-11-13
Reviewed by Eric Carlson.

According to the spec the RTCSessionDescriptionInit parameter in RTCSessionDescription constructor is optional,
which must not be nullable. If the 'type' and/or 'sdp' keys are not present, the string object that stores
them in the RTCSessionDescription class, must be null in those cases. Also, if an object that is not a
Dictionary is passed as argument to the constructor, an exception must be raised.

Source/WebCore:

Existing test was updated.

* GNUmakefile.list.am:
* Modules/mediastream/RTCSessionDescription.cpp:
(WebCore::RTCSessionDescription::create):
* Modules/mediastream/RTCSessionDescription.idl:
* UseJSC.cmake:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSRTCSessionDescriptionCustom.cpp: Added.
(WebCore::JSRTCSessionDescriptionConstructor::constructJSRTCSessionDescription):

LayoutTests:

* fast/mediastream/RTCSessionDescription-expected.txt:
* fast/mediastream/RTCSessionDescription.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (159229 => 159230)


--- trunk/LayoutTests/ChangeLog	2013-11-13 21:26:33 UTC (rev 159229)
+++ trunk/LayoutTests/ChangeLog	2013-11-13 21:26:48 UTC (rev 159230)
@@ -1,3 +1,18 @@
+2013-11-13  Thiago de Barros Lacerda  <[email protected]>
+
+        Modifying RTCSessionDescription object construction to match the spec
+        https://bugs.webkit.org/show_bug.cgi?id=124212
+
+        Reviewed by Eric Carlson.
+
+        According to the spec the RTCSessionDescriptionInit parameter in RTCSessionDescription constructor is optional,
+        which must not be nullable. If the 'type' and/or 'sdp' keys are not present, the string object that stores
+        them in the RTCSessionDescription class, must be null in those cases. Also, if an object that is not a
+        Dictionary is passed as argument to the constructor, an exception must be raised.
+
+        * fast/mediastream/RTCSessionDescription-expected.txt:
+        * fast/mediastream/RTCSessionDescription.html:
+
 2013-11-09  Martin Robinson  <[email protected]>
 
         [MathML] The double bar vertical delimiter does not stretch properly

Modified: trunk/LayoutTests/fast/mediastream/RTCSessionDescription-expected.txt (159229 => 159230)


--- trunk/LayoutTests/fast/mediastream/RTCSessionDescription-expected.txt	2013-11-13 21:26:33 UTC (rev 159229)
+++ trunk/LayoutTests/fast/mediastream/RTCSessionDescription-expected.txt	2013-11-13 21:26:48 UTC (rev 159230)
@@ -3,6 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
+PASS sessionDescription = new RTCSessionDescription(); did not throw exception.
 PASS sessionDescription = new RTCSessionDescription(initializer); did not throw exception.
 PASS sessionDescription.type is "offer"
 PASS sessionDescription.sdp is "foobar"
@@ -10,11 +11,12 @@
 PASS sessionDescription = new RTCSessionDescription(initializer); did not throw exception.
 PASS sessionDescription.type is "offer"
 PASS sessionDescription.sdp is "foobar"
-PASS new RTCSessionDescription({}); threw exception Error: TypeMismatchError: DOM Exception 17.
-PASS new RTCSessionDescription(5); threw exception TypeError: Not an object..
-PASS new RTCSessionDescription('foobar'); threw exception TypeError: Not an object..
-PASS new RTCSessionDescription({type:'foobar', sdp:'x'}); threw exception Error: TypeMismatchError: DOM Exception 17.
-PASS new RTCSessionDescription({type:'offer', sdp:''}); threw exception Error: TypeMismatchError: DOM Exception 17.
+PASS new RTCSessionDescription(null); threw exception TypeError: Optional description init argument of RTCSessionDescription must be a valid Dictionary.
+PASS new RTCSessionDescription(5); threw exception TypeError: Optional description init argument of RTCSessionDescription must be a valid Dictionary.
+PASS new RTCSessionDescription('foobar'); threw exception TypeError: Optional description init argument of RTCSessionDescription must be a valid Dictionary.
+PASS new RTCSessionDescription({type:'foobar', sdp:'x'}); threw exception TypeError: Invalid RTCSessionDescription constructor arguments.
+PASS new RTCSessionDescription({type:'offer', sdp:''}); threw exception TypeError: Invalid RTCSessionDescription constructor arguments.
+PASS new RTCSessionDescription({}); did not throw exception.
 PASS new RTCSessionDescription({type:'offer', sdp:'x'}); did not throw exception.
 PASS new RTCSessionDescription({type:'answer', sdp:'x'}); did not throw exception.
 PASS new RTCSessionDescription({type:'pranswer', sdp:'x'}); did not throw exception.

Modified: trunk/LayoutTests/fast/mediastream/RTCSessionDescription.html (159229 => 159230)


--- trunk/LayoutTests/fast/mediastream/RTCSessionDescription.html	2013-11-13 21:26:33 UTC (rev 159229)
+++ trunk/LayoutTests/fast/mediastream/RTCSessionDescription.html	2013-11-13 21:26:48 UTC (rev 159230)
@@ -11,6 +11,7 @@
 
             var initializer = {type:"offer", sdp:"foobar"};
             var sessionDescription;
+            shouldNotThrow("sessionDescription = new RTCSessionDescription();");
             shouldNotThrow("sessionDescription = new RTCSessionDescription(initializer);");
             shouldBe('sessionDescription.type', '"offer"');
             shouldBe('sessionDescription.sdp', '"foobar"');
@@ -21,12 +22,13 @@
             shouldBe('sessionDescription.type', '"offer"');
             shouldBe('sessionDescription.sdp', '"foobar"');
 
-            shouldThrow("new RTCSessionDescription({});");
+            shouldThrow("new RTCSessionDescription(null);");
             shouldThrow("new RTCSessionDescription(5);");
             shouldThrow("new RTCSessionDescription('foobar');");
             shouldThrow("new RTCSessionDescription({type:'foobar', sdp:'x'});");
             shouldThrow("new RTCSessionDescription({type:'offer', sdp:''});");
 
+            shouldNotThrow("new RTCSessionDescription({});");
             shouldNotThrow("new RTCSessionDescription({type:'offer', sdp:'x'});");
             shouldNotThrow("new RTCSessionDescription({type:'answer', sdp:'x'});");
             shouldNotThrow("new RTCSessionDescription({type:'pranswer', sdp:'x'});");

Modified: trunk/Source/WebCore/ChangeLog (159229 => 159230)


--- trunk/Source/WebCore/ChangeLog	2013-11-13 21:26:33 UTC (rev 159229)
+++ trunk/Source/WebCore/ChangeLog	2013-11-13 21:26:48 UTC (rev 159230)
@@ -1,3 +1,28 @@
+2013-11-13  Thiago de Barros Lacerda  <[email protected]>
+
+        Modifying RTCSessionDescription object construction to match the spec
+        https://bugs.webkit.org/show_bug.cgi?id=124212
+
+        Reviewed by Eric Carlson.
+
+        According to the spec the RTCSessionDescriptionInit parameter in RTCSessionDescription constructor is optional,
+        which must not be nullable. If the 'type' and/or 'sdp' keys are not present, the string object that stores
+        them in the RTCSessionDescription class, must be null in those cases. Also, if an object that is not a
+        Dictionary is passed as argument to the constructor, an exception must be raised.
+
+        Existing test was updated.
+
+        * GNUmakefile.list.am:
+        * Modules/mediastream/RTCSessionDescription.cpp:
+        (WebCore::RTCSessionDescription::create):
+        * Modules/mediastream/RTCSessionDescription.idl:
+        * UseJSC.cmake:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSRTCSessionDescriptionCustom.cpp: Added.
+        (WebCore::JSRTCSessionDescriptionConstructor::constructJSRTCSessionDescription):
+
 2013-11-13  Tim Horton  <[email protected]>
 
         Fix release build after r159224.

Modified: trunk/Source/WebCore/GNUmakefile.list.am (159229 => 159230)


--- trunk/Source/WebCore/GNUmakefile.list.am	2013-11-13 21:26:33 UTC (rev 159229)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2013-11-13 21:26:48 UTC (rev 159230)
@@ -2389,6 +2389,7 @@
 	Source/WebCore/bindings/js/JSSQLTransactionCustom.cpp \
 	Source/WebCore/bindings/js/JSSQLTransactionSyncCustom.cpp \
 	Source/WebCore/bindings/js/JSRTCPeerConnectionCustom.cpp \
+	Source/WebCore/bindings/js/JSRTCSessionDescriptionCustom.cpp \
 	Source/WebCore/bindings/js/JSRTCStatsResponseCustom.cpp \
 	Source/WebCore/bindings/js/JSSharedWorkerCustom.cpp \
 	Source/WebCore/bindings/js/JSStorageCustom.cpp \

Modified: trunk/Source/WebCore/Modules/mediastream/RTCSessionDescription.cpp (159229 => 159230)


--- trunk/Source/WebCore/Modules/mediastream/RTCSessionDescription.cpp	2013-11-13 21:26:33 UTC (rev 159229)
+++ trunk/Source/WebCore/Modules/mediastream/RTCSessionDescription.cpp	2013-11-13 21:26:48 UTC (rev 159230)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -49,14 +50,14 @@
 {
     String type;
     bool ok = dictionary.get("type", type);
-    if (!ok || !verifyType(type)) {
+    if (ok && !verifyType(type)) {
         ec = TYPE_MISMATCH_ERR;
         return 0;
     }
 
     String sdp;
     ok = dictionary.get("sdp", sdp);
-    if (!ok || sdp.isEmpty()) {
+    if (ok && sdp.isEmpty()) {
         ec = TYPE_MISMATCH_ERR;
         return 0;
     }

Modified: trunk/Source/WebCore/Modules/mediastream/RTCSessionDescription.idl (159229 => 159230)


--- trunk/Source/WebCore/Modules/mediastream/RTCSessionDescription.idl	2013-11-13 21:26:33 UTC (rev 159229)
+++ trunk/Source/WebCore/Modules/mediastream/RTCSessionDescription.idl	2013-11-13 21:26:48 UTC (rev 159230)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,7 +31,7 @@
 
 [
     Conditional=MEDIA_STREAM,
-    Constructor(Dictionary dictionary),
+    CustomConstructor(optional Dictionary dictionary),
     ConstructorRaisesException
 ] interface RTCSessionDescription {
     [SetterRaisesException] attribute DOMString type;

Modified: trunk/Source/WebCore/UseJSC.cmake (159229 => 159230)


--- trunk/Source/WebCore/UseJSC.cmake	2013-11-13 21:26:33 UTC (rev 159229)
+++ trunk/Source/WebCore/UseJSC.cmake	2013-11-13 21:26:48 UTC (rev 159230)
@@ -244,6 +244,7 @@
         bindings/js/JSMediaSourceStatesCustom.cpp
         bindings/js/JSMediaStreamCapabilitiesCustom.cpp
         bindings/js/JSRTCPeerConnectionCustom.cpp
+        bindings/js/JSRTCSessionDescriptionCustom.cpp
         bindings/js/JSRTCStatsResponseCustom.cpp
     )
 endif ()

Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (159229 => 159230)


--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj	2013-11-13 21:26:33 UTC (rev 159229)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj	2013-11-13 21:26:48 UTC (rev 159230)
@@ -16907,6 +16907,20 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="..\bindings\js\JSRTCSessionDescriptionCustom.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="..\bindings\js\JSRTCStatsResponseCustom.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>

Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (159229 => 159230)


--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters	2013-11-13 21:26:33 UTC (rev 159229)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters	2013-11-13 21:26:48 UTC (rev 159230)
@@ -4476,6 +4476,9 @@
     <ClCompile Include="..\bindings\js\JSRTCPeerConnectionCustom.cpp">
       <Filter>bindings\js</Filter>
     </ClCompile>
+    <ClCompile Include="..\bindings\js\JSRTCSessionDescriptionCustom.cpp">
+      <Filter>bindings\js</Filter>
+    </ClCompile>
     <ClCompile Include="..\bindings\js\JSRTCStatsResponseCustom.cpp">
       <Filter>bindings\js</Filter>
     </ClCompile>
@@ -15098,4 +15101,4 @@
       <Filter>platform\win</Filter>
     </MASM>
   </ItemGroup>
-</Project>
\ No newline at end of file
+</Project>

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (159229 => 159230)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-11-13 21:26:33 UTC (rev 159229)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-11-13 21:26:48 UTC (rev 159230)
@@ -321,6 +321,7 @@
 		07C59B7617F7D0DB000FBCBB /* CapabilityRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 07C59B7417F7D09D000FBCBB /* CapabilityRange.h */; };
 		07CA120E182D67D800D12197 /* JSRTCPeerConnectionCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07CA120D182D67D800D12197 /* JSRTCPeerConnectionCustom.cpp */; };
 		07CE77D516712A6A00C55A47 /* InbandTextTrackPrivateClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 07CE77D416712A6A00C55A47 /* InbandTextTrackPrivateClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		07D07B141834158800ABDD3C /* JSRTCSessionDescriptionCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07D07B131834158800ABDD3C /* JSRTCSessionDescriptionCustom.cpp */; };
 		07DC5FD417D3EEE90099F890 /* JSRTCStatsResponseCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07DC5FD317D3EEE90099F890 /* JSRTCStatsResponseCustom.cpp */; };
 		07E116B11489C9A100EC5ACE /* JSTextTrackCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07E116B01489C9A100EC5ACE /* JSTextTrackCustom.cpp */; };
 		07E117071489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07E117061489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp */; };
@@ -6862,6 +6863,7 @@
 		07C59B7517F7D09D000FBCBB /* CapabilityRange.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CapabilityRange.idl; sourceTree = "<group>"; };
 		07CA120D182D67D800D12197 /* JSRTCPeerConnectionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRTCPeerConnectionCustom.cpp; sourceTree = "<group>"; };
 		07CE77D416712A6A00C55A47 /* InbandTextTrackPrivateClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandTextTrackPrivateClient.h; sourceTree = "<group>"; };
+		07D07B131834158800ABDD3C /* JSRTCSessionDescriptionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRTCSessionDescriptionCustom.cpp; sourceTree = "<group>"; };
 		07DC5FD317D3EEE90099F890 /* JSRTCStatsResponseCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRTCStatsResponseCustom.cpp; sourceTree = "<group>"; };
 		07E116B01489C9A100EC5ACE /* JSTextTrackCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTextTrackCustom.cpp; sourceTree = "<group>"; };
 		07E117061489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTextTrackCueCustom.cpp; sourceTree = "<group>"; };
@@ -19612,6 +19614,7 @@
 		BC4EDEF70C08F414007EDD49 /* Custom */ = {
 			isa = PBXGroup;
 			children = (
+				07D07B131834158800ABDD3C /* JSRTCSessionDescriptionCustom.cpp */,
 				0705851617FB40E9005F2BCB /* JSMediaStreamCapabilitiesCustom.cpp */,
 				07C59B6D17F794F6000FBCBB /* JSMediaSourceStatesCustom.cpp */,
 				BC2ED6BB0C6BD2F000920BFF /* JSAttrCustom.cpp */,
@@ -25703,6 +25706,7 @@
 				41D015CB0F4B5C71004A662F /* ContentType.cpp in Sources */,
 				97627B8D14FB3CEE002CDCA1 /* ContextDestructionObserver.cpp in Sources */,
 				065AD4F60B0C2EDA005A2B1D /* ContextMenuController.cpp in Sources */,
+				07D07B141834158800ABDD3C /* JSRTCSessionDescriptionCustom.cpp in Sources */,
 				06027CB30B1CC03D00884B2D /* ContextMenuItemMac.mm in Sources */,
 				93B6A0EA0B0BCA8400F5027A /* ContextMenuMac.mm in Sources */,
 				FD31602812B0267600C1A359 /* ConvolverNode.cpp in Sources */,

Added: trunk/Source/WebCore/bindings/js/JSRTCSessionDescriptionCustom.cpp (0 => 159230)


--- trunk/Source/WebCore/bindings/js/JSRTCSessionDescriptionCustom.cpp	                        (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSRTCSessionDescriptionCustom.cpp	2013-11-13 21:26:48 UTC (rev 159230)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "JSRTCSessionDescription.h"
+
+#include "Dictionary.h"
+#include "ExceptionCode.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+EncodedJSValue JSC_HOST_CALL JSRTCSessionDescriptionConstructor::constructJSRTCSessionDescription(ExecState* exec)
+{
+    ExceptionCode ec = 0;
+    Dictionary sessionInit;
+    if (exec->argumentCount() > 0) {
+        sessionInit = Dictionary(exec, exec->argument(0));
+        if (!sessionInit.isObject())
+            return throwVMError(exec, createTypeError(exec, "Optional RTCSessionDescription constructor argument must be a valid Dictionary"));
+
+        if (exec->hadException())
+            return JSValue::encode(jsUndefined());
+    }
+
+    JSRTCSessionDescriptionConstructor* jsConstructor = jsCast<JSRTCSessionDescriptionConstructor*>(exec->callee());
+    RefPtr<RTCSessionDescription> sessionDescription = RTCSessionDescription::create(sessionInit, ec);
+    if (ec == TYPE_MISMATCH_ERR) {
+        setDOMException(exec, ec);
+        return throwVMError(exec, createTypeError(exec, "Invalid RTCSessionDescription constructor arguments"));
+    }
+
+    if (ec) {
+        setDOMException(exec, ec);
+        return throwVMError(exec, createTypeError(exec, "Error creating RTCSessionDescription"));
+    }
+
+    return JSValue::encode(CREATE_DOM_WRAPPER(exec, jsConstructor->globalObject(), RTCSessionDescription, sessionDescription.get()));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
+
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to