blob: ebf3774689d12cdfe48b45807a2c244a8a7199d5 [file] [edit]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test counting of third-party script loads</title>
<script src="/js-test-resources/js-test.js"></script>
<script src="resources/util.js"></script>
</head>
<body onload="runTest()">
<script>
window.jsTestIsAsync = true;
const thirdPartyOrigin = "http://localhost:8000";
const thirdPartyBaseUrl = thirdPartyOrigin + "/resourceLoadStatistics/resources";
function finishTest() {
testRunner.dumpResourceLoadStatistics();
setEnableFeature(false, function() {
finishJSTest();
});
}
async function runTest() {
switch (document.location.hash) {
case "":
if (window.testRunner && window.internals) {
setEnableFeature(true, function() {
document.location.hash = "step1";
runTest();
});
}
break;
case "#step1":
document.location.hash = "step2";
let scriptElement = document.createElement("script");
scriptElement.onload = runTest;
scriptElement.src = thirdPartyBaseUrl + "/dummy.js?dummyParam=" + Math.random();
document.body.appendChild(scriptElement);
break;
case "#step2":
await testRunner.statisticsNotifyObserver();
finishTest()
break;
}
}
</script>
</body>
</html>