diff options
Diffstat (limited to 'test/fixtures/wpt/WebCryptoAPI/import_export/symmetric_importKey.https.any.js')
-rw-r--r-- | test/fixtures/wpt/WebCryptoAPI/import_export/symmetric_importKey.https.any.js | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/test/fixtures/wpt/WebCryptoAPI/import_export/symmetric_importKey.https.any.js b/test/fixtures/wpt/WebCryptoAPI/import_export/symmetric_importKey.https.any.js index 404b66ac00..a9ce9be0a1 100644 --- a/test/fixtures/wpt/WebCryptoAPI/import_export/symmetric_importKey.https.any.js +++ b/test/fixtures/wpt/WebCryptoAPI/import_export/symmetric_importKey.https.any.js @@ -41,17 +41,18 @@ } rawKeyData.forEach(function(keyData) { - // Generate all combinations of valid usages for testing - allValidUsages(vector.legalUsages, []).forEach(function(usages) { - // Try each legal value of the extractable parameter - vector.extractable.forEach(function(extractable) { - vector.formats.forEach(function(format) { - var data = keyData; - if (format === "jwk") { - data = jwkData(keyData, algorithm); - } + // Try each legal value of the extractable parameter + vector.extractable.forEach(function(extractable) { + vector.formats.forEach(function(format) { + var data = keyData; + if (format === "jwk") { + data = jwkData(keyData, algorithm); + } + // Generate all combinations of valid usages for testing + allValidUsages(vector.legalUsages, []).forEach(function(usages) { testFormat(format, algorithm, data, keyData.length * 8, usages, extractable); }); + testEmptyUsages(format, algorithm, data, keyData.length * 8, extractable); }); }); @@ -90,6 +91,20 @@ }, "Good parameters: " + keySize.toString() + " bits " + parameterString(format, keyData, 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, 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: |