| <!DOCTYPE html> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <script src="../../../resources/js-test-pre.js"></script> |
| <script src="../../resources/common.js"></script> |
| </head> |
| <body> |
| <script> |
| |
| description("Test sending multiple crypto keys via postMessage to a worker."); |
| |
| jsTestIsAsync = true; |
| |
| var count = 0; |
| var worker = new Worker("resources/aes-postMessage-worker.js"); |
| worker.onmessage = function(evt) { |
| if (!evt.data.result) { |
| testFailed("Check failed in worker: " + evt.data.message); |
| finishJSTest(); |
| } else { |
| testPassed("All checks passed in worker: " + count); |
| key = evt.data.key; |
| shouldBe("key.type", "'secret'"); |
| shouldBe("key.extractable", "true"); |
| shouldBe("key.algorithm.name", "'AES-CBC'"); |
| shouldBe("key.algorithm.length", "128"); |
| shouldBe("key.usages", "['decrypt', 'encrypt']"); |
| count = count + 1; |
| } |
| |
| if (count == 10) |
| finishJSTest(); |
| } |
| |
| var keyFormat = "raw"; |
| var keyData = asciiToUint8Array("16 bytes of key!"); |
| var aesKeyGenParams = {name: "aes-cbc", length: 128}; |
| var usages = ["encrypt", "decrypt"] |
| for (i = 0; i < 10; i++) |
| crypto.subtle.importKey(keyFormat, keyData, aesKeyGenParams, true, usages).then(function(localKey) { |
| worker.postMessage(localKey); |
| }); |
| </script> |
| <script src="../../../resources/js-test-post.js"></script> |
| </body> |
| </html> |