diff options
Diffstat (limited to 'test/fixtures/wpt/WebCryptoAPI/import_export/rsa_importKey.https.any.js')
-rw-r--r-- | test/fixtures/wpt/WebCryptoAPI/import_export/rsa_importKey.https.any.js | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/test/fixtures/wpt/WebCryptoAPI/import_export/rsa_importKey.https.any.js b/test/fixtures/wpt/WebCryptoAPI/import_export/rsa_importKey.https.any.js index 41d25da89c..5582b2f506 100644 --- a/test/fixtures/wpt/WebCryptoAPI/import_export/rsa_importKey.https.any.js +++ b/test/fixtures/wpt/WebCryptoAPI/import_export/rsa_importKey.https.any.js @@ -92,13 +92,13 @@ }); // Next, test private keys - allValidUsages(vector.privateUsages, []).forEach(function(usages) { - ['pkcs8', 'jwk'].forEach(function(format) { - var algorithm = {name: vector.name, hash: hash}; - var data = keyData[size]; - + ['pkcs8', 'jwk'].forEach(function(format) { + var algorithm = {name: vector.name, hash: hash}; + var data = keyData[size]; + allValidUsages(vector.privateUsages, []).forEach(function(usages) { testFormat(format, algorithm, data, size, usages, extractable); }); + testEmptyUsages(format, algorithm, data, size, extractable); }); }); }); @@ -135,6 +135,20 @@ }, "Good parameters: " + keySize.toString() + " bits " + parameterString(format, keyData[format], algorithm, extractable, usages)); } + // Test importKey with a given key format and other parameters but with empty usages. + // Should fail with SyntaxError + function testEmptyUsages(format, algorithm, keyData, keySize, extractable) { + const usages = []; + promise_test(function(test) { + return subtle.importKey(format, keyData[format], algorithm, extractable, usages). + then(function(key) { + assert_unreached("importKey succeeded but should have failed with SyntaxError"); + }, function(err) { + assert_equals(err.name, "SyntaxError", "Should throw correct error, not " + err.name + ": " + err.message); + }); + }, "Empty Usages: " + keySize.toString() + " bits " + parameterString(format, keyData, algorithm, extractable, usages)); + } + // Helper methods follow: |