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

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

Issue 11817025: Attempting to remove flakiness from history test (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
« no previous file with comments | « no previous file | 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_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
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 }
OLDNEW
« no previous file with comments | « no previous file | tests/html/html.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698