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

Side by Side Diff: LayoutTests/crypto/aes-export-key.html

Issue 806913006: [WebCrypto] Move LayoutTests from crypto to crypto/subtle (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update path for deserialize legacy tests Created 6 years 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("Test exporting an AES key.");
13
14 jsTestIsAsync = true;
15
16 var extractable = true;
17 var nonExtractable = false;
18
19 var jwkKey = {
20 kty: "oct",
21 k: "jnOw99oOZFLIEPMrgJB55WL46tJSLGt7jnOw99oOZFI"
22 };
23
24 Promise.resolve(null).then(function(result) {
25 return crypto.subtle.exportKey("raw");
26 }).then(failAndFinishJSTest, function(result) {
27 logError(result);
28 return crypto.subtle.exportKey("raw", null)
29 }).then(failAndFinishJSTest, function(result) {
30 logError(result);
31 return crypto.subtle.exportKey("raw", undefined);
32 }).then(failAndFinishJSTest, function(result) {
33 logError(result);
34 return crypto.subtle.exportKey("raw", {});
35 }).then(failAndFinishJSTest, function(result) {
36 logError(result);
37 return crypto.subtle.exportKey("raw", 1);
38 }).then(failAndFinishJSTest, function(result) {
39 logError(result);
40 debug("\nImporting a JWK key...");
41
42 return crypto.subtle.importKey("jwk", jwkKey, {name: "AES-CBC"}, extractable , ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey']);
43 }).then(function(result) {
44 key = result;
45
46 return crypto.subtle.exportKey(null, key);
47 }).then(failAndFinishJSTest, function(result) {
48 logError(result);
49 return crypto.subtle.exportKey(undefined, key);
50 }).then(failAndFinishJSTest, function(result) {
51 logError(result);
52 return crypto.subtle.exportKey({}, key);
53 }).then(failAndFinishJSTest, function(result) {
54 logError(result);
55 return crypto.subtle.exportKey("", key);
56 }).then(failAndFinishJSTest, function(result) {
57 logError(result);
58 return crypto.subtle.exportKey("foobar", key);
59 }).then(failAndFinishJSTest, function(result) {
60 logError(result);
61
62 debug("\nExporting the key as raw data...");
63 return crypto.subtle.exportKey("raw", key);
64 }).then(function(result) {
65 exportedData = result;
66 shouldBe("bytesToHexString(new Uint8Array(exportedData))", "'8e73b0f7da0e645 2c810f32b809079e562f8ead2522c6b7b8e73b0f7da0e6452'");
67
68 debug("Exporting the key as JWK...");
69 return crypto.subtle.exportKey("jwk", key);
70 }).then(function(result) {
71 exportedJWK = result;
72 shouldBe("exportedJWK.kty", "'oct'");
73 shouldBe("exportedJWK.k", "'jnOw99oOZFLIEPMrgJB55WL46tJSLGt7jnOw99oOZFI'");
74 shouldBe("exportedJWK.alg", "'A256CBC'");
75 shouldBe("exportedJWK.ext", "true");
76 shouldBe("exportedJWK.use", "undefined");
77 shouldBe("exportedJWK.key_ops", "['encrypt', 'decrypt', 'wrapKey', 'unwrapKe y']");
78
79 debug("\nImporting a key that's not extractable...");
80 return crypto.subtle.importKey("jwk", jwkKey, {name: "AES-CBC"}, nonExtracta ble, ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'])
81 }).then(function(result) {
82 key = result;
83
84 debug("\nTrying to export as raw...");
85 return crypto.subtle.exportKey("raw", key);
86 }, failAndFinishJSTest).then(function(result) {
87 testFailed("Promise wasn't rejected");
88 finishJSTest();
89 }, function(result) {
90 testPassed("Rejected, as expected");
91 logError(result);
92
93 debug("Trying to export as jwk...");
94 return crypto.subtle.exportKey("jwk", key);
95 }).then(function(result) {
96 testFailed("Promise wasn't rejected");
97 finishJSTest();
98 }, function(result) {
99 testPassed("Rejected, as expected");
100 logError(result);
101
102 finishJSTest();
103 });
104 </script>
105
106 </body>
107 </html>
OLDNEW
« no previous file with comments | « LayoutTests/crypto/aes-ctr-parseAlgorithm-failures-expected.txt ('k') | LayoutTests/crypto/aes-export-key-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698