Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / crypto / subtle / rsa-indexeddb.html
blobadf2bcc80adccf51c06e40801ef90a182335372b
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 <script>
10 description("Test storing a private RSA key in IndexedDB, and retrieving it.");
12 jsTestIsAsync = true;
14 var privateKeyJSON = {
15 kty: "RSA",
16 alg: "RS256",
17 n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
18 e: "AQAB",
19 d: "eNLS37aCz7RXSNPD_DtLBJ6j5T8cSxdzRBCjPaI6WcGqJp16lq3UTwuoDLAqlA9oGYm238dsIWpuucP_lQtbWe-7SpxoI6_vmYGf7YVUHv1-DF9qiOmSrMmdxMnVOzYXY8RaT6thPjn_J5cfLV2xI_LwsrMtmpdSyNlgX0zTUhwtuahgAKMEChYjH2EnjHdHw6sY2-wApdcQI7ULE0oo5RzbQZpmuhcN9hiBc0L3hhF0qo50mbl02_65_GQ7DpVkXBxNgRBLzlPabmzzG2oAhfefLgYmSC1opaCkXE6vRWQNWNL45RZNZFYM3uoJghOMqGeocM0BpjdChHrPOlFvSQ",
20 p: "4miTuAjKMeH5uJ5KB397QUwhbkYEgSbcA2mifmSkvE2018gb55qkBHK1eVryf1_m43LNlc6O_ak6gfzdZIZvS5NCGjPl0q09plUpu8qFOSspBwA67qGH76lFlZLn_d4yglS7wfLru4_5Ys8qLLs-DqVLviwposOnyyWqwM5AXp0",
21 q: "xHYrzkivtmnz_sGchnWGc0q-pDOkKicptRpv2pMFIIXxnFX5aMeEXIZjVujXtwUy1UlFIN2GZJSvy5KJ79mu_XyNnFHMzedH-A3ee3u8h1UUrZF-vUu1_e4U_x67NN1dedzUSKynN7pFl3OkuShMBWGV-cwzOPdcVAfVuZlxUMc",
22 dp: "fBzDzYDUBmBQGop7Hn0dvf_T27V6RqpctWo074CQZcFbP2atFVtKSj3viWT3xid2VHzcgiDHdfpM3nEVlEO1wwIonGCSvdjGEOZiiFVOjrZAOVxA8guOjyyFvqbXke06VwPIIVvfKeSU2zuhbP__1tt6F_fxow4Kb2xonGT0GGk",
23 dq: "jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5x-r9KwBZFC4FCG2hg_zE",
24 qi: "YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf9-2QuKDoWeRdd7NsdxTk"
27 crypto.subtle.importKey("jwk", privateKeyJSON, {name: "RSASSA-PKCS1-v1_5", hash: {name: "sha-256"}}, true, ["sign"]).then(function(key) {
28 var openRequest = indexedDB.open("crypto_subtle");
29 openRequest.onupgradeneeded = function(event) {
30 var objectStore = event.target.result.createObjectStore("rsa-indexeddb");
32 openRequest.onerror = function(event) {
33 testFailed("Could not open database: " + event.target.error.name);
34 finishJSTest();
36 openRequest.onsuccess = function(event) {
37 db = event.target.result;
38 storeKey();
41 function storeKey() {
42 var tx = db.transaction("rsa-indexeddb", "readwrite");
43 var objectStore = tx.objectStore("rsa-indexeddb");
44 var req = objectStore.put(key, "mykey");
45 req.onerror = function(event) {
46 testFailed("Could not put a key into database: " + event.target.error.name);
47 finishJSTest();
49 req.onsuccess = function(event) {
50 debug("Put key into database successfully");
53 tx.oncomplete = function() {
54 readKey();
58 function readKey() {
59 var objectStore = db.transaction("rsa-indexeddb").objectStore("rsa-indexeddb");
60 var req = objectStore.get("mykey");
61 req.onerror = function(event) {
62 testFailed("Could not get a key from database: " + event.target.error.name);
63 finishJSTest();
65 req.onsuccess = function(event) {
66 window.retrievedKey = event.target.result;
67 shouldBe("retrievedKey.type", "'private'");
68 shouldBe("retrievedKey.extractable", "true");
69 shouldBe("retrievedKey.algorithm.name", "'RSASSA-PKCS1-v1_5'");
70 shouldBe("retrievedKey.algorithm.modulusLength", "2048");
71 shouldBe("bytesToHexString(retrievedKey.algorithm.publicExponent)", "'010001'");
72 shouldBe("retrievedKey.usages", '["sign"]');
74 finishJSTest();
77 }).catch(failAndFinishJSTest);
78 </script>
79 </body>
80 </html>