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

Unified Diff: LayoutTests/dart/Multiscript.html

Issue 1532413002: Added Dartium changes onto 45.0.2454.104 (Closed) Base URL: http://src.chromium.org/blink/branches/chromium/2454
Patch Set: Created 5 years 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.dart ('k') | LayoutTests/dart/Multiscript-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/dart/Multiscript.html
diff --git a/LayoutTests/dart/Multiscript.html b/LayoutTests/dart/Multiscript.html
new file mode 100644
index 0000000000000000000000000000000000000000..c4df14cbbc6f0b6f9470818b0a58626b23961143
--- /dev/null
+++ b/LayoutTests/dart/Multiscript.html
@@ -0,0 +1,113 @@
+<html>
+<head>
+<script type="application/javascript" src="../../../../dart/pkg/unittest/lib/test_controller.js"></script>
+<script type="application/javascript">
+var sJs = 0;
+var callbacks = [];
+var numCallbacks = 0;
+// Trivial method to run all 4 callbacks in order once they are all
+// registered.
+function registerCallback(index, callback) {
+ callbacks[index] = callback;
+ numCallbacks++;
+ if (numCallbacks == 4) {
+ for (var i = 0; i < numCallbacks; i++) {
+ callbacks[i]();
+ }
+ }
+}
+</script>
+</head>
+<body>
+
+<script type="application/dart">
+import 'dart:async';
+import 'package:unittest/unittest.dart';
+import 'Multiscript.dart';
+
+main() {
+ State.registerCallback(0, () {
+ // FIXME: Rewrite this test to use html-imports.
+ print("Running script 0");
+ State.update();
+ expect(State.sJs, equals(1));
+ expect(State.sDart, equals(1));
+ });
+}
+</script>
+
+<script type="application/dart">
+import 'dart:js' as js;
+import 'dart:math';
+import 'package:unittest/unittest.dart';
+import 'Multiscript.dart';
+
+main() {
+ State.registerCallback(1, () {
+ print("Running script 1");
+ State.update();
+ expect(State.sJs, 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"));
+ // 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)]),
+ equals(new Point(4, 8)));
+ });
+}
+</script>
+
+<script type="application/dart">
+import 'package:unittest/unittest.dart';
+import 'Multiscript.dart';
+
+main() {
+ State.registerCallback(2, () {
+ print("Running script 2");
+ State.update();
+ expect(State.sJs, equals(3));
+ expect(State.sDart, equals(1));
+ });
+}
+</script>
+
+<script type="application/dart">
+import 'dart:js' as js;
+import 'dart:math';
+import 'package:unittest/unittest.dart';
+import 'package:unittest/html_config.dart';
+import 'Multiscript.dart';
+
+main() {
+ State.registerCallback(3, () {
+ print("Running script 3");
+ useHtmlConfiguration(true);
+ test('Multiple script tags', () {
+ State.update();
+ expect(State.sJs, 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"));
+ // 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)]);
+ } catch (e) {
+ throw new Exception(e.toString());
+ }
+ },
+ throwsException);
+ });
+ });
+}
+</script>
+</body>
+</html>
« no previous file with comments | « LayoutTests/dart/Multiscript.dart ('k') | LayoutTests/dart/Multiscript-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698