| 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 exportKey() given bad inputs."); | 12 description("Tests exportKey() given bad inputs."); | 
| 13 | 13 | 
| 14 jsTestIsAsync = true; | 14 jsTestIsAsync = true; | 
| 15 | 15 | 
| 16 function importAesKey() | 16 function importAesKey() | 
| 17 { | 17 { | 
| 18     var keyData = new Uint8Array(16); | 18     var keyData = new Uint8Array(16); | 
| 19     var usages = ['encrypt']; | 19     var usages = ['encrypt']; | 
| 20     var extractable = true; | 20     var extractable = true; | 
| 21     var algorithm = {name: 'aes-cbc'}; | 21     var algorithm = {name: 'aes-cbc'}; | 
| 22 | 22 | 
| 23     return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage
    s); | 23     return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage
    s); | 
| 24 } | 24 } | 
| 25 | 25 | 
| 26 Promise.resolve(null).then(function(result) { | 26 Promise.resolve(null).then(function(result) { | 
| 27     // null is not a valid Key. | 27     // null is not a valid Key. | 
| 28     return crypto.subtle.exportKey('raw', null); | 28     return crypto.subtle.exportKey('raw', null); | 
| 29 }).then(failAndFinishJSTest, function(result) { | 29 }).then(failAndFinishJSTest, function(result) { | 
| 30     error = result; | 30     logError(result); | 
| 31     shouldBeNull("error"); |  | 
| 32 | 31 | 
| 33     // 3 is not a valid Key. | 32     // 3 is not a valid Key. | 
| 34     return crypto.subtle.exportKey('raw', 3); | 33     return crypto.subtle.exportKey('raw', 3); | 
| 35 }).then(failAndFinishJSTest, function(result) { | 34 }).then(failAndFinishJSTest, function(result) { | 
| 36     error = result; | 35     logError(result); | 
| 37     shouldBeNull("error"); |  | 
| 38 | 36 | 
| 39     return importAesKey(); | 37     return importAesKey(); | 
| 40 }).then(function(result) { | 38 }).then(function(result) { | 
| 41     key = result; | 39     key = result; | 
| 42 | 40 | 
| 43     // Invalid export format | 41     // Invalid export format | 
| 44     return crypto.subtle.exportKey(3, key); | 42     return crypto.subtle.exportKey(3, key); | 
| 45 }).then(failAndFinishJSTest, function(result) { | 43 }).then(failAndFinishJSTest, function(result) { | 
| 46     error = result; | 44     logError(result); | 
| 47     shouldBeNull("error"); |  | 
| 48 | 45 | 
| 49     // Invalid export format | 46     // Invalid export format | 
| 50     return crypto.subtle.exportKey(null, key); | 47     return crypto.subtle.exportKey(null, key); | 
| 51 }).then(failAndFinishJSTest, function(result) { | 48 }).then(failAndFinishJSTest, function(result) { | 
| 52     error = result; | 49     logError(result); | 
| 53     shouldBeNull("error"); |  | 
| 54 | 50 | 
| 55     // Invalid export format | 51     // Invalid export format | 
| 56     return crypto.subtle.exportKey('invalid', key); | 52     return crypto.subtle.exportKey('invalid', key); | 
| 57 }).then(failAndFinishJSTest, function(result) { | 53 }).then(failAndFinishJSTest, function(result) { | 
| 58     error = result; | 54     logError(result); | 
| 59     shouldBeNull("error"); |  | 
| 60 }).then(finishJSTest, failAndFinishJSTest); | 55 }).then(finishJSTest, failAndFinishJSTest); | 
| 61 | 56 | 
| 62 </script> | 57 </script> | 
| 63 | 58 | 
| 64 </body> | 59 </body> | 
| 65 </html> | 60 </html> | 
| OLD | NEW | 
|---|