blob: 0919833500a7da356befa91d08f60e193f45e334 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../resources/inspector-test.js"></script>
<script>
let requestCount = 0;
function createSecureRequest() {
let img = document.createElement("img");
img.src = "https://localhost:8443/resources/square100.png?" + (++requestCount);
document.body.appendChild(img);
}
function test()
{
let suite = InspectorTest.createAsyncSuite("Resource.Security.Certificate");
suite.addTestCase({
name: "Resource.Security.Certificate.Basic",
description: "Check if a resource has security certificate information.",
test(resolve, reject) {
WI.Resource.awaitEvent(WI.Resource.Event.ResponseReceived)
.then((event) => {
let resource = event.target;
InspectorTest.expectThat(resource.loadedSecurely, "Resource should have been loaded securely.");
let security = resource.security;
InspectorTest.expectNotNull(security, "Resource should have security information.");
let certificate = security.certificate;
InspectorTest.expectNotNull(certificate, "Security information should include certificate information.");
InspectorTest.expectGreaterThan(certificate.subject.length, 0, "Certificate should have subject.");
InspectorTest.expectGreaterThan(certificate.validFrom, 0, "Certificate should have a validFrom date.");
InspectorTest.expectGreaterThan(certificate.validUntil, 0, "Certificate should have a validUntil date.");
})
.then(resolve, reject);
InspectorTest.evaluateInPage(`createSecureRequest()`)
.catch(reject);
}
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Tests for resource security certificate information.</p>
</body>
</html>