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

Unified Diff: LayoutTests/crypto/aes-cbc-generateKey-parseAlgorithm-failures.html

Issue 215153005: [refactor] Split up generateKey.html into multiple files, and test errors directly. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Re-upload with --similarity=20 Created 6 years, 9 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/aes-cbc-generateKey-parseAlgorithm-failures-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/crypto/aes-cbc-generateKey-parseAlgorithm-failures.html
diff --git a/LayoutTests/crypto/aes-cbc-parseAlgorithm-failures.html b/LayoutTests/crypto/aes-cbc-generateKey-parseAlgorithm-failures.html
similarity index 41%
copy from LayoutTests/crypto/aes-cbc-parseAlgorithm-failures.html
copy to LayoutTests/crypto/aes-cbc-generateKey-parseAlgorithm-failures.html
index d41e48d6af8db3527148e3ce094fa79d95c3b612..bbc16d343fc97329d3bf0d6aec9c014a5ebd899e 100644
--- a/LayoutTests/crypto/aes-cbc-parseAlgorithm-failures.html
+++ b/LayoutTests/crypto/aes-cbc-generateKey-parseAlgorithm-failures.html
@@ -9,43 +9,39 @@
<div id="console"></div>
<script>
-description("Tests bad algorithm inputs for AES-CBC");
-
+description("Tests generateKey() with bad AES-CBC parameters.");
jsTestIsAsync = true;
-var keyData = hexStringToUint8Array("2b7e151628aed2a6abf7158809cf4f3c");
-var data = asciiToUint8Array("hello");
-var key = null;
+extractable = true;
+keyUsages = ['encrypt', 'decrypt'];
-Promise.resolve(null).then(function(result) {
- var usages = ['encrypt', 'decrypt'];
- var extractable = false;
- var algorithm = {name: 'aes-cbc'};
+// Invalid keyUsages
+shouldThrow("crypto.subtle.generateKey({ name: 'aes-cbc', length: 1024 }, extractable, -1)");
+shouldThrow("crypto.subtle.generateKey({ name: 'aes-cbc', length: 1024 }, extractable, null)");
- return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usages);
-}).then(function(result) {
- key = result;
+Promise.resolve(null).then(function() {
+ // Bad key usage "boo".
+ return crypto.subtle.generateKey({ name: 'aes-cbc', length: 1024 }, extractable, ['boo']);
+}).then(failAndFinishJSTest, function(result) {
+ error = result;
+ shouldBeNull("error");
- // Bad iv
- return crypto.subtle.encrypt({name: 'AES-CBC', iv: null}, key, data);
+ return crypto.subtle.generateKey({ name: 'aes-cbc' }, extractable, keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
- // Missing iv
- return crypto.subtle.decrypt({name: 'AES-CBC'}, key, data);
+ return crypto.subtle.generateKey({ name: 'aes-cbc', length: 70000 }, extractable, keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
- // iv is not a buffer
- return crypto.subtle.encrypt({name: 'AES-CBC', iv: 3}, key, data);
+ return crypto.subtle.generateKey({ name: 'aes-cbc', length: -3 }, extractable, keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
- // iv is too short
- return crypto.subtle.encrypt({name: 'AES-CBC', iv: new Uint8Array(0)}, key, data);
+ return crypto.subtle.generateKey({ name: 'aes-cbc', length: -Infinity }, extractable, keyUsages);
}).then(failAndFinishJSTest, function(result) {
error = result;
shouldBeNull("error");
« no previous file with comments | « no previous file | LayoutTests/crypto/aes-cbc-generateKey-parseAlgorithm-failures-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698