OLD | NEW |
---|---|
1 import 'dart:html'; | 1 import 'dart:html'; |
2 | 2 |
3 import 'package:expect/minitest.dart'; | 3 import 'package:expect/minitest.dart'; |
4 | 4 |
5 main() { | 5 main() { |
6 var isWindowBase = predicate((x) => x is WindowBase, 'is a WindowBase'); | 6 var isWindowBase = predicate((x) => x is WindowBase, 'is a WindowBase'); |
7 var isWindow = predicate((x) => x is Window, 'is a Window'); | 7 var isWindow = predicate((x) => x is Window, 'is a Window'); |
8 var isLocationBase = predicate((x) => x is LocationBase, 'is a LocationBase'); | 8 var isLocationBase = predicate((x) => x is LocationBase, 'is a LocationBase'); |
9 var isLocation = predicate((x) => x is Location, 'is a Location'); | 9 var isLocation = predicate((x) => x is Location, 'is a Location'); |
10 var isHistoryBase = predicate((x) => x is HistoryBase, 'is a HistoryBase'); | 10 var isHistoryBase = predicate((x) => x is HistoryBase, 'is a HistoryBase'); |
11 var isHistory = predicate((x) => x is History, 'is a History'); | 11 var isHistory = predicate((x) => x is History, 'is a History'); |
12 | 12 |
13 final iframe = new IFrameElement(); | 13 final iframe = new IFrameElement(); |
14 document.body.append(iframe); | 14 document.body.append(iframe); |
15 | 15 |
16 test('window', () { | 16 test('window', () { |
17 expect(window, isWindow); | 17 expect(window, isWindow); |
18 expect(window.document, document); | 18 expect(window.document, document); |
19 }); | 19 }); |
20 | 20 |
21 test('iframe', () { | 21 test('iframe', () { |
22 final frameWindow = iframe.contentWindow; | 22 final frameWindow = iframe.contentWindow; |
23 expect(frameWindow, isWindowBase); | 23 expect(frameWindow, isWindowBase); |
24 //TODO(gram) The next test should be written as: | 24 //TODO(gram) The next test should be written as: |
25 // expect(frameWindow, isNot(isWindow)); | 25 // expect(frameWindow, isNot(isWindow)); |
26 // but that will cause problems now until is/is! work | 26 // but that will cause problems now until is/is! work |
27 // properly in dart2js instead of always returning true. | 27 // properly in dart2js instead of always returning true. |
28 expect(frameWindow is! Window, isTrue); | 28 expect(frameWindow is! Window, isTrue); |
29 expect(frameWindow.parent, isWindow); | 29 expect(frameWindow.parent, isWindow); |
30 | |
31 // Ensure that the frame's document is inaccessible via window. | |
32 expect(() => frameWindow.document, throws); | |
vsm
2017/07/14 15:35:27
Note - these are all static errors now.
| |
33 }); | |
34 | |
35 test('contentDocument', () { | |
36 // Ensure that the frame's document is inaccessible. | |
37 expect(() => iframe.contentDocument, throws); | |
38 }); | 30 }); |
39 | 31 |
40 test('location', () { | 32 test('location', () { |
41 expect(window.location, isLocation); | 33 expect(window.location, isLocation); |
42 final frameLocation = iframe.contentWindow.location; | 34 final frameLocation = iframe.contentWindow.location; |
43 expect(frameLocation, isLocationBase); | 35 expect(frameLocation, isLocationBase); |
44 // TODO(gram) Similar to the above, the next test should be: | 36 // TODO(gram) Similar to the above, the next test should be: |
45 // expect(frameLocation, isNot(isLocation)); | 37 // expect(frameLocation, isNot(isLocation)); |
46 expect(frameLocation is! Location, isTrue); | 38 expect(frameLocation is! Location, isTrue); |
47 | 39 |
48 expect(() => frameLocation.href, throws); | |
49 expect(() => frameLocation.hash, throws); | |
50 | |
51 final frameParentLocation = iframe.contentWindow.parent.location; | 40 final frameParentLocation = iframe.contentWindow.parent.location; |
52 expect(frameParentLocation, isLocation); | 41 expect(frameParentLocation, isLocation); |
53 }); | 42 }); |
54 | 43 |
55 test('history', () { | 44 test('history', () { |
56 expect(window.history, isHistory); | 45 expect(window.history, isHistory); |
57 final frameHistory = iframe.contentWindow.history; | 46 final frameHistory = iframe.contentWindow.history; |
58 expect(frameHistory, isHistoryBase); | 47 expect(frameHistory, isHistoryBase); |
59 // See earlier comments. | 48 // See earlier comments. |
60 //expect(frameHistory, isNot(isHistory)); | 49 //expect(frameHistory, isNot(isHistory)); |
61 expect(frameHistory is! History, isTrue); | 50 expect(frameHistory is! History, isTrue); |
62 | 51 |
63 // Valid methods. | 52 // Valid methods. |
64 frameHistory.forward(); | 53 frameHistory.forward(); |
65 | 54 |
66 expect(() => frameHistory.length, throws); | |
67 | |
68 final frameParentHistory = iframe.contentWindow.parent.history; | 55 final frameParentHistory = iframe.contentWindow.parent.history; |
69 expect(frameParentHistory, isHistory); | 56 expect(frameParentHistory, isHistory); |
70 }); | 57 }); |
71 } | 58 } |
OLD | NEW |