| 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 import 'dart:async'; | |
| 6 | 5 |
| 7 main() { | 6 main() { |
| 8 useHtmlIndividualConfiguration(); | 7 useHtmlIndividualConfiguration(); |
| 9 | 8 |
| 10 group('supported_state', () { | 9 group('supported_state', () { |
| 11 test('supportsState', () { | 10 test('supportsState', () { |
| 12 expect(History.supportsState, true); | 11 expect(History.supportsState, true); |
| 13 }); | 12 }); |
| 14 }); | 13 }); |
| 15 | 14 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 36 | 35 |
| 37 test('back', () { | 36 test('back', () { |
| 38 expect(() { | 37 expect(() { |
| 39 window.history.pushState(null, document.title, '?dummy1'); | 38 window.history.pushState(null, document.title, '?dummy1'); |
| 40 window.history.pushState(null, document.title, '?dummy2'); | 39 window.history.pushState(null, document.title, '?dummy2'); |
| 41 var length = window.history.length; | 40 var length = window.history.length; |
| 42 | 41 |
| 43 expect(window.location.href.endsWith('dummy2'), isTrue); | 42 expect(window.location.href.endsWith('dummy2'), isTrue); |
| 44 | 43 |
| 45 // Need to wait a frame or two to let the pushState events occur. | 44 // Need to wait a frame or two to let the pushState events occur. |
| 46 new Timer(const Duration(milliseconds: 100), expectAsync0(() { | 45 window.setTimeout(expectAsync0(() { |
| 47 window.onPopState.first.then(expectAsync1((_){ | 46 window.onPopState.first.then(expectAsync1((_){ |
| 48 expect(window.history.length, length); | 47 expect(window.history.length, length); |
| 49 expect(window.location.href.endsWith('dummy1'), isTrue); | 48 expect(window.location.href.endsWith('dummy1'), isTrue); |
| 50 })); | 49 })); |
| 51 | 50 |
| 52 window.history.back(); | 51 window.history.back(); |
| 53 })); | 52 }), 100); |
| 54 }, expectation); | 53 }, expectation); |
| 55 }); | 54 }); |
| 56 | 55 |
| 57 test('replaceState', () { | 56 test('replaceState', () { |
| 58 expect(() { | 57 expect(() { |
| 59 var length = window.history.length; | 58 var length = window.history.length; |
| 60 | 59 |
| 61 window.history.replaceState(null, document.title, '?foo=baz'); | 60 window.history.replaceState(null, document.title, '?foo=baz'); |
| 62 expect(window.history.length, length); | 61 expect(window.history.length, length); |
| 63 expect(window.location.href.endsWith('foo=baz'), isTrue); | 62 expect(window.location.href.endsWith('foo=baz'), isTrue); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 75 var expectation = HashChangeEvent.supported ? returnsNormally : throws; | 74 var expectation = HashChangeEvent.supported ? returnsNormally : throws; |
| 76 expect(() { | 75 expect(() { |
| 77 var event = new HashChangeEvent('change', oldUrl:'old', newUrl: 'new'); | 76 var event = new HashChangeEvent('change', oldUrl:'old', newUrl: 'new'); |
| 78 expect(event is HashChangeEvent, true); | 77 expect(event is HashChangeEvent, true); |
| 79 expect(event.oldUrl, 'old'); | 78 expect(event.oldUrl, 'old'); |
| 80 expect(event.newUrl, 'new'); | 79 expect(event.newUrl, 'new'); |
| 81 }, expectation); | 80 }, expectation); |
| 82 }); | 81 }); |
| 83 }); | 82 }); |
| 84 } | 83 } |
| OLD | NEW |