OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
| 5 import "dart:_js_helper"; |
5 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
6 | 7 |
7 // Test to see if novel HTML tags are interpreted as HTMLElement. | 8 // Test to see if novel HTML tags are interpreted as HTMLElement. |
8 | 9 |
9 class Element native "HTMLElement" { | 10 @Native("HTMLElement") |
| 11 class Element { |
10 String dartMethod(int x) => 'dartMethod(${nativeMethod(x+1)})'; | 12 String dartMethod(int x) => 'dartMethod(${nativeMethod(x+1)})'; |
11 String nativeMethod(int x) native; | 13 String nativeMethod(int x) native; |
12 } | 14 } |
13 | 15 |
14 makeE() native; | 16 makeE() native; |
15 makeF() native; | 17 makeF() native; |
16 | 18 |
17 void setup() native """ | 19 void setup() native """ |
18 // A novel HTML element. | 20 // A novel HTML element. |
19 function HTMLGoofyElement(){} | 21 function HTMLGoofyElement(){} |
(...skipping 24 matching lines...) Expand all Loading... |
44 var e = makeE(); | 46 var e = makeE(); |
45 Expect.equals('Goofy.nativeMethod(10)', e.nativeMethod(10)); | 47 Expect.equals('Goofy.nativeMethod(10)', e.nativeMethod(10)); |
46 Expect.equals('dartMethod(Goofy.nativeMethod(11))', e.dartMethod(10)); | 48 Expect.equals('dartMethod(Goofy.nativeMethod(11))', e.dartMethod(10)); |
47 | 49 |
48 var f = makeF(); | 50 var f = makeF(); |
49 Expect.throws(() => f.nativeMethod(20), (e) => e is NoSuchMethodError, | 51 Expect.throws(() => f.nativeMethod(20), (e) => e is NoSuchMethodError, |
50 'fake HTML Element must not run Dart method on native class'); | 52 'fake HTML Element must not run Dart method on native class'); |
51 Expect.throws(() => f.dartMethod(20), (e) => e is NoSuchMethodError, | 53 Expect.throws(() => f.dartMethod(20), (e) => e is NoSuchMethodError, |
52 'fake HTML Element must not run native method on native class'); | 54 'fake HTML Element must not run native method on native class'); |
53 } | 55 } |
OLD | NEW |