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

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

Issue 11697011: Fixing up history test to pass properly on supported platforms. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 12 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
« no previous file with comments | « sdk/lib/html/templates/html/impl/impl_History.darttemplate ('k') | tests/html/html.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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.
7 void expectAsync1Once(EventListenerList list, void callback(arg)) {
8 var fn = null;
9 fn = expectAsync1((arg) {
10 list.remove(fn);
11 callback(arg);
12 });
13 list.add(fn);
14 }
15
6 main() { 16 main() {
7 useHtmlConfiguration(); 17 useHtmlIndividualConfiguration();
8 test('History', () {
9 window.history.pushState(null, document.title, '?foo=bar');
10 expect(window.history.length, equals(2));
11 window.history.back();
12 expect(window.location.href.endsWith('foo=bar'), isTrue);
13 18
14 window.history.replaceState(null, document.title, '?foo=baz'); 19 group('supported_state', () {
15 expect(window.history.length, equals(2)); 20 test('supportsState', () {
16 expect(window.location.href.endsWith('foo=baz'), isTrue); 21 expect(History.supportsState, true);
22 });
23 });
24
25 var expectation = History.supportsState ? returnsNormally : throws;
26
27 group('history', () {
28 test('pushState', () {
29 expect(() {
30 window.history.pushState(null, document.title, '?dummy');
31 var length = window.history.length;
32
33 window.history.pushState(null, document.title, '?foo=bar');
34 expect(window.history.length, length + 1);
35 expect(window.location.href.endsWith('foo=bar'), isTrue);
36 }, expectation);
37 });
38
39 test('back', () {
40 expect(() {
41 window.history.pushState(null, document.title, '?dummy1');
42 window.history.pushState(null, document.title, '?dummy2');
43 var length = window.history.length;
44
45 expect(window.location.href.endsWith('dummy2'), isTrue);
46
47 expectAsync1Once(window.on.popState, (_) {
48 expect(window.history.length, length);
49 expect(window.location.href.endsWith('dummy1'), isTrue);
50 });
51
52 window.history.back();
53 }, expectation);
54 });
55
56 test('replaceState', () {
57 expect(() {
58 var length = window.history.length;
59
60 window.history.replaceState(null, document.title, '?foo=baz');
61 expect(window.history.length, length);
62 expect(window.location.href.endsWith('foo=baz'), isTrue);
63 }, expectation);
64 });
17 }); 65 });
18 } 66 }
OLDNEW
« no previous file with comments | « sdk/lib/html/templates/html/impl/impl_History.darttemplate ('k') | tests/html/html.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698