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 exportKey() given bad inputs.");
16 function importAesKey()
18 var keyData
= new Uint8Array(16);
19 var usages
= ['encrypt'];
20 var extractable
= true;
21 var algorithm
= {name
: 'aes-cbc'};
23 return crypto
.subtle
.importKey('raw', keyData
, algorithm
, extractable
, usages
);
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
) {
32 // 3 is not a valid Key.
33 return crypto
.subtle
.exportKey('raw', 3);
34 }).then(failAndFinishJSTest
, function(result
) {
37 return importAesKey();
38 }).then(function(result
) {
41 // Invalid export format
42 return crypto
.subtle
.exportKey(3, key
);
43 }).then(failAndFinishJSTest
, function(result
) {
46 // Invalid export format
47 return crypto
.subtle
.exportKey(null, key
);
48 }).then(failAndFinishJSTest
, function(result
) {
51 // Invalid export format
52 return crypto
.subtle
.exportKey('invalid', key
);
53 }).then(failAndFinishJSTest
, function(result
) {
55 }).then(finishJSTest
, failAndFinishJSTest
);