| 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 calling cypto.subtle.importKey with bad parameters"); |  | 
|  13  |  | 
|  14 jsTestIsAsync = true; |  | 
|  15  |  | 
|  16 var aesCbc = {name: 'aes-cbc'}; |  | 
|  17 var aesKeyBytes = new Uint8Array(16); |  | 
|  18 var extractable = true; |  | 
|  19  |  | 
|  20 // Undefined key usage. |  | 
|  21 // FIXME: http://crbug.com/262383 |  | 
|  22 //shouldThrow("crypto.subtle.importKey('raw', aesKeyBytes, aesCbc, extractable, 
    undefined)"); |  | 
|  23  |  | 
|  24 Promise.resolve(null).then(function() { |  | 
|  25     // Invalid data |  | 
|  26     return crypto.subtle.importKey('raw', [], aesCbc, extractable, ['encrypt']); |  | 
|  27 }).then(failAndFinishJSTest, function(result) { |  | 
|  28     logError(result); |  | 
|  29  |  | 
|  30     // 'null' treated as a Dictionary with default values - an empty dictionary |  | 
|  31     return crypto.subtle.importKey('raw', null, aesCbc, extractable, ['encrypt']
    ); |  | 
|  32 }).then(failAndFinishJSTest, function(result) { |  | 
|  33     logError(result); |  | 
|  34  |  | 
|  35     // Invalid algorithm |  | 
|  36     return crypto.subtle.importKey('raw', aesKeyBytes, null, extractable, ['encr
    ypt']); |  | 
|  37 }).then(failAndFinishJSTest, function(result) { |  | 
|  38     logError(result); |  | 
|  39  |  | 
|  40     // Invalid format. |  | 
|  41     return crypto.subtle.importKey('invalid format', aesKeyBytes, aesCbc, extrac
    table, ['encrypt']); |  | 
|  42 }).then(failAndFinishJSTest, function(result) { |  | 
|  43     logError(result); |  | 
|  44  |  | 
|  45     // Invalid key usage (case sensitive). |  | 
|  46     return crypto.subtle.importKey('raw', aesKeyBytes, aesCbc, extractable, ['EN
    CRYPT']); |  | 
|  47 }).then(failAndFinishJSTest, function(result) { |  | 
|  48     logError(result); |  | 
|  49  |  | 
|  50     // If both the format and key usage are bogus, should complain about the |  | 
|  51     // format first. |  | 
|  52     return crypto.subtle.importKey('invalid format', aesKeyBytes, aesCbc, extrac
    table, ['ENCRYPT']); |  | 
|  53 }).then(failAndFinishJSTest, function(result) { |  | 
|  54     logError(result); |  | 
|  55  |  | 
|  56     // Missing hash parameter for HMAC. |  | 
|  57     return crypto.subtle.importKey('raw', new Uint8Array(20), {name: 'hmac'}, ex
    tractable, ['sign']); |  | 
|  58 }).then(failAndFinishJSTest, function(result) { |  | 
|  59     logError(result); |  | 
|  60  |  | 
|  61     // SHA-1 doesn't support the importKey operation. |  | 
|  62     return crypto.subtle.importKey('raw', new Uint8Array(20), {name: 'sha-1'}, e
    xtractable, ['sign']); |  | 
|  63 }).then(failAndFinishJSTest, function(result) { |  | 
|  64     logError(result); |  | 
|  65 }).then(finishJSTest, failAndFinishJSTest); |  | 
|  66  |  | 
|  67 </script> |  | 
|  68  |  | 
|  69 </body> |  | 
|  70 </html> |  | 
| OLD | NEW |