OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <script src="../resources/js-test.js"></script> | |
5 <script src="resources/common.js"></script> | |
6 </head> | |
7 <body> | |
8 <p id="description"></p> | |
9 <div id="console"></div> | |
10 | |
11 <script> | |
12 description("Tests exportKey() given bad inputs."); | |
13 | |
14 jsTestIsAsync = true; | |
15 | |
16 function importAesKey() | |
17 { | |
18 var keyData = new Uint8Array(16); | |
19 var usages = ['encrypt']; | |
20 var extractable = true; | |
21 var algorithm = {name: 'aes-cbc'}; | |
22 | |
23 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage
s); | |
24 } | |
25 | |
26 Promise.resolve(null).then(function(result) { | |
27 // null is not a valid Key. | |
28 return crypto.subtle.exportKey('raw', null); | |
29 }).then(failAndFinishJSTest, function(result) { | |
30 logError(result); | |
31 | |
32 // 3 is not a valid Key. | |
33 return crypto.subtle.exportKey('raw', 3); | |
34 }).then(failAndFinishJSTest, function(result) { | |
35 logError(result); | |
36 | |
37 return importAesKey(); | |
38 }).then(function(result) { | |
39 key = result; | |
40 | |
41 // Invalid export format | |
42 return crypto.subtle.exportKey(3, key); | |
43 }).then(failAndFinishJSTest, function(result) { | |
44 logError(result); | |
45 | |
46 // Invalid export format | |
47 return crypto.subtle.exportKey(null, key); | |
48 }).then(failAndFinishJSTest, function(result) { | |
49 logError(result); | |
50 | |
51 // Invalid export format | |
52 return crypto.subtle.exportKey('invalid', key); | |
53 }).then(failAndFinishJSTest, function(result) { | |
54 logError(result); | |
55 }).then(finishJSTest, failAndFinishJSTest); | |
56 | |
57 </script> | |
58 | |
59 </body> | |
60 </html> | |
OLD | NEW |