blob: 2e67bb6678535c2025a01f5af4984cda5b65d4ac [file] [log] [blame]
// Copyright (c) 2018, 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.
// ignore: IMPORT_INTERNAL_LIBRARY
import 'dart:_foreign_helper' as foreign show JS;
// ignore: IMPORT_INTERNAL_LIBRARY
import 'dart:_js_helper';
import 'dart:html_common';
/*element: main:static=[testJSCall(0),
testNativeField(1),
testNativeMethod(0),
testNativeMethodCreates(0),
testNativeMethodReturns(0)],
type=[inst:JSNull]*/
main() {
testJSCall();
testNativeMethod();
testNativeField(null);
testNativeMethodCreates();
testNativeMethodReturns();
}
/*element: testJSCall:
static=[JS<dynamic>(3)],
type=[inst:JSNull,inst:JSString,native:bool,native:int]
*/
testJSCall() => foreign.JS(
'int|bool|NativeUint8List|Rectangle|IdbFactory|SqlDatabase|TypedData|ContextAttributes',
'#',
null);
/*element: testNativeMethod:*/
@JSName('foo')
@SupportedBrowser(SupportedBrowser.CHROME)
// ignore: NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE
testNativeMethod() native;
/*element: testNativeMethodCreates:
type=[native:JSArray<JSArray.E>,native:Null,native:int]
*/
@Creates('int|Null|JSArray')
// ignore: NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE
testNativeMethodCreates() native;
// This will trigger native instantiation and therefore include type use
// `native:X` for all native types. This is truncated to `type=[*]` to avoid
// dependency on the particular types. If `testNativeMethodReturns` was not
// called `testNativeMethodCreates` would instead trigger the native
// instantiations, so the blame is a bit arbitrary.
/*element: testNativeMethodReturns:type=[*]*/
@Returns('String|Null|JSArray')
// ignore: NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE
testNativeMethodReturns() native;
@Native("NativeClass")
class NativeClass {
/*strong.element: NativeClass.field:
type=[
inst:JSBool,
inst:JSNull,
native:JSExtendableArray<JSExtendableArray.E>,
native:Object,
native:String,
native:bool,
native:double,
native:int,
param:Object]
*/
// TODO(johnniwinther): The metadata is defined in dart:html_common and
// therefore derived from platform.dill which doesn't currently include IR
// constants.
/*strongConst.element: NativeClass.field:type=[inst:JSBool,inst:JSNull,param:Object]*/
@annotation_Creates_SerializedScriptValue
final Object field;
factory NativeClass._() {
throw new UnsupportedError("Not supported");
}
}
/*element: testNativeField:
dynamic=[NativeClass.field],
static=[defineProperty(3)],
type=[inst:JSBool,param:NativeClass]
*/
testNativeField(NativeClass c) => c.field;