chromium/third_party/blink/manual_tests/onbeforeunload-close_with_javascript.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<script language="JavaScript">
function openWindow() {
    window.open("./onbeforeunload-close_with_javascript.html","name","width=700px,height=500px");
}
</script>
</head>
<BODY onbeforeunload="return 'onBeforeUnloadHandler return string is displayed here.';">
<p><b>BUG ID:</b> <a href="rdar://problem/4394910">4394910</a> calling Javascript window.close() does not trigger onbeforeunload event</p>

<p id="test" style="background-color:skyblue; padding:3px;"><b>STEPS TO TEST:</b> 
	<ol>
	<li>Click the "Open" button below.  
	<li>In the window that opens, click the "Close" button.
	</ol>
</p>

<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b> 
After the close button is clicked, you should see a dialog that reads:</p>
<pre>Are you sure you want to navigate away from this page?

onBeforeUnloadHandler return string is displayed here.

Press OK to continue or Cancel to stay on the current page.</pre>
<p id="success" style="background-color:palegreen; padding:3px;">You should see the same dialog if you click the "Close" button in the main window.
</p>

<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b>  
No dialog (as described above) after clicking the "Close" button in the newly opened window, or in the main window.
</p>

<BODY onbeforeunload="return 'onBeforeUnloadHandler return string is displayed here.';">
<input type=button value="Open Window" onclick="openWindow()"><br>
<input type=button value="Close Window" onclick="window.close();"><br>
<p>Click the Open Window button.  Once the new window is opened, close the new window by clicking the Close Window button (not the browser's close window icon).</p>
</body>
</html>