| OLD | NEW |
| (Empty) |
| 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> | |
| 10 | |
| 11 <script> | |
| 12 description("Tests cancelling of crypto operations when the context is destr
oyed."); | |
| 13 | |
| 14 // Start a worker thread which starts a LOT of expensive | |
| 15 // webcrypto operations (generating RSA keys). | |
| 16 // | |
| 17 // Now from the main page try to generate an AES key. | |
| 18 // | |
| 19 // Lastly, the web worker closes itself. This should have the | |
| 20 // effect of aborting all of the web crypto operations it had | |
| 21 // started, and now the AES key generation will be able to complete. | |
| 22 // | |
| 23 // If the crypto tasks started by the web worker are NOT | |
| 24 // cancelled (and are merely orphaned), then the test is going to | |
| 25 // timeout. | |
| 26 jsTestIsAsync = true; | |
| 27 | |
| 28 function startWorker() { | |
| 29 return new Promise(function(resolve, reject) { | |
| 30 var worker = new Worker("resources/worker-start-slow-operations.js")
; | |
| 31 worker.onmessage = function(event) | |
| 32 { | |
| 33 debug(event.data); | |
| 34 resolve(); | |
| 35 }; | |
| 36 worker.onerror = function(error) | |
| 37 { | |
| 38 debug(error.filename + ':' + error.lineno + ': ' + error.message
); | |
| 39 reject('worker failed'); | |
| 40 } | |
| 41 }); | |
| 42 } | |
| 43 | |
| 44 function generateTestKey() { | |
| 45 var algorithm = {name: "AES-CBC", length: 128}; | |
| 46 return crypto.subtle.generateKey(algorithm, true, ['encrypt']).then(func
tion() { | |
| 47 debug('Successfully generated AES-CBC key'); | |
| 48 }); | |
| 49 } | |
| 50 | |
| 51 startWorker().then(generateTestKey).then(finishJSTest, failAndFinishJSTest); | |
| 52 </script> | |
| 53 </body> | |
| 54 </html> | |
| OLD | NEW |