blob: 3d313604fbf77a02224bf852a57e4bffa8b1c3df [file] [edit]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script src="resources/common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Test crypto.subtle.digest.");
jsTestIsAsync = true;
Promise.resolve(null).then(function() {
debug("SHA1 of []");
return crypto.subtle.digest('sha-1', new Uint8Array([]));
}).then(function(result) {
digest = result;
shouldBe("bytesToHexString(new Uint8Array(digest))", "'da39a3ee5e6b4b0d3255bfef95601890afd80709'");
debug("SHA1 of [0x0]")
return crypto.subtle.digest({name: 'sha-1'}, new Uint8Array([0]));
}).then(function(result) {
digest = result;
shouldBe("bytesToHexString(new Uint8Array(digest))", "'5ba93c9db0cff93f52b521d7420e43f6eda2784f'");
debug("SHA1 of [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]");
var data = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
return crypto.subtle.digest({name: 'sha-1'}, data);
}).then(function(result) {
digest = result;
shouldBe("bytesToHexString(new Uint8Array(digest))", "'2c7e7c384f7829694282b1e3a6216def8082d055'");
// All SHA-1 can do is digest.
shouldThrow("crypto.subtle.generateKey('sha-1')");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>