| 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 test('contentWindow', () { | 9 final iframe = new Element.tag('iframe'); |
| 10 final iframe = new Element.tag('iframe'); | 10 document.body.nodes.add(iframe); |
| 11 document.body.nodes.add(iframe); | 11 |
| 12 test('window', () { |
| 13 expect(window is LocalWindow); |
| 14 expect(window.document == document); |
| 15 }); |
| 16 |
| 17 test('iframe', () { |
| 12 final frameWindow = iframe.contentWindow; | 18 final frameWindow = iframe.contentWindow; |
| 19 expect(frameWindow is Window); |
| 20 expect(frameWindow is! LocalWindow); |
| 21 expect(frameWindow.parent is LocalWindow); |
| 13 | 22 |
| 14 // Ensure that the frame's document is inaccessible via window. | 23 // Ensure that the frame's document is inaccessible via window. |
| 15 expect(() => frameWindow.document, throws); | 24 expect(() => frameWindow.document, throws); |
| 16 }); | 25 }); |
| 17 | 26 |
| 18 test('contentDocument', () { | 27 test('contentDocument', () { |
| 19 final iframe = new Element.tag('iframe'); | |
| 20 document.body.nodes.add(iframe); | |
| 21 | |
| 22 // Ensure that the frame's document is inaccessible. | 28 // Ensure that the frame's document is inaccessible. |
| 23 expect(() => iframe.contentDocument, throws); | 29 expect(() => iframe.contentDocument, throws); |
| 24 }); | 30 }); |
| 31 |
| 32 test('location', () { |
| 33 expect(window.location is LocalLocation); |
| 34 final frameLocation = iframe.contentWindow.location; |
| 35 expect(frameLocation is Location); |
| 36 expect(frameLocation is! LocalLocation); |
| 37 |
| 38 expect(() => frameLocation.href, throws); |
| 39 expect(() => frameLocation.hash, throws); |
| 40 |
| 41 final frameParentLocation = iframe.contentWindow.parent.location; |
| 42 expect(frameParentLocation is LocalLocation); |
| 43 }); |
| 44 |
| 45 test('history', () { |
| 46 expect(window.history is LocalHistory); |
| 47 final frameHistory = iframe.contentWindow.history; |
| 48 expect(frameHistory is History); |
| 49 expect(frameHistory is! LocalHistory); |
| 50 |
| 51 // Valid methods. |
| 52 frameHistory.back(); |
| 53 frameHistory.forward(); |
| 54 |
| 55 expect(() => frameHistory.length, throws); |
| 56 |
| 57 final frameParentHistory = iframe.contentWindow.parent.history; |
| 58 expect(frameParentHistory is LocalHistory); |
| 59 }); |
| 25 } | 60 } |
| OLD | NEW |