Update SubtleCrypto::generateKey to match the latest spec
[WebKit-https.git] / LayoutTests / crypto / workers / subtle / resources / aes-generate-key.js
1 importScripts('../../../../resources/js-test-pre.js');
2
3 description("Test generating an AES key using AES-CBC algorithm in workers.");
4 jsTestIsAsync = true;
5
6 var extractable = true;
7
8 shouldReject('crypto.subtle.generateKey({name: "aes-cbc", length: 128}, extractable, ["sign"])');
9 shouldReject('crypto.subtle.generateKey({name: "aes-cbc", length: 111}, extractable, ["encrypt"])');
10
11 debug("Generating a key...");
12 crypto.subtle.generateKey({name: "aes-cbc", length: 128}, extractable, ["decrypt", "encrypt", "unwrapKey", "wrapKey"]).then(function(result) {
13     key = result;
14
15     shouldBe("key.type", "'secret'");
16     shouldBe("key.extractable", "true");
17     shouldBe("key.algorithm.name", "'AES-CBC'");
18     shouldBe("key.algorithm.length", "128");
19     shouldBe("key.usages", "['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']");
20
21     finishJSTest();
22 });