Fixed callbacks typedef to be List instead of a generic typed List.
Fixed getLegacyStats - shouldn't have a JSName annotation.
Fixes #33891
R=sigmund@google.com
Change-Id: Ie9761ad4f3c69fc875cdb1f0d096f48d1528671b
Reviewed-on: https://dart-review.googlesource.com/66400
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Terry Lucas <terry@google.com>
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index b046d1b..6ec6ed5 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -14504,7 +14504,7 @@
// WARNING: Do not edit - generated code.
-typedef void _EntriesCallback(List<Entry> entries);
+typedef void _EntriesCallback(List entries);
// Copyright (c) 2012, 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.
@@ -18843,7 +18843,7 @@
// WARNING: Do not edit - generated code.
typedef void IntersectionObserverCallback(
- List<IntersectionObserverEntry> entries, IntersectionObserver observer);
+ List entries, IntersectionObserver observer);
// Copyright (c) 2012, 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.
@@ -21179,8 +21179,7 @@
// WARNING: Do not edit - generated code.
-typedef void MutationCallback(
- List<MutationRecord> mutations, MutationObserver observer);
+typedef void MutationCallback(List mutations, MutationObserver observer);
// Copyright (c) 2012, 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.
@@ -25106,7 +25105,7 @@
// WARNING: Do not edit - generated code.
typedef void ReportingObserverCallback(
- List<_Report> reports, ReportingObserver observer);
+ List reports, ReportingObserver observer);
// Copyright (c) 2012, 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.
@@ -25481,7 +25480,6 @@
* Temporarily exposes _getStats and old getStats as getLegacyStats until Chrome fully supports
* new getStats API.
*/
- @JSName('getStats')
Future<RtcStatsResponse> getLegacyStats([MediaStreamTrack selector]) {
var completer = new Completer<RtcStatsResponse>();
_getStats((value) {
diff --git a/tests/lib_2/html/callback_list_test.dart b/tests/lib_2/html/callback_list_test.dart
new file mode 100644
index 0000000..71e0902
--- /dev/null
+++ b/tests/lib_2/html/callback_list_test.dart
@@ -0,0 +1,42 @@
+library callback_list_test;
+
+import 'dart:html';
+import 'dart:async';
+
+import 'package:unittest/unittest.dart';
+import 'package:unittest/html_config.dart';
+
+var callbackDone = false;
+bool isCallbackDone() => callbackDone;
+
+Future waitUntilCallbackDone(bool test()) async {
+ var completer = new Completer();
+ check() {
+ if (test()) {
+ completer.complete();
+ } else {
+ new Timer(Duration.zero, check);
+ }
+ }
+
+ check();
+ return completer.future;
+}
+
+void main() async {
+ useHtmlConfiguration();
+ window.navigator.persistentStorage.requestQuota(1024 * 1024, _quotaHandler);
+
+ await waitUntilCallbackDone(isCallbackDone);
+ expect(true, isCallbackDone());
+}
+
+Future _quotaHandler(int byteCount) async {
+ FileSystem filesystem =
+ await window.requestFileSystem(1024 * 1024, persistent: true);
+ DirectoryEntry dir = await filesystem.root;
+ DirectoryReader dirReader = dir.createReader();
+ await dirReader.readEntries();
+ List<Entry> secondEntries = await dirReader.readEntries();
+ callbackDone = true;
+}
diff --git a/tests/lib_2/lib_2_dart2js.status b/tests/lib_2/lib_2_dart2js.status
index 9e3bf1c..c37cc88 100644
--- a/tests/lib_2/lib_2_dart2js.status
+++ b/tests/lib_2/lib_2_dart2js.status
@@ -87,7 +87,6 @@
html/worker_test/functional: RuntimeError # Issue 32261
[ $compiler == dart2js && $runtime == chrome && $strong ]
-html/fileapi_directory_reader_test: RuntimeError
html/interactive_media_test: RuntimeError
[ $compiler == dart2js && $runtime == chromeOnAndroid ]
@@ -117,6 +116,7 @@
html/b_element_test: RuntimeError
html/blob_constructor_test: RuntimeError
html/cache_test: RuntimeError
+html/callback_list_test: RuntimeError
html/callbacks_test: RuntimeError
html/canvas_pixel_array_type_alias_test: RuntimeError
html/canvas_test: RuntimeError
diff --git a/tools/dom/scripts/systemhtml.py b/tools/dom/scripts/systemhtml.py
index 7b7dabf..0fcf00a 100644
--- a/tools/dom/scripts/systemhtml.py
+++ b/tools/dom/scripts/systemhtml.py
@@ -137,6 +137,15 @@
# constructor creation.
_static_classes = set(['Url'])
+# Callback typedefs with generic List (List<nnn>) convert to List
+_callback_list_generics_mapping = monitored.Set('systemhtml._callback_list_generics_mapping', [
+ 'List<Entry>',
+ 'List<IntersectionObserverEntry>',
+ 'List<MutationRecord>',
+ 'List<_Report>',
+])
+
+
# Information for generating element constructors.
#
# TODO(sra): maybe remove all the argument complexity and use cascades.
@@ -524,10 +533,19 @@
annotations = self._metadata.GetFormattedMetadata(self._library_name,
self._interface)
+ params = info.ParametersAsDeclaration(self._DartType);
+
+ types = params.split()
+ if len(types) > 0:
+ mapType = types[0] in _callback_list_generics_mapping
+ if mapType is True:
+ types[0] = 'List'
+ params = " ".join(types)
+
code.Emit('$(ANNOTATIONS)typedef void $NAME($PARAMS);\n',
ANNOTATIONS=annotations,
NAME=typedef_name,
- PARAMS=info.ParametersAsDeclaration(self._DartType))
+ PARAMS=params)
self._backend.GenerateCallback(info)
def GenerateInterface(self):
diff --git a/tools/dom/templates/html/impl/impl_RTCPeerConnection.darttemplate b/tools/dom/templates/html/impl/impl_RTCPeerConnection.darttemplate
index 293fb19..33f503a 100644
--- a/tools/dom/templates/html/impl/impl_RTCPeerConnection.darttemplate
+++ b/tools/dom/templates/html/impl/impl_RTCPeerConnection.darttemplate
@@ -54,7 +54,6 @@
* Temporarily exposes _getStats and old getStats as getLegacyStats until Chrome fully supports
* new getStats API.
*/
- @JSName('getStats')
Future<RtcStatsResponse> getLegacyStats([MediaStreamTrack selector]) {
var completer = new Completer<RtcStatsResponse>();
_getStats((value) {