<script src="../../resources/ui-helper.js"></script>
<script>

if (window.testRunner) {
	testRunner.dumpAsText();
	testRunner.waitUntilDone();
}

function navigateFrame()
{
	window.location.href = 'resources/notify-done.html';
}

window.onload = function()
{
	// Simulate a user interaction with the page so that the beforeunload alert shows.
	const testButton = document.getElementById("testButton");
	UIHelper.activateAt(testButton.offsetLeft + 5, testButton.offsetTop + 5);
}

window.onbeforeunload = function()
{
	return "This is beforeunload from the top level frame.";
}

</script>
<body>
This page has multiple iframes, each trying to bring up a beforeunload dialog.<br>
This page also has a beforeunload dialog, itself.<br>
Only the dialog from this top-level frame should display, and none of the iframe ones should display.<br>
<input id="testButton" type="button" value="Click to navigate" onclick="navigateFrame()"><br>
<iframe src="resources/iframe-with-beforeunload.html"></iframe><br>
<iframe src="resources/iframe-with-beforeunload.html"></iframe><br>
</body>
