4 <script src="../resources/js-test.js"></script>
5 <script src="resources/common.js"></script>
8 <p id="description"></p>
9 <div id="console"></div>
12 description("Tests incorrect calls to crypto.subtle.digest()");
16 Promise.resolve(null).then(function(result) {
17 // Called with too few parameters.
18 return crypto.subtle.digest({name: 'sha-1'});
19 }).then(failAndFinishJSTest, function(result) {
22 // "null" is not a valid data argument.
23 return crypto.subtle.digest({name: 'sha-1'}, null);
24 }).then(failAndFinishJSTest, function(result) {
27 // 10 is not a valid data argument.
28 return crypto.subtle.digest({name: 'sha-1'}, 10);
29 }).then(failAndFinishJSTest, function(result) {
32 // null is not a valid algorithm argument.
33 data = new Uint8Array([0]);
34 return crypto.subtle.digest(null, data);
35 }).then(failAndFinishJSTest, function(result) {
38 // "sha" is not a recognized algorithm name
39 return crypto.subtle.digest({name: 'sha'}, data);
40 }).then(failAndFinishJSTest, function(result) {
43 // Algorithm lacks a name.
44 return crypto.subtle.digest({}, data);
45 }).then(failAndFinishJSTest, function(result) {
48 }).then(finishJSTest, failAndFinishJSTest);