| OLD | NEW |
| 1 import 'dart:html'; | 1 import 'dart:html'; |
| 2 | 2 |
| 3 import 'package:expect/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(() { |
| 18 confuse(e).onfocus = null; |
| 19 }, throwsNoSuchMethodError); |
| 18 }); | 20 }); |
| 19 | |
| 20 } | 21 } |
| 21 | 22 |
| 22 class Decoy { | 23 class Decoy { |
| 23 void set onfocus(x) { throw 'dead code'; } | 24 void set onfocus(x) { |
| 25 throw 'dead code'; |
| 26 } |
| 24 } | 27 } |
| 25 | 28 |
| 26 confuse(x) => opaqueTrue() ? x : (opaqueTrue() ? new Object() : new Decoy()); | 29 confuse(x) => opaqueTrue() ? x : (opaqueTrue() ? new Object() : new Decoy()); |
| 27 | 30 |
| 28 /** Returns `true`, but in a way that confuses the compiler. */ | 31 /** Returns `true`, but in a way that confuses the compiler. */ |
| 29 opaqueTrue() => true; // Expand as needed. | 32 opaqueTrue() => true; // Expand as needed. |
| OLD | NEW |