Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: tests/html/history_test.dart

Issue 12041053: Adding supported flag to HashChangeEvent. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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);
11 callback(arg); 11 callback(arg);
12 }); 12 });
13 list.add(fn); 13 list.add(fn);
14 } 14 }
15 15
16 main() { 16 main() {
17 useHtmlIndividualConfiguration(); 17 useHtmlIndividualConfiguration();
18 18
19 group('supported_state', () { 19 group('supported_state', () {
20 test('supportsState', () { 20 test('supportsState', () {
21 expect(History.supportsState, true); 21 expect(History.supportsState, true);
22 }); 22 });
23 }); 23 });
24 24
25 group('supported_HashChangeEvent', () {
26 test('supported', () {
27 expect(HashChangeEvent.supported, true);
28 });
29 });
30
25 var expectation = History.supportsState ? returnsNormally : throws; 31 var expectation = History.supportsState ? returnsNormally : throws;
26 32
27 group('history', () { 33 group('history', () {
28 test('pushState', () { 34 test('pushState', () {
29 expect(() { 35 expect(() {
30 window.history.pushState(null, document.title, '?dummy'); 36 window.history.pushState(null, document.title, '?dummy');
31 var length = window.history.length; 37 var length = window.history.length;
32 38
33 window.history.pushState(null, document.title, '?foo=bar'); 39 window.history.pushState(null, document.title, '?foo=bar');
34 40
(...skipping 26 matching lines...) Expand all
61 expect(() { 67 expect(() {
62 var length = window.history.length; 68 var length = window.history.length;
63 69
64 window.history.replaceState(null, document.title, '?foo=baz'); 70 window.history.replaceState(null, document.title, '?foo=baz');
65 expect(window.history.length, length); 71 expect(window.history.length, length);
66 expect(window.location.href.endsWith('foo=baz'), isTrue); 72 expect(window.location.href.endsWith('foo=baz'), isTrue);
67 }, expectation); 73 }, expectation);
68 }); 74 });
69 75
70 test('hashchangeevent', () { 76 test('hashchangeevent', () {
77 var expectation = HashChangeEvent.supported ? returnsNormally : throws;
71 expect(() { 78 expect(() {
72 var event = new HashChangeEvent('change', oldUrl:'old', newUrl: 'new'); 79 var event = new HashChangeEvent('change', oldUrl:'old', newUrl: 'new');
73 expect(event is HashChangeEvent, true); 80 expect(event is HashChangeEvent, true);
74 expect(event.oldUrl, 'old'); 81 expect(event.oldUrl, 'old');
75 expect(event.newUrl, 'new'); 82 expect(event.newUrl, 'new');
76 }, expectation); 83 }, expectation);
77 }); 84 });
78 }); 85 });
79 } 86 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698