OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "native_testing.dart"; | 5 import "native_testing.dart"; |
6 | 6 |
7 // Test for dartNativeDispatchHooksTransformer, getTag hook. | 7 // Test for dartNativeDispatchHooksTransformer, getTag hook. |
8 // Same as browser_compat_1_prepatched_test but with prepatching disabled. | 8 // Same as browser_compat_1_prepatched_test but with prepatching disabled. |
9 | 9 |
10 @Native("T1A") | 10 @Native("T1A") |
11 class T1A {} | 11 class T1A {} |
12 | 12 |
13 @Native("T1B") | 13 @Native("T1B") |
14 class T1B {} | 14 class T1B {} |
15 | 15 |
16 @Native("T1C") | 16 @Native("T1C") |
17 class T1C {} | 17 class T1C {} |
18 | 18 |
19 makeT1A() native ; | 19 makeT1A() native ; |
20 makeT1B() native ; | 20 makeT1B() native ; |
21 makeT1C() native ; | 21 makeT1C() native ; |
22 | 22 |
23 int getTagCallCount() native ; | 23 int getTagCallCount() native ; |
24 | 24 |
25 void setup() native r''' | 25 void setup() native r''' |
26 function T1A() { } // Normal native class. | 26 function T1A() { } // Normal native class. |
27 function T1CrazyB() { } // Native class with different constructor name. | 27 function T1CrazyB() { } // Native class with different constructor name. |
28 | 28 |
29 var T1fakeA = (function(){ | 29 var T1fakeA = (function(){ |
30 function T1A() {} // Native class with adversarial constructor name. | 30 function T1A() {} // Native class with adversarial constructor name. |
31 return T1A; | 31 return T1A; |
32 })(); | 32 })(); |
33 | 33 |
34 // Make constructors visible on 'window' for prepatching. | 34 // Make constructors visible on 'window' for prepatching. |
35 if (typeof window == "undefined") window = {} | 35 if (typeof window == "undefined") window = {} |
36 window.T1A = T1A; | 36 window.T1A = T1A; |
37 window.T1CrazyB = T1CrazyB; | 37 window.T1CrazyB = T1CrazyB; |
38 | 38 |
39 makeT1A = function(){return new T1A;}; | 39 makeT1A = function(){return new T1A;}; |
40 makeT1B = function(){return new T1CrazyB;}; | 40 makeT1B = function(){return new T1CrazyB;}; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 Expect.equals(true, t1c is T1C, '$t1c is T1C'); | 86 Expect.equals(true, t1c is T1C, '$t1c is T1C'); |
87 | 87 |
88 Expect.equals(3, getTagCallCount()); | 88 Expect.equals(3, getTagCallCount()); |
89 | 89 |
90 Expect.equals(true, confuse(t1a) is T1A, '$t1a is T1A'); | 90 Expect.equals(true, confuse(t1a) is T1A, '$t1a is T1A'); |
91 Expect.equals(true, confuse(t1b) is T1B, '$t1b is T1B'); | 91 Expect.equals(true, confuse(t1b) is T1B, '$t1b is T1B'); |
92 Expect.equals(true, confuse(t1c) is T1C, '$t1c is T1C'); | 92 Expect.equals(true, confuse(t1c) is T1C, '$t1c is T1C'); |
93 | 93 |
94 Expect.equals(3, getTagCallCount()); | 94 Expect.equals(3, getTagCallCount()); |
95 } | 95 } |
OLD | NEW |