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

Unified 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 8 years 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/history_test.dart
diff --git a/tests/html/history_test.dart b/tests/html/history_test.dart
index 62dbc9c4010af904daf462b985b8897382c0a4e0..bce3674de18efa816b06e7e2f959082e6080467a 100644
--- a/tests/html/history_test.dart
+++ b/tests/html/history_test.dart
@@ -1,18 +1,66 @@
library HistoryTest;
import '../../pkg/unittest/lib/unittest.dart';
-import '../../pkg/unittest/lib/html_config.dart';
+import '../../pkg/unittest/lib/html_individual_config.dart';
import 'dart:html';
+/// Waits for a callback once, then removes the event handler.
+void expectAsync1Once(EventListenerList list, void callback(arg)) {
+ var fn = null;
+ fn = expectAsync1((arg) {
+ list.remove(fn);
+ callback(arg);
+ });
+ list.add(fn);
+}
+
main() {
- useHtmlConfiguration();
- test('History', () {
- window.history.pushState(null, document.title, '?foo=bar');
- expect(window.history.length, equals(2));
- window.history.back();
- expect(window.location.href.endsWith('foo=bar'), isTrue);
-
- window.history.replaceState(null, document.title, '?foo=baz');
- expect(window.history.length, equals(2));
- expect(window.location.href.endsWith('foo=baz'), isTrue);
+ useHtmlIndividualConfiguration();
+
+ group('supported_state', () {
+ test('supportsState', () {
+ expect(History.supportsState, true);
+ });
+ });
+
+ var expectation = History.supportsState ? returnsNormally : throws;
+
+ group('history', () {
+ test('pushState', () {
+ expect(() {
+ window.history.pushState(null, document.title, '?dummy');
+ var length = window.history.length;
+
+ window.history.pushState(null, document.title, '?foo=bar');
+ expect(window.history.length, length + 1);
+ expect(window.location.href.endsWith('foo=bar'), isTrue);
+ }, expectation);
+ });
+
+ test('back', () {
+ expect(() {
+ window.history.pushState(null, document.title, '?dummy1');
+ window.history.pushState(null, document.title, '?dummy2');
+ var length = window.history.length;
+
+ expect(window.location.href.endsWith('dummy2'), isTrue);
+
+ expectAsync1Once(window.on.popState, (_) {
+ expect(window.history.length, length);
+ expect(window.location.href.endsWith('dummy1'), isTrue);
+ });
+
+ window.history.back();
+ }, expectation);
+ });
+
+ test('replaceState', () {
+ expect(() {
+ var length = window.history.length;
+
+ window.history.replaceState(null, document.title, '?foo=baz');
+ expect(window.history.length, length);
+ expect(window.location.href.endsWith('foo=baz'), isTrue);
+ }, expectation);
+ });
});
}
« 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