490421d166
APIs in dart:html (that take a Dictionary) will receive a Dart Map parameter. The Map parameter
must be converted to a Dictionary before passing to the browser's API. Before this change,
any Promise/Future API with a Map/Dictionary parameter never called the Promise and didn't
return a Dart Future - now it does.
This caused a number of breaks especially in Service Workers (register, etc.). Here is a
complete list of the fixed APIs:
BackgroundFetchManager
Future<BackgroundFetchRegistration> fetch(String id, Object requests, [Map options])
CacheStorage
Future match(/*RequestInfo*/ request, [Map options])
CanMakePayment
Future<List<Client>> matchAll([Map options])
CookieStore
Future getAll([Map options])
Future set(String name, String value, [Map options])
CredentialsContainer
Future get([Map options])
Future create([Map options])
DirectoryEntry
Future<Entry> _getDirectory(String path, {Map options})
Future<Entry> _getFile(String path, {Map options})
ImageCapture
Future setOptions(Map photoSettings)
MediaCapabilities
Future<MediaCapabilitiesInfo> decodingInfo(Map configuration)
Future<MediaCapabilitiesInfo> encodingInfo(Map configuration)
MediaStreamTrack
Future applyConstraints([Map constraints])
Navigator
Future requestKeyboardLock([List<String> keyCodes])
Future requestMidiAccess([Map options])
Future share([Map data])
OffscreenCanvas
Future<Blob> convertToBlob([Map options])
PaymentInstruments
Future set(String instrumentKey, Map details)
Permissions
Future<PermissionStatus> query(Map permission)
Future<PermissionStatus> request(Map permissions)
Future<PermissionStatus> revoke(Map permission)
PushManager
Future permissionState([Map options])
Future<PushSubscription> subscribe([Map options])
RtcPeerConnection
REMOVED: Future createAnswer([options_OR_successCallback,
RtcPeerConnectionErrorCallback failureCallback,
Map mediaConstraints])
REMOVED: Future createOffer([options_OR_successCallback,
RtcPeerConnectionErrorCallback failureCallback,
Map rtcOfferOptions])
REMOVED: Future setLocalDescription(Map description, VoidCallback successCallback,
[RtcPeerConnectionErrorCallback failureCallback])
REMOVED: Future setLocalDescription(Map description, VoidCallback successCallback,
[RtcPeerConnectionErrorCallback failureCallback])
Future<RtcSessionDescription> createAnswer([Map options])
Future<RtcSessionDescription> createOffer([Map options])
Future setLocalDescription(Map description)
Future setRemoteDescription(Map description)
ServiceWorkerContainer
Future<ServiceWorkerRegistration> register(String url, [Map options])
ServiceWorkerRegistration
Future<List<Notification>> getNotifications([Map filter])
Future showNotification(String title, [Map options])
VRDevice
Future requestSession([Map options])
Future supportsSession([Map options])
VRSession
Future requestFrameOfReference(String type, [Map options])
Window
Future fetch(/*RequestInfo*/ input, [Map init])
WorkerGlobalScope
Future fetch(/*RequestInfo*/ input, [Map init])
In addition, exposed Service Worker "self" as a static getter named "instance". The
instance is exposed on four different Service Worker classes and can throw a InstanceTypeError
if the instance isn't of the class expected (WorkerGlobalScope.instance will always work
and not throw):
* SharedWorkerGlobalScope.instance
* DedicatedWorkerGlobalScope.instance
* ServiceWorkerGlobalScope.instance
* WorkerGlobalScope.instance
R=vsm@google.com
Bug: #34202
Change-Id: I641ccbff7cc771465dd32c73db20eba5d6667939
Reviewed-on: https://dart-review.googlesource.com/c/74482
Commit-Queue: Terry Lucas <terry@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
Reviewed-by: Jenny Messerly <jmesserly@google.com>
58 lines
2.1 KiB
Plaintext
58 lines
2.1 KiB
Plaintext
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
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');
|
|
if (mediaConstraints != null) {
|
|
return JS('RtcPeerConnection', 'new #(#,#)', constructorName,
|
|
convertDartToNative_SerializedScriptValue(rtcIceServers),
|
|
convertDartToNative_SerializedScriptValue(mediaConstraints));
|
|
} else {
|
|
return JS('RtcPeerConnection', 'new #(#)', constructorName,
|
|
convertDartToNative_SerializedScriptValue(rtcIceServers));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Checks if Real Time Communication (RTC) APIs are supported and enabled on
|
|
* the current platform.
|
|
*/
|
|
static bool get supported {
|
|
// Currently in Firefox some of the RTC elements are defined but throw an
|
|
// error unless the user has specifically enabled them in their
|
|
// about:config. So we have to construct an element to actually test if RTC
|
|
// is supported at the given time.
|
|
try {
|
|
new RtcPeerConnection(
|
|
{"iceServers": [ {"url":"stun:localhost"}]});
|
|
return true;
|
|
} catch (_) { return false;}
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Temporarily exposes _getStats and old getStats as getLegacyStats until Chrome fully supports
|
|
* new getStats API.
|
|
*/
|
|
Future<RtcStatsResponse> getLegacyStats([MediaStreamTrack selector]) {
|
|
var completer = new Completer<RtcStatsResponse>();
|
|
_getStats((value) {
|
|
completer.complete(value);
|
|
}, selector);
|
|
return completer.future;
|
|
}
|
|
@JSName('getStats')
|
|
Future _getStats(
|
|
[RtcStatsCallback successCallback, MediaStreamTrack selector]) native;
|
|
|
|
static Future generateCertificate(/*AlgorithmIdentifier*/ keygenAlgorithm) =>
|
|
JS('dynamic', 'generateCertificate(#)', keygenAlgorithm);
|
|
|
|
$!MEMBERS
|
|
}
|