OLD | NEW |
1 library WindowOpenTest; | 1 library WindowOpenTest; |
2 import '../../pkg/unittest/lib/unittest.dart'; | 2 import '../../pkg/unittest/lib/unittest.dart'; |
3 import '../../pkg/unittest/lib/html_config.dart'; | 3 import '../../pkg/unittest/lib/html_config.dart'; |
4 import 'dart:html'; | 4 import 'dart:html'; |
5 import 'dart:async'; | |
6 | 5 |
7 main() { | 6 main() { |
8 useHtmlConfiguration(); | 7 useHtmlConfiguration(); |
9 evaluateJavaScript(code) { | 8 evaluateJavaScript(code) { |
10 final scriptTag = new Element.tag('script'); | 9 final scriptTag = new Element.tag('script'); |
11 scriptTag.innerHtml = code; | 10 scriptTag.innerHtml = code; |
12 document.body.nodes.add(scriptTag); | 11 document.body.nodes.add(scriptTag); |
13 } | 12 } |
14 evaluateJavaScript('(testRunner || layoutTestController).setCanOpenWindows()')
; | 13 evaluateJavaScript('(testRunner || layoutTestController).setCanOpenWindows()')
; |
15 | 14 |
16 test('TwoArgumentVersion', () { | 15 test('TwoArgumentVersion', () { |
17 Window win = window.open('../resources/pong.html', 'testWindow'); | 16 Window win = window.open('../resources/pong.html', 'testWindow'); |
18 closeWindow(win); | 17 closeWindow(win); |
19 }); | 18 }); |
20 test('ThreeArgumentVersion', () { | 19 test('ThreeArgumentVersion', () { |
21 Window win = window.open("resources/pong.html", "testWindow", "scrollbars=ye
s,width=75,height=100"); | 20 Window win = window.open("resources/pong.html", "testWindow", "scrollbars=ye
s,width=75,height=100"); |
22 closeWindow(win); | 21 closeWindow(win); |
23 }); | 22 }); |
24 } | 23 } |
25 | 24 |
26 closeWindow(win) { | 25 closeWindow(win) { |
27 win.close(); | 26 win.close(); |
28 doneHandler() { | 27 doneHandler() { |
29 if (!win.closed) { | 28 if (!win.closed) { |
30 new Timer(const Duration(milliseconds: 1), expectAsync0(doneHandler)); | 29 window.setTimeout(expectAsync0(doneHandler), 1); |
31 } | 30 } |
32 } | 31 } |
33 new Timer(const Duration(milliseconds: 1), expectAsync0(doneHandler)); | 32 window.setTimeout(expectAsync0(doneHandler), 1); |
34 } | 33 } |
OLD | NEW |