OLD | NEW |
1 import 'dart:html'; | 1 import 'dart:html'; |
2 | 2 |
3 import 'package:minitest/minitest.dart'; | 3 import 'package:expect/minitest.dart'; |
4 | 4 |
5 // Test that the dart:html API does not leak native jsdom methods: | 5 // Test that the dart:html API does not leak native jsdom methods: |
6 // onfocus setter. | 6 // onfocus setter. |
7 | 7 |
8 main() { | 8 main() { |
9 test('test1', () { | 9 test('test1', () { |
10 document.body.children.add(new Element.html(r''' | 10 document.body.children.add(new Element.html(r''' |
11 <div id='div1'> | 11 <div id='div1'> |
12 Hello World! | 12 Hello World! |
13 </div>''')); | 13 </div>''')); |
14 Element e = document.query('#div1'); | 14 Element e = document.query('#div1'); |
15 expect(e, isNotNull); | 15 expect(e, isNotNull); |
16 | 16 |
17 expect(() { confuse(e).onfocus = null; }, throwsNoSuchMethodError); | 17 expect(() { confuse(e).onfocus = null; }, throwsNoSuchMethodError); |
18 }); | 18 }); |
19 | 19 |
20 } | 20 } |
21 | 21 |
22 class Decoy { | 22 class Decoy { |
23 void set onfocus(x) { throw 'dead code'; } | 23 void set onfocus(x) { throw 'dead code'; } |
24 } | 24 } |
25 | 25 |
26 confuse(x) => opaqueTrue() ? x : (opaqueTrue() ? new Object() : new Decoy()); | 26 confuse(x) => opaqueTrue() ? x : (opaqueTrue() ? new Object() : new Decoy()); |
27 | 27 |
28 /** Returns `true`, but in a way that confuses the compiler. */ | 28 /** Returns `true`, but in a way that confuses the compiler. */ |
29 opaqueTrue() => true; // Expand as needed. | 29 opaqueTrue() => true; // Expand as needed. |
OLD | NEW |