blob: b724bbe5bc208967634b50a6a69f84ef08448ed1 [file] [log] [blame]
<html>
<head>
<script>
function CallCommand(cmd)
{
try {
var req = new XMLHttpRequest;
req.open("GET", "/resources/network-simulator.php?test=misc-link-rel-prefetch-and-subresource&command=" + cmd, false);
req.send(null);
return req.responseText;
} catch (ex) {
return "";
}
}
function startTest()
{
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
}
function endTest()
{
getResourceLog();
CallCommand("clear-resource-request-log");
if (window.testRunner)
testRunner.notifyDone();
}
function getResourceLog()
{
var log = CallCommand("get-resource-request-log");
var logLines = log.split('\n');
logLines.sort();
document.getElementById('result').innerText = logLines.join('\n');
}
CallCommand("start-resource-request-log");
window.addEventListener('load', startTest, false);
</script>
<!-- link rel=subresource is very similar to link rel=prefetch, however it is
expected to have a higher network priority. This test should confirm that the
priorities of the two types of prefetch are being observed -->
<script>
var linkLoadCount = 5;
function decrementLinkLoadCount()
{
linkLoadCount--;
if (linkLoadCount == 0) {
endTest();
}
}
</script>
<link rel=prefetch onload="decrementLinkLoadCount()" href="/resources/network-simulator.php?test=misc-link-rel-prefetch-and-subresource&command=log-resource-request&path=1st.jpg">
<link rel=subresource onload="decrementLinkLoadCount()" href="/resources/network-simulator.php?test=misc-link-rel-prefetch-and-subresource&command=log-resource-request&path=2nd.jpg">
<link rel=prefetch onload="decrementLinkLoadCount()" href="/resources/network-simulator.php?test=misc-link-rel-prefetch-and-subresource&command=log-resource-request&path=3rd.jpg">
<link rel=prefetch onload="decrementLinkLoadCount()" href="/resources/network-simulator.php?test=misc-link-rel-prefetch-and-subresource&command=log-resource-request&path=4th.jpg">
<link rel=subresource onload="decrementLinkLoadCount()" href="/resources/network-simulator.php?test=misc-link-rel-prefetch-and-subresource&command=log-resource-request&path=5th.jpg">
</head>
<body>
<div class="box bordered"></div>
<h2>Resource requests:</h2>
<pre id="result">Request log goes here in DRT</pre>
</body>
</html>