Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Unified Diff: LayoutTests/crypto/abandon-crypto-operation2.html

Issue 343723003: [webcrypto] Allow crypto operations to be cancelled by the platform implementation. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix comment typo Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/crypto/abandon-crypto-operation2-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/crypto/abandon-crypto-operation2.html
diff --git a/LayoutTests/crypto/abandon-crypto-operation2.html b/LayoutTests/crypto/abandon-crypto-operation2.html
new file mode 100644
index 0000000000000000000000000000000000000000..68558b990ef87abd759dcaf5a4e810add2ea4bd0
--- /dev/null
+++ b/LayoutTests/crypto/abandon-crypto-operation2.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../resources/js-test.js"></script>
+<script src="resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+ description("Tests cancelling of crypto operations when the context is destroyed.");
+
+ // Start a worker thread which starts a LOT of expensive
+ // webcrypto operations (generating RSA keys).
+ //
+ // Now from the main page try to generate an AES key.
+ //
+ // Lastly, the web worker closes itself. This should have the
+ // effect of aborting all of the web crypto operations it had
+ // started, and now the AES key generation will be able to complete.
+ //
+ // If the crypto tasks started by the web worker are NOT
+ // cancelled (and are merely orphaned), then the test is going to
+ // timeout.
+ jsTestIsAsync = true;
+
+ function startWorker() {
+ return new Promise(function(resolve, reject) {
+ var worker = new Worker("resources/worker-start-slow-operations.js");
+ worker.onmessage = function(event)
+ {
+ debug(event.data);
+ resolve();
+ };
+ worker.onerror = function(error)
+ {
+ debug(error.filename + ':' + error.lineno + ': ' + error.message);
+ reject('worker failed');
+ }
+ });
+ }
+
+ function generateTestKey() {
+ var algorithm = {name: "AES-CBC", length: 128};
+ return crypto.subtle.generateKey(algorithm, true, ['encrypt']).then(function() {
+ debug('Successfully generated AES-CBC key');
+ });
+ }
+
+ startWorker().then(generateTestKey).then(finishJSTest, failAndFinishJSTest);
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/crypto/abandon-crypto-operation2-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698