Forward native static methods

We don't generate these.  Rather than do that, this CL forwards to the
actual JS method instead.

This is the diff on the generated dart_sdk.js:

59732c59732

<     return html$.LengthValue._fromDictionary_1(dictionary_1);

---

>     return dart.global.LengthValue.fromDictionary(dictionary_1);

59894c59894

<     html$.MediaStreamTrack._getSources(dart.fn(value => {

---

>     dart.global.MediaStreamTrack.getSources(dart.fn(value => {

80232c80232

<     html$.Notification._requestPermission(dart.fn(value => {

---

>     dart.global.Notification.requestPermission(dart.fn(value => {

Change-Id: I9e857a808557e4702fb2b99aa518c25b49ff3db7
Reviewed-on: https://dart-review.googlesource.com/29020
Reviewed-by: Terry Lucas <terry@google.com>
Commit-Queue: Vijay Menon <vsm@google.com>
This commit is contained in:
Vijay Menon 2017-12-13 13:38:36 +00:00 committed by commit-bot@chromium.org
parent 4bda53d424
commit e9d03b4120
2 changed files with 30 additions and 0 deletions

View file

@ -3078,6 +3078,17 @@ class CodeGenerator extends Object
var member = _emitMemberName(name,
isStatic: isStatic, type: type, element: accessor);
// A static native element should just forward directly to the
// JS type's member.
if (isStatic && _isExternal(element)) {
var nativeName = getAnnotationName(classElem, isNativeAnnotation);
if (nativeName != null) {
var memberName = getAnnotationName(element, isJSName) ?? member;
return js
.call('#.#.#', [_callHelper('global'), nativeName, memberName]);
}
}
// For instance members, we add implicit-this.
// For method tear-offs, we ensure it's a bound method.
if (element is MethodElement &&

View file

@ -0,0 +1,19 @@
// Copyright (c) 2017, 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.
import 'dart:async';
import 'dart:html';
import 'package:unittest/unittest.dart';
import 'package:unittest/html_config.dart';
import 'package:async_helper/async_helper.dart';
main() async {
useHtmlConfiguration();
test('Notification.requestPermission', () async {
String permission = await Notification.requestPermission();
expect(permission, isNotNull);
});
}