mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 05:07:52 +00:00
Regression tests for 25658 and 24817.
BUG= R=alanknight@google.com Review URL: https://codereview.chromium.org/2168493002 .
This commit is contained in:
parent
faaff39aa9
commit
bcf224b3e6
|
@ -357,9 +357,11 @@ event_customevent_test: SkipByDesign
|
|||
js_interop_1_test: SkipByDesign
|
||||
js_test: SkipByDesign
|
||||
js_array_test: SkipByDesign
|
||||
js_typed_interop_bind_this_test: SkipByDesign
|
||||
js_typed_interop_test: SkipByDesign
|
||||
js_typed_interop_default_arg_test: SkipByDesign
|
||||
js_typed_interop_type_test: SkipByDesign
|
||||
js_typed_interop_window_property_test: SkipByDesign
|
||||
js_function_getter_test: SkipByDesign
|
||||
js_function_getter_trust_types_test: SkipByDesign
|
||||
js_dart_to_string_test: SkipByDesign
|
||||
|
|
53
tests/html/js_typed_interop_bind_this_test.dart
Normal file
53
tests/html/js_typed_interop_bind_this_test.dart
Normal file
|
@ -0,0 +1,53 @@
|
|||
// Copyright (c) 2016, 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.
|
||||
|
||||
@JS()
|
||||
library js_typed_interop_bind_this_test;
|
||||
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:js/js.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
|
||||
// This is a regression test for https://github.com/dart-lang/sdk/issues/25658
|
||||
|
||||
_injectJs() {
|
||||
document.body.append(new ScriptElement()
|
||||
..type = 'text/javascript'
|
||||
..innerHtml = r"""
|
||||
"use strict";
|
||||
|
||||
function JsTest() {
|
||||
}
|
||||
|
||||
JsTest.returnThis = function(name, value) {
|
||||
return this;
|
||||
};
|
||||
""");
|
||||
}
|
||||
|
||||
@JS('JsTest.returnThis')
|
||||
external returnThis([name, value]);
|
||||
|
||||
@JS('JsTest')
|
||||
external get jsTestObject;
|
||||
|
||||
@JS('window')
|
||||
external get jsWindow;
|
||||
|
||||
main() {
|
||||
_injectJs();
|
||||
|
||||
useHtmlIndividualConfiguration();
|
||||
|
||||
group('bind this', () {
|
||||
test('simple', () {
|
||||
expect(identical(returnThis(), jsWindow), isFalse);
|
||||
expect(identical(returnThis(), null), isFalse);
|
||||
expect(identical(returnThis(), jsTestObject), isTrue);
|
||||
});
|
||||
});
|
||||
}
|
40
tests/html/js_typed_interop_window_property_test.dart
Normal file
40
tests/html/js_typed_interop_window_property_test.dart
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) 2016, 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.
|
||||
|
||||
@JS()
|
||||
library js_typed_interop_window_property_test;
|
||||
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:js/js.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
|
||||
// This is a regression test for https://github.com/dart-lang/sdk/issues/24817
|
||||
|
||||
_injectJs() {
|
||||
document.body.append(new ScriptElement()
|
||||
..type = 'text/javascript'
|
||||
..innerHtml = r"""
|
||||
"use strict";
|
||||
|
||||
window.foo = [function() { return 42; }];
|
||||
""");
|
||||
}
|
||||
|
||||
@JS("window.foo")
|
||||
external List<Function> get foo;
|
||||
|
||||
main() {
|
||||
_injectJs();
|
||||
|
||||
useHtmlIndividualConfiguration();
|
||||
|
||||
group('bind this', () {
|
||||
test('simple', () {
|
||||
expect(foo[0](), equals(42));
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue