Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: LayoutTests/dart/multiscript-js-interop.html

Issue 1663753002: Apply all blink changes between @202695 and tip of trunk (Closed) Base URL: svn://svn.chromium.org/blink/branches/dart/2454_1
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/dart/multiscript-js-interop.dart ('k') | LayoutTests/dart/multiscript-js-interop-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/dart/multiscript-js-interop.html
diff --git a/LayoutTests/dart/Multiscript.html b/LayoutTests/dart/multiscript-js-interop.html
similarity index 65%
copy from LayoutTests/dart/Multiscript.html
copy to LayoutTests/dart/multiscript-js-interop.html
index c4df14cbbc6f0b6f9470818b0a58626b23961143..80a7f1b2717770a8b663dd4c14446b8f53345713 100644
--- a/LayoutTests/dart/Multiscript.html
+++ b/LayoutTests/dart/multiscript-js-interop.html
@@ -2,7 +2,7 @@
<head>
<script type="application/javascript" src="../../../../dart/pkg/unittest/lib/test_controller.js"></script>
<script type="application/javascript">
-var sJs = 0;
+var sJs;
var callbacks = [];
var numCallbacks = 0;
// Trivial method to run all 4 callbacks in order once they are all
@@ -22,91 +22,102 @@ function registerCallback(index, callback) {
<script type="application/dart">
import 'dart:async';
+import 'package:js/js.dart';
import 'package:unittest/unittest.dart';
-import 'Multiscript.dart';
+import 'multiscript-js-interop.dart';
main() {
- State.registerCallback(0, () {
+ State.registerCallback(0, allowInterop(() {
// FIXME: Rewrite this test to use html-imports.
print("Running script 0");
State.update();
- expect(State.sJs, equals(1));
+ expect(State.sJs.length, equals(1));
expect(State.sDart, equals(1));
- });
+ }));
}
</script>
<script type="application/dart">
-import 'dart:js' as js;
+import 'package:js/js.dart';
import 'dart:math';
import 'package:unittest/unittest.dart';
-import 'Multiscript.dart';
+import 'multiscript-js-interop.dart';
+
+@JS()
+external Function get doubleValue;
+@JS()
+external Function set doubleValue(Function v);
main() {
- State.registerCallback(1, () {
+ State.registerCallback(1, allowInterop(() {
print("Running script 1");
State.update();
- expect(State.sJs, equals(2));
+ expect(State.sJs.length, equals(2));
expect(State.sDart, equals(1));
- js.context['doubleValue'] = (x) => x*2;
- expect(js.context.callMethod('doubleValue', [21]), equals(42));
- expect(js.context.callMethod('doubleValue', ["Foo"]), equals("FooFoo"));
+ doubleValue = allowInterop((x) => x*2);
+ expect(doubleValue(21), equals(42));
+ expect(doubleValue("Foo"), equals("FooFoo"));
// Point is not a primitive type so passing it to a different isolate is
// not allowed.
- expect(js.context.callMethod('doubleValue', [new Point(2, 4)]),
+ expect(doubleValue(new Point(2, 4)),
equals(new Point(4, 8)));
- });
+ }));
}
</script>
<script type="application/dart">
+import 'package:js/js.dart';
import 'package:unittest/unittest.dart';
-import 'Multiscript.dart';
+import 'multiscript-js-interop.dart';
main() {
- State.registerCallback(2, () {
+ State.registerCallback(2, allowInterop(() {
print("Running script 2");
State.update();
- expect(State.sJs, equals(3));
+ expect(State.sJs.length, equals(3));
expect(State.sDart, equals(1));
- });
+ }));
}
</script>
<script type="application/dart">
-import 'dart:js' as js;
import 'dart:math';
+import 'package:js/js.dart';
import 'package:unittest/unittest.dart';
import 'package:unittest/html_config.dart';
-import 'Multiscript.dart';
+import 'multiscript-js-interop.dart';
+
+// This function is set by a different isolate.
+@JS()
+external Function get doubleValue;
main() {
- State.registerCallback(3, () {
+ State.registerCallback(3, allowInterop(() {
print("Running script 3");
useHtmlConfiguration(true);
test('Multiple script tags', () {
State.update();
- expect(State.sJs, equals(4));
+ expect(State.sJs.length, equals(4));
expect(State.sDart, equals(1));
// doubleValue is from a different Dart isolate but arguments are primitive
// types so it is safe to call.
- expect(js.context.callMethod('doubleValue', [21]), equals(42));
- expect(js.context.callMethod('doubleValue', ["Foo"]), equals("FooFoo"));
+ expect(doubleValue(21), equals(42));
+ expect(doubleValue("Foo"), equals("FooFoo"));
// Point is not a primitive type so passing it to a different isolate
// using js interop results in a JsObject rather than a Point. A
// NoSuchMethodError is thrown in the other Dart isolate but once the
// error gets to this isolate it shows up as just an Unhandled Exception.
expect(() {
try {
- js.context.callMethod('doubleValue', [new Point(2, 4)]);
+ doubleValue(new Point(2, 4));
} catch (e) {
throw new Exception(e.toString());
}
},
throwsException);
});
- });
+ }));
}
</script>
</body>
« no previous file with comments | « LayoutTests/dart/multiscript-js-interop.dart ('k') | LayoutTests/dart/multiscript-js-interop-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698