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

Side by Side 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, 7 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
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 library HistoryTest;
2 import 'package:unittest/unittest.dart';
3 import 'package:unittest/html_individual_config.dart';
4 import 'dart:html';
5 import 'dart:async';
6
7 main() {
8 useHtmlIndividualConfiguration();
9
10 group('supported_state', () {
11 test('supportsState', () {
12 expect(History.supportsState, true);
13 });
14 });
15
16 group('supported_HashChangeEvent', () {
17 test('supported', () {
18 expect(HashChangeEvent.supported, true);
19 });
20 });
21
22 var expectation = History.supportsState ? returnsNormally : throws;
23
24 group('history', () {
25 test('pushState', () {
26 expect(() {
27 window.history.pushState(null, document.title, '?dummy');
28 var length = window.history.length;
29
30 window.history.pushState(null, document.title, '?foo=bar');
31
32 expect(window.location.href.endsWith('foo=bar'), isTrue);
33
34 }, expectation);
35 });
36
37 test('pushState with data', () {
38 expect(() {
39 window.history.pushState({'one' : 1}, document.title, '?dummy');
40 expect(window.history.state, equals({'one' : 1}));
41 window.history.pushState(null, document.title, '?foo=bar');
42
43 expect(window.location.href.endsWith('foo=bar'), isTrue);
44
45 }, expectation);
46 });
47
48 test('back', () {
49 expect(() {
50 window.history.pushState(null, document.title, '?dummy1');
51 window.history.pushState(null, document.title, '?dummy2');
52 var length = window.history.length;
53
54 expect(window.location.href.endsWith('dummy2'), isTrue);
55
56 // Need to wait a frame or two to let the pushState events occur.
57 new Timer(const Duration(milliseconds: 100), expectAsync(() {
58 window.onPopState.first.then(expectAsync((_){
59 expect(window.history.length, length);
60 expect(window.location.href.endsWith('dummy1'), isTrue);
61 }));
62
63 window.history.back();
64 }));
65 }, expectation);
66 });
67
68 test('replaceState', () {
69 expect(() {
70 var length = window.history.length;
71
72 window.history.replaceState(null, document.title, '?foo=baz');
73 expect(window.history.length, length);
74 expect(window.location.href.endsWith('foo=baz'), isTrue);
75 }, expectation);
76 });
77
78 test('popstatevent', () {
79 expect(() {
80 var event = new Event.eventType('PopStateEvent', 'popstate');
81 expect(event is PopStateEvent, true);
82 }, expectation);
83 });
84
85 test('hashchangeevent', () {
86 var expectation = HashChangeEvent.supported ? returnsNormally : throws;
87 expect(() {
88 var event = new HashChangeEvent('change', oldUrl:'old', newUrl: 'new');
89 expect(event is HashChangeEvent, true);
90 expect(event.oldUrl, 'old');
91 expect(event.newUrl, 'new');
92 }, expectation);
93 });
94 });
95 }
OLDNEW
« 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