OLD | NEW |
---|---|
1 #library('CrossFrameTest'); | 1 #library('CrossFrameTest'); |
2 #import('../../pkg/unittest/unittest.dart'); | 2 #import('../../pkg/unittest/unittest.dart'); |
3 #import('../../pkg/unittest/html_config.dart'); | 3 #import('../../pkg/unittest/html_config.dart'); |
4 #import('dart:html'); | 4 #import('dart:html'); |
5 | 5 |
6 main() { | 6 main() { |
7 useHtmlConfiguration(); | 7 useHtmlConfiguration(); |
8 | 8 |
9 var isWindow = new isInstanceOf<Window>('Window'); | |
Siggi Cherem (dart-lang)
2012/10/26 00:44:51
is this now fixed in dart2js? it used to only work
gram
2012/10/26 22:26:27
No - as you can see from my comments below about n
| |
10 var isLocalWindow = new isInstanceOf<LocalWindow>('LocalWindow'); | |
11 var isLocation = new isInstanceOf<Location>('Location'); | |
12 var isLocalLocation = new isInstanceOf<LocalLocation>('LocalLocation'); | |
13 var isHistory = new isInstanceOf<History>('History'); | |
14 var isLocalHistory = new isInstanceOf<LocalHistory>('LocalHistory'); | |
15 | |
9 final iframe = new Element.tag('iframe'); | 16 final iframe = new Element.tag('iframe'); |
10 document.body.nodes.add(iframe); | 17 document.body.nodes.add(iframe); |
11 | 18 |
12 test('window', () { | 19 test('window', () { |
13 expect(window is LocalWindow); | 20 expect(window, isLocalWindow); |
14 expect(window.document == document); | 21 expect(window.document, document); |
15 }); | 22 }); |
16 | 23 |
17 test('iframe', () { | 24 test('iframe', () { |
18 final frameWindow = iframe.contentWindow; | 25 final frameWindow = iframe.contentWindow; |
19 expect(frameWindow is Window); | 26 expect(frameWindow, isWindow); |
20 expect(frameWindow is! LocalWindow); | 27 //TODO(gram) The next test should be written as: |
21 expect(frameWindow.parent is LocalWindow); | 28 // expect(frameWindow, isNot(isLocalWindow)); |
29 // but that will cause problems now until is/is! work | |
30 // properly in dart2js instead of always returning true. | |
31 expect(frameWindow is! LocalWindow, isTrue); | |
32 expect(frameWindow.parent, isLocalWindow); | |
22 | 33 |
23 // Ensure that the frame's document is inaccessible via window. | 34 // Ensure that the frame's document is inaccessible via window. |
24 expect(() => frameWindow.document, throws); | 35 expect(() => frameWindow.document, throws); |
25 }); | 36 }); |
26 | 37 |
27 test('contentDocument', () { | 38 test('contentDocument', () { |
28 // Ensure that the frame's document is inaccessible. | 39 // Ensure that the frame's document is inaccessible. |
29 expect(() => iframe.contentDocument, throws); | 40 expect(() => iframe.contentDocument, throws); |
30 }); | 41 }); |
31 | 42 |
32 test('location', () { | 43 test('location', () { |
33 expect(window.location is LocalLocation); | 44 expect(window.location, isLocalLocation); |
34 final frameLocation = iframe.contentWindow.location; | 45 final frameLocation = iframe.contentWindow.location; |
35 expect(frameLocation is Location); | 46 expect(frameLocation, isLocation); |
36 expect(frameLocation is! LocalLocation); | 47 // TODO(gram) Similar to the above, the next test should be: |
48 // expect(frameLocation, isNot(isLocalLocation)); | |
49 expect(frameLocation is! LocalLocation, isTrue); | |
37 | 50 |
38 expect(() => frameLocation.href, throws); | 51 expect(() => frameLocation.href, throws); |
39 expect(() => frameLocation.hash, throws); | 52 expect(() => frameLocation.hash, throws); |
40 | 53 |
41 final frameParentLocation = iframe.contentWindow.parent.location; | 54 final frameParentLocation = iframe.contentWindow.parent.location; |
42 expect(frameParentLocation is LocalLocation); | 55 expect(frameParentLocation, isLocalLocation); |
43 }); | 56 }); |
44 | 57 |
45 test('history', () { | 58 test('history', () { |
46 expect(window.history is LocalHistory); | 59 expect(window.history, isLocalHistory); |
47 final frameHistory = iframe.contentWindow.history; | 60 final frameHistory = iframe.contentWindow.history; |
48 expect(frameHistory is History); | 61 expect(frameHistory, isHistory); |
49 expect(frameHistory is! LocalHistory); | 62 // See earlier comments. |
63 //expect(frameHistory, isNot(isLocalHistory)); | |
64 expect(frameHistory is! LocalHistory, isTrue); | |
50 | 65 |
51 // Valid methods. | 66 // Valid methods. |
52 frameHistory.forward(); | 67 frameHistory.forward(); |
53 | 68 |
54 expect(() => frameHistory.length, throws); | 69 expect(() => frameHistory.length, throws); |
55 | 70 |
56 final frameParentHistory = iframe.contentWindow.parent.history; | 71 final frameParentHistory = iframe.contentWindow.parent.history; |
57 expect(frameParentHistory is LocalHistory); | 72 expect(frameParentHistory, isLocalHistory); |
58 }); | 73 }); |
59 } | 74 } |
OLD | NEW |