Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / crypto / subtle / aes-export-key.html
blob7143a70def97b676df02c30568f6f1748444f4b1
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>
11 <script>
12 description("Test exporting an AES key.");
14 jsTestIsAsync = true;
16 var extractable = true;
17 var nonExtractable = false;
19 var jwkKey = {
20 kty: "oct",
21 k: "jnOw99oOZFLIEPMrgJB55WL46tJSLGt7jnOw99oOZFI"
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...");
42 return crypto.subtle.importKey("jwk", jwkKey, {name: "AES-CBC"}, extractable, ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey']);
43 }).then(function(result) {
44 key = result;
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);
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))", "'8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b8e73b0f7da0e6452'");
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', 'unwrapKey']");
79 debug("\nImporting a key that's not extractable...");
80 return crypto.subtle.importKey("jwk", jwkKey, {name: "AES-CBC"}, nonExtractable, ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'])
81 }).then(function(result) {
82 key = result;
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);
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);
102 finishJSTest();
104 </script>
106 </body>
107 </html>