From d012dfc7a64090bf0bff6f3f5ed8c08db1186502 Mon Sep 17 00:00:00 2001 From: Mark Zhou Date: Tue, 24 Sep 2019 00:04:00 +0000 Subject: [PATCH] Removing 'webkit' prefix, as most modern web browsers will accept 'RTCPeerConnection' Fixes #38325 Change-Id: I08589781c8e8647c1e6d403baf4d6106d5308181 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116941 Reviewed-by: Nicholas Shahan Commit-Queue: Mark Zhou Auto-Submit: Mark Zhou --- sdk/lib/html/dart2js/html_dart2js.dart | 24 ++++--------------- sdk_nnbd/lib/html/dart2js/html_dart2js.dart | 24 ++++--------------- tests/lib_2/html/rtc_test.dart | 5 +--- .../dart2js/impl_RTCIceCandidate.darttemplate | 7 +----- .../impl_RTCSessionDescription.darttemplate | 7 +----- .../impl/impl_RTCPeerConnection.darttemplate | 4 ++-- 6 files changed, 13 insertions(+), 58 deletions(-) diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart index 74f0c764956..a8ce5d67a50 100644 --- a/sdk/lib/html/dart2js/html_dart2js.dart +++ b/sdk/lib/html/dart2js/html_dart2js.dart @@ -25457,15 +25457,7 @@ class RtcDtmfToneChangeEvent extends Event { @Native("RTCIceCandidate,mozRTCIceCandidate") class RtcIceCandidate extends Interceptor { factory RtcIceCandidate(Map dictionary) { - // TODO(efortuna): Remove this check if when you can actually construct with - // the unprefixed RTCIceCandidate in Firefox (currently both are defined, - // but one can't be used as a constructor). - var constructorName = JS( - '', - 'window[#]', - Device.isFirefox - ? '${Device.propertyPrefix}RTCIceCandidate' - : 'RTCIceCandidate'); + var constructorName = JS('', 'window[#]', 'RTCIceCandidate'); return JS('RtcIceCandidate', 'new #(#)', constructorName, convertDartToNative_SerializedScriptValue(dictionary)); } @@ -25511,8 +25503,8 @@ class RtcLegacyStatsReport extends Interceptor { @Native("RTCPeerConnection,webkitRTCPeerConnection,mozRTCPeerConnection") class RtcPeerConnection extends EventTarget { factory RtcPeerConnection(Map rtcIceServers, [Map mediaConstraints]) { - var constructorName = JS('RtcPeerConnection', 'window[#]', - '${Device.propertyPrefix}RTCPeerConnection'); + var constructorName = + JS('RtcPeerConnection', 'window[#]', 'RTCPeerConnection'); if (mediaConstraints != null) { return JS( 'RtcPeerConnection', @@ -25847,15 +25839,7 @@ class RtcRtpSender extends Interceptor { @Native("RTCSessionDescription,mozRTCSessionDescription") class RtcSessionDescription extends Interceptor { factory RtcSessionDescription(Map dictionary) { - // TODO(efortuna): Remove this check if when you can actually construct with - // the unprefixed RTCIceCandidate in Firefox (currently both are defined, - // but one can't be used as a constructor). - var constructorName = JS( - '', - 'window[#]', - Device.isFirefox - ? '${Device.propertyPrefix}RTCSessionDescription' - : 'RTCSessionDescription'); + var constructorName = JS('', 'window[#]', 'RTCSessionDescription'); return JS('RtcSessionDescription', 'new #(#)', constructorName, convertDartToNative_SerializedScriptValue(dictionary)); } diff --git a/sdk_nnbd/lib/html/dart2js/html_dart2js.dart b/sdk_nnbd/lib/html/dart2js/html_dart2js.dart index 6fb9b773239..64aa8ab3334 100644 --- a/sdk_nnbd/lib/html/dart2js/html_dart2js.dart +++ b/sdk_nnbd/lib/html/dart2js/html_dart2js.dart @@ -25459,15 +25459,7 @@ class RtcDtmfToneChangeEvent extends Event { @Native("RTCIceCandidate,mozRTCIceCandidate") class RtcIceCandidate extends Interceptor { factory RtcIceCandidate(Map dictionary) { - // TODO(efortuna): Remove this check if when you can actually construct with - // the unprefixed RTCIceCandidate in Firefox (currently both are defined, - // but one can't be used as a constructor). - var constructorName = JS( - '', - 'window[#]', - Device.isFirefox - ? '${Device.propertyPrefix}RTCIceCandidate' - : 'RTCIceCandidate'); + var constructorName = JS('', 'window[#]', 'RTCIceCandidate'); return JS('RtcIceCandidate', 'new #(#)', constructorName, convertDartToNative_SerializedScriptValue(dictionary)); } @@ -25513,8 +25505,8 @@ class RtcLegacyStatsReport extends Interceptor { @Native("RTCPeerConnection,webkitRTCPeerConnection,mozRTCPeerConnection") class RtcPeerConnection extends EventTarget { factory RtcPeerConnection(Map rtcIceServers, [Map mediaConstraints]) { - var constructorName = JS('RtcPeerConnection', 'window[#]', - '${Device.propertyPrefix}RTCPeerConnection'); + var constructorName = + JS('RtcPeerConnection', 'window[#]', 'RTCPeerConnection'); if (mediaConstraints != null) { return JS( 'RtcPeerConnection', @@ -25849,15 +25841,7 @@ class RtcRtpSender extends Interceptor { @Native("RTCSessionDescription,mozRTCSessionDescription") class RtcSessionDescription extends Interceptor { factory RtcSessionDescription(Map dictionary) { - // TODO(efortuna): Remove this check if when you can actually construct with - // the unprefixed RTCIceCandidate in Firefox (currently both are defined, - // but one can't be used as a constructor). - var constructorName = JS( - '', - 'window[#]', - Device.isFirefox - ? '${Device.propertyPrefix}RTCSessionDescription' - : 'RTCSessionDescription'); + var constructorName = JS('', 'window[#]', 'RTCSessionDescription'); return JS('RtcSessionDescription', 'new #(#)', constructorName, convertDartToNative_SerializedScriptValue(dictionary)); } diff --git a/tests/lib_2/html/rtc_test.dart b/tests/lib_2/html/rtc_test.dart index 8819d22c034..6b3c3581adc 100644 --- a/tests/lib_2/html/rtc_test.dart +++ b/tests/lib_2/html/rtc_test.dart @@ -27,10 +27,7 @@ main() { ] }); expect(pc is RtcPeerConnection, isTrue); - // TODO(efortuna): Uncomment this test when RTCPeerConnection correctly - // implements EventListener in Firefox (works correctly in nightly, so - // it's coming!). - //pc.onIceCandidate.listen((candidate) {}); + pc.onIceCandidate.listen((candidate) {}); }); test('ice candidate', () { diff --git a/tools/dom/templates/html/dart2js/impl_RTCIceCandidate.darttemplate b/tools/dom/templates/html/dart2js/impl_RTCIceCandidate.darttemplate index 06b5456eaef..24cc4387b4c 100644 --- a/tools/dom/templates/html/dart2js/impl_RTCIceCandidate.darttemplate +++ b/tools/dom/templates/html/dart2js/impl_RTCIceCandidate.darttemplate @@ -6,12 +6,7 @@ part of $LIBRARYNAME; $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS { factory $CLASSNAME(Map dictionary) { - // TODO(efortuna): Remove this check if when you can actually construct with - // the unprefixed RTCIceCandidate in Firefox (currently both are defined, - // but one can't be used as a constructor). - var constructorName = JS('', 'window[#]', - Device.isFirefox ? '${Device.propertyPrefix}RTCIceCandidate' : - 'RTCIceCandidate'); + var constructorName = JS('', 'window[#]', 'RTCIceCandidate'); return JS('RtcIceCandidate', 'new #(#)', constructorName, convertDartToNative_SerializedScriptValue(dictionary)); } diff --git a/tools/dom/templates/html/dart2js/impl_RTCSessionDescription.darttemplate b/tools/dom/templates/html/dart2js/impl_RTCSessionDescription.darttemplate index 9ca8ceb2ec0..fd57f16fb5f 100644 --- a/tools/dom/templates/html/dart2js/impl_RTCSessionDescription.darttemplate +++ b/tools/dom/templates/html/dart2js/impl_RTCSessionDescription.darttemplate @@ -6,12 +6,7 @@ part of $LIBRARYNAME; $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS { factory $CLASSNAME(Map dictionary) { - // TODO(efortuna): Remove this check if when you can actually construct with - // the unprefixed RTCIceCandidate in Firefox (currently both are defined, - // but one can't be used as a constructor). - var constructorName = JS('', 'window[#]', - Device.isFirefox ? '${Device.propertyPrefix}RTCSessionDescription' : - 'RTCSessionDescription'); + var constructorName = JS('', 'window[#]', 'RTCSessionDescription'); return JS('RtcSessionDescription', 'new #(#)', constructorName, convertDartToNative_SerializedScriptValue(dictionary)); diff --git a/tools/dom/templates/html/impl/impl_RTCPeerConnection.darttemplate b/tools/dom/templates/html/impl/impl_RTCPeerConnection.darttemplate index 868d21537e0..4af23ea20bd 100644 --- a/tools/dom/templates/html/impl/impl_RTCPeerConnection.darttemplate +++ b/tools/dom/templates/html/impl/impl_RTCPeerConnection.darttemplate @@ -6,8 +6,8 @@ part of $LIBRARYNAME; $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS { factory $CLASSNAME(Map rtcIceServers, [Map mediaConstraints]) { - var constructorName = JS('RtcPeerConnection', 'window[#]', - '${Device.propertyPrefix}RTCPeerConnection'); + var constructorName = + JS('RtcPeerConnection', 'window[#]', 'RTCPeerConnection'); if (mediaConstraints != null) { return JS('RtcPeerConnection', 'new #(#,#)', constructorName, convertDartToNative_SerializedScriptValue(rtcIceServers),