| Index: LayoutTests/crypto/subtle/resources/symmetric-cloneKey.js
|
| diff --git a/LayoutTests/crypto/subtle/clone-aesKey.html b/LayoutTests/crypto/subtle/resources/symmetric-cloneKey.js
|
| similarity index 50%
|
| rename from LayoutTests/crypto/subtle/clone-aesKey.html
|
| rename to LayoutTests/crypto/subtle/resources/symmetric-cloneKey.js
|
| index e682369b3cb639b423a14a2cb5f4a508da63bc79..4899a28ffd68d07448899dffe3d398c20a031210 100644
|
| --- a/LayoutTests/crypto/subtle/clone-aesKey.html
|
| +++ b/LayoutTests/crypto/subtle/resources/symmetric-cloneKey.js
|
| @@ -1,35 +1,14 @@
|
| -<!DOCTYPE html>
|
| -<html>
|
| -<head>
|
| -<script src="../../resources/js-test.js"></script>
|
| -<script src="resources/common.js"></script>
|
| -</head>
|
| -<body>
|
| -<p id="description"></p>
|
| -<div id="console"></div>
|
| -
|
| -<script>
|
| -description("Tests structured cloning of AES keys");
|
| -
|
| -jsTestIsAsync = true;
|
| -
|
| -// Tests the 32 permutations of keys generated by:
|
| -// kPossibleAlgorithms x kPossibleExtractable x kPossibleKeyUsages x kPossibleKeyData
|
| -//
|
| -// For practical reasons these tests are not exhaustive.
|
| -
|
| -var k128BitData = "30112233445566778899aabbccddeeff"
|
| -var k256BitData = "00112233445546778899aabbccddeeff000102030405060708090a0b0c0d0e0f";
|
| -
|
| -var kPossibleAlgorithms = ['AES-CBC', 'AES-GCM'];
|
| -var kPossibleExtractable = [true, false];
|
| -var kPossibleKeyUsages = [['encrypt'], ['decrypt', 'wrapKey'], ['encrypt', 'wrapKey', 'unwrapKey']];
|
| -var kPossibleKeyData = [k128BitData, k256BitData];
|
| +if (self.importScripts) {
|
| + importScripts('common.js');
|
| +}
|
|
|
| -function runTest(algorithmName, extractable, keyUsages, keyData)
|
| +function runCloneSymmetricTests(algorithmName, extractable, keyUsages, keyData, hashName, keyHasLength)
|
| {
|
| var importData = hexStringToUint8Array(keyData);
|
| var importAlgorithm = { name: algorithmName };
|
| + if (hashName)
|
| + importAlgorithm.hash = { name: hashName };
|
| + var expectingHash = (algorithmName.toLowerCase() === "hmac");
|
|
|
| var results = {};
|
|
|
| @@ -50,7 +29,10 @@ function runTest(algorithmName, extractable, keyUsages, keyData)
|
| shouldEvaluateAs("importedKey.type", "secret");
|
| shouldEvaluateAs("importedKey.extractable", extractable);
|
| shouldEvaluateAs("importedKey.algorithm.name", algorithmName);
|
| - shouldEvaluateAs("importedKey.algorithm.length", importData.length * 8);
|
| + if (keyHasLength)
|
| + shouldEvaluateAs("importedKey.algorithm.length", importData.length * 8);
|
| + if (expectingHash)
|
| + shouldEvaluateAs("importedKey.algorithm.hash.name", hashName);
|
| shouldEvaluateAs("importedKey.usages.join(',')", keyUsages.join(","));
|
|
|
| shouldNotBe("importedKey", "clonedKey");
|
| @@ -59,7 +41,10 @@ function runTest(algorithmName, extractable, keyUsages, keyData)
|
| shouldEvaluateAs("clonedKey.type", "secret");
|
| shouldEvaluateAs("clonedKey.extractable", extractable);
|
| shouldEvaluateAs("clonedKey.algorithm.name", algorithmName);
|
| - shouldEvaluateAs("clonedKey.algorithm.length", importData.length * 8);
|
| + if (keyHasLength)
|
| + shouldEvaluateAs("clonedKey.algorithm.length", importData.length * 8);
|
| + if (expectingHash)
|
| + shouldEvaluateAs("clonedKey.algorithm.hash.name", hashName);
|
| shouldEvaluateAs("clonedKey.usages.join(',')", keyUsages.join(","));
|
|
|
| logSerializedKey(importedKey);
|
| @@ -71,21 +56,19 @@ function runTest(algorithmName, extractable, keyUsages, keyData)
|
| });
|
| }
|
|
|
| -var lastPromise = Promise.resolve(null);
|
| -
|
| -kPossibleAlgorithms.forEach(function(algorithmName) {
|
| - kPossibleExtractable.forEach(function(extractable) {
|
| - kPossibleKeyUsages.forEach(function(keyUsages) {
|
| - kPossibleKeyData.forEach(function(keyData) {
|
| - lastPromise = lastPromise.then(runTest.bind(null, algorithmName, extractable, keyUsages, keyData));
|
| +function testCloneSymmetricKeys(algorithmName, possibleHashAlgorithms, possibleExtractable, possibleKeyUsages, possibleKeyData, keyHasLength)
|
| +{
|
| + var lastPromise = Promise.resolve(null);
|
| +
|
| + possibleHashAlgorithms.forEach(function(hashName) {
|
| + possibleExtractable.forEach(function(extractable) {
|
| + possibleKeyUsages.forEach(function(keyUsages) {
|
| + possibleKeyData.forEach(function(keyData) {
|
| + lastPromise = lastPromise.then(runCloneSymmetricTests.bind(null, algorithmName, extractable, keyUsages, keyData, hashName, keyHasLength));
|
| + });
|
| });
|
| });
|
| });
|
| -});
|
| -
|
| -lastPromise.then(finishJSTest, failAndFinishJSTest);
|
|
|
| -</script>
|
| -
|
| -</body>
|
| -</html>
|
| + return lastPromise;
|
| +}
|
|
|