| OLD | NEW | 
| (Empty) |  | 
 |    1 <html> | 
 |    2 <head> | 
 |    3 <script type="application/javascript" src="../../../../dart/pkg/unittest/lib/tes
     t_controller.js"></script> | 
 |    4 <script type="application/javascript"> | 
 |    5 var sJs = 0; | 
 |    6 var callbacks = []; | 
 |    7 var numCallbacks = 0; | 
 |    8 // Trivial method to run all 4 callbacks in order once they are all | 
 |    9 // registered. | 
 |   10 function registerCallback(index, callback) { | 
 |   11   callbacks[index] = callback; | 
 |   12   numCallbacks++; | 
 |   13   if (numCallbacks == 4) { | 
 |   14     for (var i = 0; i < numCallbacks; i++) { | 
 |   15       callbacks[i](); | 
 |   16     } | 
 |   17   } | 
 |   18 } | 
 |   19 </script> | 
 |   20 </head> | 
 |   21 <body> | 
 |   22  | 
 |   23 <script type="application/dart"> | 
 |   24 import 'dart:async'; | 
 |   25 import 'package:unittest/unittest.dart'; | 
 |   26 import 'Multiscript.dart'; | 
 |   27  | 
 |   28 main() { | 
 |   29   State.registerCallback(0, () { | 
 |   30     // FIXME: Rewrite this test to use html-imports. | 
 |   31     print("Running script 0"); | 
 |   32     State.update(); | 
 |   33     expect(State.sJs, equals(1)); | 
 |   34     expect(State.sDart, equals(1)); | 
 |   35   }); | 
 |   36 } | 
 |   37 </script> | 
 |   38  | 
 |   39 <script type="application/dart"> | 
 |   40 import 'dart:js' as js; | 
 |   41 import 'dart:math'; | 
 |   42 import 'package:unittest/unittest.dart'; | 
 |   43 import 'Multiscript.dart'; | 
 |   44  | 
 |   45 main() { | 
 |   46   State.registerCallback(1, () { | 
 |   47     print("Running script 1"); | 
 |   48     State.update(); | 
 |   49     expect(State.sJs, equals(2)); | 
 |   50     expect(State.sDart, equals(1)); | 
 |   51     js.context['doubleValue'] = (x) => x*2; | 
 |   52     expect(js.context.callMethod('doubleValue', [21]), equals(42)); | 
 |   53     expect(js.context.callMethod('doubleValue', ["Foo"]), equals("FooFoo")); | 
 |   54     // Point is not a primitive type so passing it to a different isolate is | 
 |   55     // not allowed. | 
 |   56     expect(js.context.callMethod('doubleValue', [new Point(2, 4)]), | 
 |   57         equals(new Point(4, 8))); | 
 |   58   }); | 
 |   59 } | 
 |   60 </script> | 
 |   61  | 
 |   62 <script type="application/dart"> | 
 |   63 import 'package:unittest/unittest.dart'; | 
 |   64 import 'Multiscript.dart'; | 
 |   65  | 
 |   66 main() { | 
 |   67   State.registerCallback(2, () { | 
 |   68     print("Running script 2"); | 
 |   69     State.update(); | 
 |   70     expect(State.sJs, equals(3)); | 
 |   71     expect(State.sDart, equals(1)); | 
 |   72   }); | 
 |   73 } | 
 |   74 </script> | 
 |   75  | 
 |   76 <script type="application/dart"> | 
 |   77 import 'dart:js' as js; | 
 |   78 import 'dart:math'; | 
 |   79 import 'package:unittest/unittest.dart'; | 
 |   80 import 'package:unittest/html_config.dart'; | 
 |   81 import 'Multiscript.dart'; | 
 |   82  | 
 |   83 main() { | 
 |   84   State.registerCallback(3, () { | 
 |   85     print("Running script 3"); | 
 |   86     useHtmlConfiguration(true); | 
 |   87     test('Multiple script tags', () { | 
 |   88       State.update(); | 
 |   89       expect(State.sJs, equals(4)); | 
 |   90       expect(State.sDart, equals(1)); | 
 |   91  | 
 |   92       // doubleValue is from a different Dart isolate but arguments are primitiv
     e | 
 |   93       // types so it is safe to call. | 
 |   94       expect(js.context.callMethod('doubleValue', [21]), equals(42)); | 
 |   95       expect(js.context.callMethod('doubleValue', ["Foo"]), equals("FooFoo")); | 
 |   96       // Point is not a primitive type so passing it to a different isolate | 
 |   97       // using js interop results in a JsObject rather than a Point. A | 
 |   98       // NoSuchMethodError is thrown in the other Dart isolate but once the | 
 |   99       // error gets to this isolate it shows up as just an Unhandled Exception. | 
 |  100       expect(() { | 
 |  101             try { | 
 |  102               js.context.callMethod('doubleValue', [new Point(2, 4)]); | 
 |  103             } catch (e) { | 
 |  104               throw new Exception(e.toString()); | 
 |  105             } | 
 |  106           }, | 
 |  107           throwsException); | 
 |  108     }); | 
 |  109   }); | 
 |  110 } | 
 |  111 </script> | 
 |  112 </body> | 
 |  113 </html> | 
| OLD | NEW |