4 <script src=
"../../resources/js-test.js"></script>
5 <script src=
"resources/common.js"></script>
8 <p id=
"description"></p>
9 <div id=
"console"></div>
12 description("Tests cancelling of crypto operations when the context is destroyed.");
14 // Start a worker thread which starts a LOT of expensive
15 // webcrypto operations (generating RSA keys).
17 // Now from the main page try to generate an AES key.
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.
23 // If the crypto tasks started by the web worker are NOT
24 // cancelled (and are merely orphaned), then the test is going to
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
)
36 worker
.onerror = function(error
)
38 debug(error
.filename
+ ':' + error
.lineno
+ ': ' + error
.message
);
39 reject('worker failed');
44 function generateTestKey() {
45 var algorithm
= {name
: "AES-CBC", length
: 128};
46 return crypto
.subtle
.generateKey(algorithm
, true, ['encrypt']).then(function() {
47 debug('Successfully generated AES-CBC key');
51 startWorker().then(generateTestKey
).then(finishJSTest
, failAndFinishJSTest
);