| OLD | NEW |
| 1 library HistoryTest; | 1 library HistoryTest; |
| 2 import '../../pkg/unittest/lib/unittest.dart'; | 2 import '../../pkg/unittest/lib/unittest.dart'; |
| 3 import '../../pkg/unittest/lib/html_individual_config.dart'; | 3 import '../../pkg/unittest/lib/html_individual_config.dart'; |
| 4 import 'dart:html'; | 4 import 'dart:html'; |
| 5 | 5 |
| 6 /// Waits for a callback once, then removes the event handler. | 6 /// Waits for a callback once, then removes the event handler. |
| 7 void expectAsync1Once(EventListenerList list, void callback(arg)) { | 7 void expectAsync1Once(EventListenerList list, void callback(arg)) { |
| 8 var fn = null; | 8 var fn = null; |
| 9 fn = expectAsync1((arg) { | 9 fn = expectAsync1((arg) { |
| 10 list.remove(fn); | 10 list.remove(fn); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 }); | 38 }); |
| 39 | 39 |
| 40 test('back', () { | 40 test('back', () { |
| 41 expect(() { | 41 expect(() { |
| 42 window.history.pushState(null, document.title, '?dummy1'); | 42 window.history.pushState(null, document.title, '?dummy1'); |
| 43 window.history.pushState(null, document.title, '?dummy2'); | 43 window.history.pushState(null, document.title, '?dummy2'); |
| 44 var length = window.history.length; | 44 var length = window.history.length; |
| 45 | 45 |
| 46 expect(window.location.href.endsWith('dummy2'), isTrue); | 46 expect(window.location.href.endsWith('dummy2'), isTrue); |
| 47 | 47 |
| 48 expectAsync1Once(window.on.popState, (_) { | 48 // Need to wait a frame or two to let the pushState events occur. |
| 49 expect(window.history.length, length); | 49 window.setTimeout(expectAsync0(() { |
| 50 expect(window.location.href.endsWith('dummy1'), isTrue); | 50 expectAsync1Once(window.on.popState, (_) { |
| 51 }); | 51 expect(window.history.length, length); |
| 52 expect(window.location.href.endsWith('dummy1'), isTrue); |
| 53 }); |
| 52 | 54 |
| 53 window.history.back(); | 55 window.history.back(); |
| 56 }), 100); |
| 54 }, expectation); | 57 }, expectation); |
| 55 }); | 58 }); |
| 56 | 59 |
| 57 test('replaceState', () { | 60 test('replaceState', () { |
| 58 expect(() { | 61 expect(() { |
| 59 var length = window.history.length; | 62 var length = window.history.length; |
| 60 | 63 |
| 61 window.history.replaceState(null, document.title, '?foo=baz'); | 64 window.history.replaceState(null, document.title, '?foo=baz'); |
| 62 expect(window.history.length, length); | 65 expect(window.history.length, length); |
| 63 expect(window.location.href.endsWith('foo=baz'), isTrue); | 66 expect(window.location.href.endsWith('foo=baz'), isTrue); |
| 64 }, expectation); | 67 }, expectation); |
| 65 }); | 68 }); |
| 66 }); | 69 }); |
| 67 } | 70 } |
| OLD | NEW |