<!DOCTYPE html>
<html>
<head>
<script src="resources/link-load-utilities.js"></script>
<script>
var numberOfFiredLoadEvents = 0;
var expectedNumberOfFiredLoadEvents = 2;

function checkIfDone(elementName)
{
  ++numberOfFiredLoadEvents;

  if (numberOfFiredLoadEvents < expectedNumberOfFiredLoadEvents && elementName === 'body') {
    log("FAIL Fired window Load event before link Load events.");
    testFinished();
  }
  if (numberOfFiredLoadEvents === expectedNumberOfFiredLoadEvents) {
    log("PASS Fired " + numberOfFiredLoadEvents + " Load events.");
    testFinished();
  }
}
</script>
<link rel="stylesheet" href="resources/stylesheet.css" onload="checkIfDone('link1')">
<link rel="stylesheet" href="resources/stylesheet.css" onload="checkIfDone('link2')">
</head>
<body onload="checkIfDone('body')">
<p>This tests that we fire two Load events on a page with two HTML Link elements and that both events are fired before the Load event for the window is dispatched. This test PASSED if you see the word PASS below. Otherwise, it FAILED.
<pre id="console"></pre>
</body>
</html>
