1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
5 if (window
.testRunner
) {
6 testRunner
.dumpAsText();
7 testRunner
.setCanOpenWindows();
8 testRunner
.waitUntilDone();
14 //This function should only be used with DRT and thus testRunner
15 function checkIfDone() {
16 var numOpenWindows
= testRunner
.windowCount();
18 if (numOpenWindows
== 1) {
19 var span
= document
.createElement("span");
20 span
.innerHTML
= 'TEST PASSED <br>';
21 document
.getElementById("console").appendChild(span
);
23 clearInterval(myInterval
);
24 testRunner
.notifyDone();
25 } else if (now
- start
> 10000) {
26 var span
= document
.createElement("span");
27 span
.innerHTML
= 'TEST FAILED <br> Number of open windows: ' + numOpenWindows
+ '<br/>';
29 document
.getElementById("console").appendChild(span
);
31 clearInterval(myInterval
);
32 testRunner
.notifyDone();
36 function openNewWindow() {
37 var event
= document
.createEvent('MouseEvent');
38 event
.initEvent( 'click', true, true );
39 document
.getElementById('anchorLink').dispatchEvent(event
);
41 if (window
.testRunner
) {
42 testRunner
.setCloseRemainingWindowsWhenComplete();
45 myInterval
= setInterval(checkIfDone
, 500);
52 <body onload=
"openNewWindow()">
53 This test checks that a window which has been opened by the DOM can also be closed
54 byt the DOM. The test will run automatically with popup blocking disabled.
55 To run the test manually click the link below.
59 <a href=
"resources/middle.html" id=
"anchorLink" target=
"_blank">Open new window that will close itself
</a>