Replace CryptoOperationData with BufferSource for WebKitSubtleCrypto
[WebKit-https.git] / LayoutTests / crypto / webkitSubtle / import-export-raw-key-leak.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <script src="../../resources/js-test-pre.js"></script>
5     <script type="text/javascript">
6     jsTestIsAsync = true;
7
8     var keySize = 0x100;
9     var blob = new Blob([""], {type : 'application/javascript'});
10     var worker = new Worker(URL.createObjectURL(blob));
11
12     function run()
13     {
14         if (window.testRunner)
15             testRunner.dumpAsText();
16
17         function arrayBufferNeuter(ab)
18         {
19             /* Neuter the ArrayBuffer */
20             debug("Sending Worker Message");
21             worker.postMessage(ab, [ab]);
22             worker.terminate();
23             debug("Worker Terminated");
24         }
25
26         var a = new ArrayBuffer(keySize);
27         var b = { };
28         b.__defineGetter__('name', function(){
29             arrayBufferNeuter(a);
30             return "AES-CBC";
31         });
32         var result = window.crypto.webkitSubtle.importKey("raw", a, b, true);
33         result.then(function(key) {
34             window.crypto.webkitSubtle.exportKey("raw", key).then(function(result) {
35                 exportedKey = result;
36                 shouldBeZero("exportedKey.byteLength");
37                 finishJSTest();
38             });
39         });
40     }
41     </script>
42     <script src="../../resources/js-test-post.js"></script>
43 </head>
44 <body onload="run()"></body>
45 </html>