Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Side by Side Diff: LayoutTests/crypto/subtle/clone-pbkdf2Key.html

Issue 958353003: [WebCrypto] Move cloneKey test to respective algorithm directory (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 structured cloning of PBKDF2 keys");
13
14 jsTestIsAsync = true;
15
16 // Tests the 27 permutations of keys generated by:
17 // kPossibleHashAlgorithms x kPossibleKeyUsages x kPossibleKeyData
18 //
19 // For practical reasons these tests are not exhaustive.
20
21 var k1ByteData = "30"
22 var k8ByteData = "0011223344554677";
23 var k11ByteData = "00112233445546778899aa";
24
25 var kPossibleHashAlgorithms = ['SHA-1', 'SHA-256', 'SHA-512'];
26 var kPossibleKeyUsages = [['deriveBits'], ['deriveKey'], ['deriveKey', 'deriveBi ts']];
27 var kPossibleKeyData = [
28 k1ByteData,
29 k8ByteData,
30 k11ByteData
31 ];
32
33 function runTest(hashName, keyUsages, keyData)
34 {
35 var importData = hexStringToUint8Array(keyData);
36 var importAlgorithm = { name: 'PBKDF2', hash: {name: hashName } };
37 var extractable = false;
38
39 var results = {};
40
41 return crypto.subtle.importKey('raw', importData, importAlgorithm, extractab le, keyUsages).then(function(importedKey) {
42 results.importedKey = importedKey;
43 importedKey.extraProperty = 'hi';
44 return cloneKey(importedKey);
45 }).then(function(result) {
46 results.clonedKey = result;
47 importedKey = results.importedKey;
48 clonedKey = results.clonedKey;
49
50 shouldEvaluateAs("importedKey.extraProperty", "hi");
51 shouldEvaluateAs("importedKey.type", "secret");
52 shouldEvaluateAs("importedKey.extractable", extractable);
53 shouldEvaluateAs("importedKey.algorithm.name", "PBKDF2");
54 shouldEvaluateAs("importedKey.usages.join(',')", keyUsages.join(","));
55
56 shouldNotBe("importedKey", "clonedKey");
57
58 shouldBeUndefined("clonedKey.extraProperty");
59 shouldEvaluateAs("clonedKey.type", "secret");
60 shouldEvaluateAs("clonedKey.extractable", extractable);
61 shouldEvaluateAs("clonedKey.algorithm.name", "PBKDF2");
62 shouldEvaluateAs("clonedKey.usages.join(',')", keyUsages.join(","));
63
64 logSerializedKey(importedKey);
65
66 debug("");
67 });
68 }
69
70 var lastPromise = Promise.resolve(null);
71
72 kPossibleHashAlgorithms.forEach(function(hashName) {
73 kPossibleKeyUsages.forEach(function(keyUsages) {
74 kPossibleKeyData.forEach(function(keyData) {
75 lastPromise = lastPromise.then(runTest.bind(null, hashName, keyUsage s, keyData));
76 });
77 });
78 });
79
80 lastPromise.then(finishJSTest, failAndFinishJSTest);
81
82 </script>
83
84 </body>
85 </html>
OLDNEW
« no previous file with comments | « LayoutTests/crypto/subtle/clone-hmacKey-expected.txt ('k') | LayoutTests/crypto/subtle/clone-pbkdf2Key-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698