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

Unified Diff: test/codegen/lib/html/history_test.dart

Issue 1930043002: Add all dart:html tests from the sdk to test/codegen. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: ptal Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/codegen/lib/html/hidden_dom_2_test.dart ('k') | test/codegen/lib/html/html.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/lib/html/history_test.dart
diff --git a/test/codegen/lib/html/history_test.dart b/test/codegen/lib/html/history_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d801a72a76f6b64743a81f92014e95768aef9d32
--- /dev/null
+++ b/test/codegen/lib/html/history_test.dart
@@ -0,0 +1,95 @@
+library HistoryTest;
+import 'package:unittest/unittest.dart';
+import 'package:unittest/html_individual_config.dart';
+import 'dart:html';
+import 'dart:async';
+
+main() {
+ useHtmlIndividualConfiguration();
+
+ group('supported_state', () {
+ test('supportsState', () {
+ expect(History.supportsState, true);
+ });
+ });
+
+ group('supported_HashChangeEvent', () {
+ test('supported', () {
+ expect(HashChangeEvent.supported, 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.location.href.endsWith('foo=bar'), isTrue);
+
+ }, expectation);
+ });
+
+ test('pushState with data', () {
+ expect(() {
+ window.history.pushState({'one' : 1}, document.title, '?dummy');
+ expect(window.history.state, equals({'one' : 1}));
+ window.history.pushState(null, document.title, '?foo=bar');
+
+ 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);
+
+ // Need to wait a frame or two to let the pushState events occur.
+ new Timer(const Duration(milliseconds: 100), expectAsync(() {
+ window.onPopState.first.then(expectAsync((_){
+ 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);
+ });
+
+ test('popstatevent', () {
+ expect(() {
+ var event = new Event.eventType('PopStateEvent', 'popstate');
+ expect(event is PopStateEvent, true);
+ }, expectation);
+ });
+
+ test('hashchangeevent', () {
+ var expectation = HashChangeEvent.supported ? returnsNormally : throws;
+ expect(() {
+ var event = new HashChangeEvent('change', oldUrl:'old', newUrl: 'new');
+ expect(event is HashChangeEvent, true);
+ expect(event.oldUrl, 'old');
+ expect(event.newUrl, 'new');
+ }, expectation);
+ });
+ });
+}
« no previous file with comments | « test/codegen/lib/html/hidden_dom_2_test.dart ('k') | test/codegen/lib/html/html.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698