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