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 calling cypto.subtle.importKey with bad parameters"); | 12 description("Tests calling cypto.subtle.importKey with bad parameters"); |
13 | 13 |
14 jsTestIsAsync = true; | 14 jsTestIsAsync = true; |
15 | 15 |
16 var aesCbc = {name: 'aes-cbc'}; | 16 var aesCbc = {name: 'aes-cbc'}; |
17 var aesKeyBytes = new Uint8Array(16); | 17 var aesKeyBytes = new Uint8Array(16); |
18 var extractable = true; | 18 var extractable = true; |
19 | 19 |
20 // Undefined key usage. | 20 // Undefined key usage. |
21 // FIXME: http://crbug.com/262383 | 21 // FIXME: http://crbug.com/262383 |
22 //shouldThrow("crypto.subtle.importKey('raw', aesKeyBytes, aesCbc, extractable,
undefined)"); | 22 //shouldThrow("crypto.subtle.importKey('raw', aesKeyBytes, aesCbc, extractable,
undefined)"); |
23 | 23 |
24 // Invalid data | 24 Promise.resolve(null).then(function() { |
25 shouldThrow("crypto.subtle.importKey('raw', [], aesCbc, extractable, ['encrypt']
)"); | 25 // Invalid data |
26 shouldThrow("crypto.subtle.importKey('raw', null, aesCbc, extractable, ['encrypt
'])"); | 26 return crypto.subtle.importKey('raw', [], aesCbc, extractable, ['encrypt']); |
| 27 }).then(failAndFinishJSTest, function(result) { |
| 28 error = result; |
| 29 shouldBeNull("error"); |
27 | 30 |
28 // Invalid algorithm | 31 // Invalid data |
29 shouldThrow("crypto.subtle.importKey('raw', aesCbc, null, extractable, ['encrypt
'])"); | 32 return crypto.subtle.importKey('raw', null, aesCbc, extractable, ['encrypt']
); |
| 33 }).then(failAndFinishJSTest, function(result) { |
| 34 error = result; |
| 35 shouldBeNull("error"); |
30 | 36 |
31 Promise.resolve(null).then(function() { | 37 // Invalid algorithm |
| 38 return crypto.subtle.importKey('raw', aesKeyBytes, null, extractable, ['encr
ypt']); |
| 39 }).then(failAndFinishJSTest, function(result) { |
| 40 error = result; |
| 41 shouldBeNull("error"); |
| 42 |
32 // Invalid format. | 43 // Invalid format. |
33 return crypto.subtle.importKey('invalid format', aesKeyBytes, aesCbc, extrac
table, ['encrypt']); | 44 return crypto.subtle.importKey('invalid format', aesKeyBytes, aesCbc, extrac
table, ['encrypt']); |
34 }).then(failAndFinishJSTest, function(result) { | 45 }).then(failAndFinishJSTest, function(result) { |
35 error = result; | 46 error = result; |
36 shouldBeNull("error"); | 47 shouldBeNull("error"); |
37 | 48 |
38 // Invalid key usage (case sensitive). | 49 // Invalid key usage (case sensitive). |
39 return crypto.subtle.importKey('raw', aesKeyBytes, aesCbc, extractable, ['EN
CRYPT']); | 50 return crypto.subtle.importKey('raw', aesKeyBytes, aesCbc, extractable, ['EN
CRYPT']); |
40 }).then(failAndFinishJSTest, function(result) { | 51 }).then(failAndFinishJSTest, function(result) { |
41 error = result; | 52 error = result; |
(...skipping 16 matching lines...) Expand all Loading... |
58 return crypto.subtle.importKey('raw', new Uint8Array(20), {name: 'sha-1'}, e
xtractable, ['sign']); | 69 return crypto.subtle.importKey('raw', new Uint8Array(20), {name: 'sha-1'}, e
xtractable, ['sign']); |
59 }).then(failAndFinishJSTest, function(result) { | 70 }).then(failAndFinishJSTest, function(result) { |
60 error = result; | 71 error = result; |
61 shouldBeNull("error"); | 72 shouldBeNull("error"); |
62 }).then(finishJSTest, failAndFinishJSTest); | 73 }).then(finishJSTest, failAndFinishJSTest); |
63 | 74 |
64 </script> | 75 </script> |
65 | 76 |
66 </body> | 77 </body> |
67 </html> | 78 </html> |
OLD | NEW |