OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.js"></script> |
5 <script src="resources/common.js"></script> | 5 <script src="resources/common.js"></script> |
6 </head> | 6 </head> |
7 <body> | 7 <body> |
8 <p id="description"></p> | 8 <p id="description"></p> |
9 <div id="console"></div> | 9 <div id="console"></div> |
10 | 10 |
11 <script> | 11 <script> |
12 description("Tests incorrect calls to crypto.subtle.digest()"); | 12 description("Tests incorrect calls to crypto.subtle.digest()"); |
13 | 13 |
14 jsTestIsAsync = true; | 14 jsTestIsAsync = true; |
15 | 15 |
16 Promise.resolve(null).then(function(result) { | 16 Promise.resolve(null).then(function(result) { |
17 // Called with too few parameters. | 17 |
| 18 debug("\ndigest() without data argument..."); |
18 return crypto.subtle.digest({name: 'sha-1'}); | 19 return crypto.subtle.digest({name: 'sha-1'}); |
19 }).then(failAndFinishJSTest, function(result) { | 20 }).then(failAndFinishJSTest, function(result) { |
20 logError(result); | 21 logError(result); |
21 | 22 |
22 // "null" is not a valid data argument. | 23 debug("\ndigest() with data argument that is null..."); |
23 return crypto.subtle.digest({name: 'sha-1'}, null); | 24 return crypto.subtle.digest({name: 'sha-1'}, null); |
24 }).then(failAndFinishJSTest, function(result) { | 25 }).then(failAndFinishJSTest, function(result) { |
25 logError(result); | 26 logError(result); |
26 | 27 |
27 // 10 is not a valid data argument. | 28 debug("\ndigest() with data argument that is an integer..."); |
28 return crypto.subtle.digest({name: 'sha-1'}, 10); | 29 return crypto.subtle.digest({name: 'sha-1'}, 10); |
29 }).then(failAndFinishJSTest, function(result) { | 30 }).then(failAndFinishJSTest, function(result) { |
30 logError(result); | 31 logError(result); |
31 | 32 |
32 // null is not a valid algorithm argument. | |
33 data = new Uint8Array([0]); | 33 data = new Uint8Array([0]); |
| 34 debug("\ndigest() with algorithm as null..."); |
34 return crypto.subtle.digest(null, data); | 35 return crypto.subtle.digest(null, data); |
35 }).then(failAndFinishJSTest, function(result) { | 36 }).then(failAndFinishJSTest, function(result) { |
36 logError(result); | 37 logError(result); |
37 | 38 |
38 // "sha" is not a recognized algorithm name | 39 debug("\ndigest() with invalid agorithm that is sha..."); |
39 return crypto.subtle.digest({name: 'sha'}, data); | 40 return crypto.subtle.digest({name: 'sha'}, data); |
40 }).then(failAndFinishJSTest, function(result) { | 41 }).then(failAndFinishJSTest, function(result) { |
41 logError(result); | 42 logError(result); |
42 | 43 |
43 // Algorithm lacks a name. | 44 debug("\ndigest() without algorithm name..."); |
44 return crypto.subtle.digest({}, data); | 45 return crypto.subtle.digest({}, data); |
45 }).then(failAndFinishJSTest, function(result) { | 46 }).then(failAndFinishJSTest, function(result) { |
46 logError(result); | 47 logError(result); |
47 | 48 |
48 }).then(finishJSTest, failAndFinishJSTest); | 49 }).then(finishJSTest, failAndFinishJSTest); |
49 | 50 |
50 </script> | 51 </script> |
51 | 52 |
52 </body> | 53 </body> |
53 </html> | 54 </html> |
OLD | NEW |