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

Unified Diff: LayoutTests/crypto/sha-digest.html

Issue 206483010: [webcrypto] Refactor some layout tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | « LayoutTests/crypto/resources/keys.js ('k') | LayoutTests/crypto/sha-digest-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/crypto/sha-digest.html
diff --git a/LayoutTests/crypto/digest.html b/LayoutTests/crypto/sha-digest.html
similarity index 79%
rename from LayoutTests/crypto/digest.html
rename to LayoutTests/crypto/sha-digest.html
index 3160c38658f2c42434e430ffb78ac94ea670b7bc..7d150c2981b2e957ca41572242a14fbd991332cc 100644
--- a/LayoutTests/crypto/digest.html
+++ b/LayoutTests/crypto/sha-digest.html
@@ -9,7 +9,7 @@
<div id="console"></div>
<script>
-description("Tests cypto.subtle.digest.");
+description("Tests the digest() operation for SHA-*");
jsTestIsAsync = true;
@@ -83,12 +83,7 @@ kDigestTestVectors = [
},
];
-// Run each test.
-for (var i = 0; i < kDigestTestVectors.length; ++i) {
- addTask(runTestCase(kDigestTestVectors[i]));
-}
-
-function runTestCase(testCase)
+function runTest(testCase)
{
return crypto.subtle.digest({name: testCase.algorithm}, hexStringToUint8Array(testCase.input)).then(function(result) {
var testDescription = testCase.algorithm + " of [" + testCase.input + "]";
@@ -96,18 +91,13 @@ function runTestCase(testCase)
});
}
-// Pass invalid data to digest()
-shouldThrow("crypto.subtle.digest({name: 'sha-1'})");
-shouldThrow("crypto.subtle.digest({name: 'sha-1'}, null)");
-shouldThrow("crypto.subtle.digest({name: 'sha-1'}, 10)");
+var lastPromise = Promise.resolve(null);
-// Pass invalid algorithmIdentifiers to digest()
-data = new Uint8Array([0]);
-shouldRejectPromiseWithNull("crypto.subtle.digest({name: 'sha'}, data)");
-shouldThrow("crypto.subtle.digest(null, data)");
-shouldRejectPromiseWithNull("crypto.subtle.digest({}, data)");
+kDigestTestVectors.forEach(function(test) {
+ lastPromise = lastPromise.then(runTest.bind(null, test));
+});
-completeTestWhenAllTasksDone();
+lastPromise.then(finishJSTest, failAndFinishJSTest);
</script>
« no previous file with comments | « LayoutTests/crypto/resources/keys.js ('k') | LayoutTests/crypto/sha-digest-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698