[dart:html] Migrate html js tests to NNBD
Change-Id: I01cf3de95f4d7c67f97d440187a2d7254c7daecc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140646 Reviewed-by: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
73b325c419
commit
39509bae5f
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
@JS("ArrayTest.Util")
|
||||
library js_array_test;
|
||||
|
||||
@@ -15,7 +13,7 @@ import 'package:expect/minitest.dart';
|
||||
import 'json_helper.dart' as json_helper;
|
||||
|
||||
_injectJs() {
|
||||
document.body.append(new ScriptElement()
|
||||
document.body!.append(new ScriptElement()
|
||||
..type = 'text/javascript'
|
||||
..innerHtml = r"""
|
||||
ArrayTest = {};
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
import 'dart:html';
|
||||
import 'dart:indexed_db' show IdbFactory, KeyRange;
|
||||
import 'dart:typed_data' show Int32List;
|
||||
@@ -26,8 +24,8 @@ main() {
|
||||
expect(node['testProperty'], 'test');
|
||||
});
|
||||
|
||||
test('primitives and null throw ArgumentError', () {
|
||||
for (var v in ['a', 1, 2.0, true, null]) {
|
||||
test('primitives throw ArgumentError', () {
|
||||
for (var v in ['a', 1, 2.0, true]) {
|
||||
expect(() => new JsObject.fromBrowserObject(v), throwsArgumentError);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
@JS()
|
||||
library js_dart_to_string_test;
|
||||
|
||||
@@ -13,7 +11,7 @@ import 'package:js/js.dart';
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
_injectJs() {
|
||||
document.body.append(new ScriptElement()
|
||||
document.body!.append(new ScriptElement()
|
||||
..type = 'text/javascript'
|
||||
..innerHtml = r"""
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
@JS()
|
||||
library js_function_getter_test;
|
||||
|
||||
@@ -13,7 +11,7 @@ import 'package:js/js.dart';
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
_injectJs() {
|
||||
document.body.append(new ScriptElement()
|
||||
document.body!.append(new ScriptElement()
|
||||
..type = 'text/javascript'
|
||||
..innerHtml = r"""
|
||||
var bar = { };
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
library JsInterop1Test;
|
||||
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
@@ -14,7 +12,7 @@ injectSource(code) {
|
||||
final script = new ScriptElement();
|
||||
script.type = 'text/javascript';
|
||||
script.innerHtml = code;
|
||||
document.body.append(script);
|
||||
document.body!.append(script);
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
library TestJsUtils;
|
||||
|
||||
import 'dart:html';
|
||||
@@ -190,7 +188,7 @@ var someObject = Object.create(someProto);
|
||||
someObject.role = "object";
|
||||
|
||||
""";
|
||||
document.body.append(script);
|
||||
document.body!.append(script);
|
||||
}
|
||||
|
||||
typedef bool StringToBool(String s);
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
import 'dart:html';
|
||||
import 'dart:indexed_db' show IdbFactory, KeyRange;
|
||||
import 'dart:typed_data' show Int32List;
|
||||
@@ -28,7 +26,7 @@ main() {
|
||||
|
||||
test('foreign browser objects should be proxied', () {
|
||||
var iframe = new IFrameElement();
|
||||
document.body.children.add(iframe);
|
||||
document.body!.children.add(iframe);
|
||||
var proxy = new JsObject.fromBrowserObject(iframe);
|
||||
|
||||
// Window
|
||||
@@ -55,7 +53,7 @@ main() {
|
||||
|
||||
test('foreign functions pass function is checks', () {
|
||||
var iframe = new IFrameElement();
|
||||
document.body.children.add(iframe);
|
||||
document.body!.children.add(iframe);
|
||||
var proxy = new JsObject.fromBrowserObject(iframe);
|
||||
|
||||
var contentWindow = proxy['contentWindow'];
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
// SharedOptions=--experimental-trust-js-interop-type-annotations
|
||||
|
||||
// Same test as js_typed_interop_anonymous2, but using the
|
||||
@@ -20,17 +18,17 @@ import 'package:expect/minitest.dart';
|
||||
@JS()
|
||||
@anonymous
|
||||
class A {
|
||||
external factory A({B b});
|
||||
external factory A({B? b});
|
||||
|
||||
external B get b;
|
||||
external B? get b;
|
||||
}
|
||||
|
||||
@JS()
|
||||
@anonymous
|
||||
class B {
|
||||
external factory B({C c});
|
||||
external factory B({C? c});
|
||||
|
||||
external C get c;
|
||||
external C? get c;
|
||||
}
|
||||
|
||||
@JS()
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
@JS()
|
||||
library js_typed_interop_anonymous2_test;
|
||||
|
||||
@@ -16,17 +14,17 @@ import 'package:expect/minitest.dart';
|
||||
@JS()
|
||||
@anonymous
|
||||
class A {
|
||||
external factory A({B b});
|
||||
external factory A({B? b});
|
||||
|
||||
external B get b;
|
||||
external B? get b;
|
||||
}
|
||||
|
||||
@JS()
|
||||
@anonymous
|
||||
class B {
|
||||
external factory B({C c});
|
||||
external factory B({C? c});
|
||||
|
||||
external C get c;
|
||||
external C? get c;
|
||||
}
|
||||
|
||||
@JS()
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
// SharedOptions=--experimental-trust-js-interop-type-annotations
|
||||
|
||||
// Same test as js_typed_interop_anonymous, but using the
|
||||
@@ -20,11 +18,11 @@ import 'package:expect/minitest.dart';
|
||||
@JS()
|
||||
@anonymous
|
||||
class Literal {
|
||||
external factory Literal({int x, String y, num z});
|
||||
external factory Literal({int? x, String? y, num? z});
|
||||
|
||||
external int get x;
|
||||
external String get y;
|
||||
external num get z;
|
||||
external int? get x;
|
||||
external String? get y;
|
||||
external num? get z;
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
@JS()
|
||||
library js_typed_interop_anonymous_test;
|
||||
|
||||
@@ -13,23 +11,23 @@ import 'package:expect/minitest.dart';
|
||||
@JS()
|
||||
@anonymous
|
||||
class Literal {
|
||||
external factory Literal({int x, String y, num z});
|
||||
external factory Literal({int? x, String? y, num? z});
|
||||
|
||||
external set x(int v);
|
||||
external int get x;
|
||||
external String get y;
|
||||
external num get z;
|
||||
external set x(int? v);
|
||||
external int? get x;
|
||||
external String? get y;
|
||||
external num? get z;
|
||||
}
|
||||
|
||||
class MockLiteral implements Literal {
|
||||
int _v = 0;
|
||||
set x(int v) {
|
||||
int? _v = 0;
|
||||
set x(int? v) {
|
||||
_v = v;
|
||||
}
|
||||
|
||||
int get x => _v;
|
||||
String get y => "";
|
||||
num get z => 1;
|
||||
int? get x => _v;
|
||||
String? get y => "";
|
||||
num? get z => 1;
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
// SharedOptions=--experimental-trust-js-interop-type-annotations
|
||||
|
||||
// Same test as js_typed_interop_anonymous_unreachable, but using the
|
||||
@@ -20,7 +18,7 @@ import 'package:expect/minitest.dart';
|
||||
@JS()
|
||||
@anonymous
|
||||
class Literal {
|
||||
external factory Literal({int x, String y, num z});
|
||||
external factory Literal({required int x, required String y, required num z});
|
||||
|
||||
external int get x;
|
||||
external String get y;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
@JS()
|
||||
library js_typed_interop_anonymous_unreachable_test;
|
||||
|
||||
@@ -16,7 +14,7 @@ import 'package:expect/minitest.dart';
|
||||
@JS()
|
||||
@anonymous
|
||||
class Literal {
|
||||
external factory Literal({int x, String y, num z});
|
||||
external factory Literal({required int x, required String y, required num z});
|
||||
|
||||
external int get x;
|
||||
external String get y;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
@JS()
|
||||
library js_typed_interop_bind_this_test;
|
||||
|
||||
@@ -15,7 +13,7 @@ import 'package:expect/minitest.dart';
|
||||
// This is a regression test for https://github.com/dart-lang/sdk/issues/25658
|
||||
|
||||
_injectJs() {
|
||||
document.body.append(new ScriptElement()
|
||||
document.body!.append(new ScriptElement()
|
||||
..type = 'text/javascript'
|
||||
..innerHtml = r"""
|
||||
"use strict";
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
@JS()
|
||||
library js_typed_interop_callable_object_test;
|
||||
|
||||
@@ -20,7 +18,7 @@ import 'package:expect/minitest.dart';
|
||||
confuse(x) => x;
|
||||
|
||||
_injectJs() {
|
||||
document.body.append(new ScriptElement()
|
||||
document.body!.append(new ScriptElement()
|
||||
..type = 'text/javascript'
|
||||
..innerHtml = r"""
|
||||
"use strict";
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
@JS()
|
||||
library js_typed_interop_test;
|
||||
|
||||
@@ -13,7 +11,7 @@ import 'package:js/js.dart';
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
_injectJs() {
|
||||
document.body.append(new ScriptElement()
|
||||
document.body!.append(new ScriptElement()
|
||||
..type = 'text/javascript'
|
||||
..innerHtml = r"""
|
||||
var Foo = {
|
||||
@@ -26,10 +24,10 @@ _injectJs() {
|
||||
@JS()
|
||||
class Foo {
|
||||
// Note: it's invalid to provide a default value.
|
||||
external static num get42([num b
|
||||
external static num get42([num? b
|
||||
= 3 // //# default_value: compile-time error
|
||||
]);
|
||||
external static num get43([num b]);
|
||||
external static num get43([num? b]);
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
@JS()
|
||||
library js_typed_interop_anonymous_test;
|
||||
|
||||
@@ -17,12 +15,12 @@ import 'package:expect/minitest.dart';
|
||||
@JS()
|
||||
@anonymous
|
||||
class Literal {
|
||||
external factory Literal({int x, String y, num z, Function foo});
|
||||
external factory Literal({int? x, String? y, num? z, Function? foo});
|
||||
|
||||
external int get x;
|
||||
external String get y;
|
||||
external num get z;
|
||||
external Function get foo;
|
||||
external int? get x;
|
||||
external String? get y;
|
||||
external num? get z;
|
||||
external Function? get foo;
|
||||
}
|
||||
|
||||
@JS()
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
@JS()
|
||||
library js_typed_interop_rename_static_test;
|
||||
|
||||
@@ -50,7 +48,7 @@ class Foo {
|
||||
}
|
||||
|
||||
main() {
|
||||
document.body.append(new ScriptElement()
|
||||
document.body!.append(new ScriptElement()
|
||||
..type = 'text/javascript'
|
||||
..innerHtml = r"""
|
||||
window.JSFoo = {
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
@JS()
|
||||
library js_typed_interop_anonymous2_test;
|
||||
|
||||
@@ -14,21 +12,21 @@ import 'package:expect/minitest.dart';
|
||||
@anonymous
|
||||
class A {
|
||||
external int get x;
|
||||
external factory A({int x});
|
||||
external factory A({required int x});
|
||||
}
|
||||
|
||||
@JS()
|
||||
@anonymous
|
||||
class C {
|
||||
external int get x;
|
||||
external factory C({int x});
|
||||
external factory C({required int x});
|
||||
}
|
||||
|
||||
@JS()
|
||||
@anonymous
|
||||
class B {
|
||||
external int get x;
|
||||
external factory B({int x});
|
||||
external factory B({required int x});
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
@JS()
|
||||
library js_typed_interop_test;
|
||||
|
||||
@@ -13,7 +11,7 @@ import 'package:js/js.dart';
|
||||
import 'package:expect/minitest.dart';
|
||||
|
||||
_injectJs() {
|
||||
document.body.append(new ScriptElement()
|
||||
document.body!.append(new ScriptElement()
|
||||
..type = 'text/javascript'
|
||||
..innerHtml = r"""
|
||||
"use strict";
|
||||
@@ -122,7 +120,7 @@ class ClassWithFactory {
|
||||
external get b;
|
||||
}
|
||||
|
||||
typedef num MultiplyWithDefault(num a, [num b]);
|
||||
typedef num MultiplyWithDefault(num a, [num? b]);
|
||||
|
||||
@JS()
|
||||
@anonymous
|
||||
@@ -138,17 +136,17 @@ class Foo {
|
||||
external callClosureWithArg2(Function closure, arg1, arg2);
|
||||
external Bar getBar();
|
||||
|
||||
external static num multiplyDefault2(num a, [num b]);
|
||||
external static num multiplyDefault2(num a, [num? b]);
|
||||
}
|
||||
|
||||
@anonymous
|
||||
@JS()
|
||||
class ExampleLiteral {
|
||||
external factory ExampleLiteral({int x, String y, num z});
|
||||
external factory ExampleLiteral({int? x, String? y, num? z});
|
||||
|
||||
external int get x;
|
||||
external String get y;
|
||||
external num get z;
|
||||
external int? get x;
|
||||
external String? get y;
|
||||
external num? get z;
|
||||
}
|
||||
|
||||
@anonymous
|
||||
@@ -208,7 +206,7 @@ external num get propertyOnDocument;
|
||||
external num get propertyOnWindow;
|
||||
|
||||
class DartClassWithNullField {
|
||||
int x;
|
||||
int? x;
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
@JS()
|
||||
library js_typed_interop_type_test;
|
||||
|
||||
@@ -28,7 +26,7 @@ class B {
|
||||
@JS()
|
||||
@anonymous
|
||||
class C {
|
||||
final foo;
|
||||
late final foo;
|
||||
|
||||
external factory C({foo});
|
||||
}
|
||||
@@ -36,7 +34,7 @@ class C {
|
||||
@JS()
|
||||
@anonymous
|
||||
class D {
|
||||
final foo;
|
||||
late final foo;
|
||||
|
||||
external factory D({foo});
|
||||
}
|
||||
@@ -84,7 +82,7 @@ testF(F o) {
|
||||
}
|
||||
|
||||
_injectJs() {
|
||||
document.body.append(new ScriptElement()
|
||||
document.body!.append(new ScriptElement()
|
||||
..type = 'text/javascript'
|
||||
..innerHtml = r"""
|
||||
function A(foo) {
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
@JS()
|
||||
library js_typed_interop_window_property_test;
|
||||
|
||||
@@ -15,7 +13,7 @@ import 'package:expect/expect.dart';
|
||||
// This is a regression test for https://github.com/dart-lang/sdk/issues/24817
|
||||
|
||||
_injectJs() {
|
||||
document.body.append(new ScriptElement()
|
||||
document.body!.append(new ScriptElement()
|
||||
..type = 'text/javascript'
|
||||
..innerHtml = r"""
|
||||
"use strict";
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// 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.
|
||||
|
||||
// @dart = 2.7
|
||||
|
||||
@JS()
|
||||
library js_native_test;
|
||||
|
||||
@@ -65,7 +63,7 @@ function getResolvedPromise() {
|
||||
}
|
||||
|
||||
""";
|
||||
document.body.append(script);
|
||||
document.body!.append(script);
|
||||
}
|
||||
|
||||
@JS()
|
||||
|
||||
Reference in New Issue
Block a user