mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
33044ddd9a
Fixes https://github.com/flutter/flutter/issues/66361 Change-Id: I4e68963a36c71bb4dac964d8b0fdcd8ee9187e97 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164101 Reviewed-by: Nicholas Shahan <nshahan@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com> Commit-Queue: Mark Zhou <markzipan@google.com>
51 lines
1.1 KiB
Dart
51 lines
1.1 KiB
Dart
// Copyright (c) 2020, 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.
|
|
|
|
// Tests that JS interop works with hot restart.
|
|
|
|
// Requirements=nnbd
|
|
|
|
@JS()
|
|
library hot_restart_js_interop_test;
|
|
|
|
import 'dart:js' show context;
|
|
import 'dart:js_util';
|
|
import 'dart:_foreign_helper' as helper show JS;
|
|
import 'dart:_runtime' as dart;
|
|
|
|
import 'package:expect/expect.dart';
|
|
import 'package:js/js.dart';
|
|
|
|
@JS()
|
|
external void eval(String code);
|
|
|
|
@JS('window.MyClass')
|
|
class MyClass {
|
|
external MyClass();
|
|
}
|
|
|
|
abstract class Wrapper<T> {
|
|
T? rawObject;
|
|
|
|
Wrapper() {
|
|
final T defaultObject = createDefault();
|
|
rawObject = defaultObject;
|
|
}
|
|
|
|
T createDefault();
|
|
}
|
|
|
|
class WrappedClass extends Wrapper<MyClass> {
|
|
@override
|
|
MyClass createDefault() => MyClass();
|
|
}
|
|
|
|
void main() {
|
|
// See: https://github.com/flutter/flutter/issues/66361
|
|
eval("self.MyClass = function MyClass() {}");
|
|
var c = WrappedClass();
|
|
dart.hotRestart();
|
|
eval("self.MyClass = function MyClass() {}");
|
|
c = WrappedClass();
|
|
}
|