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

Unified Diff: LayoutTests/crypto/digest-failures.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/digest-expected.txt ('k') | LayoutTests/crypto/digest-failures-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/crypto/digest-failures.html
diff --git a/LayoutTests/crypto/digest-failures.html b/LayoutTests/crypto/digest-failures.html
new file mode 100644
index 0000000000000000000000000000000000000000..1162e1cdc2c1743c0afa114102b8da5a1a502703
--- /dev/null
+++ b/LayoutTests/crypto/digest-failures.html
@@ -0,0 +1,43 @@
+<!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 incorrect calls to crypto.subtle.digest()");
+
+jsTestIsAsync = true;
+
+// 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)");
+
+// Pass invalid algorithmIdentifiers to digest()
+data = new Uint8Array([0]);
+shouldThrow("crypto.subtle.digest(null, data)");
+
+Promise.resolve(null).then(function(result) {
+ // "sha" is not a recognized algorithm name
+ return crypto.subtle.digest({name: 'sha'}, data);
+}).then(failAndFinishJSTest, function(result) {
+ error = result;
+ shouldBeNull("error");
+
+ // Algorithm lacks a name.
+ return crypto.subtle.digest({}, data);
+}).then(failAndFinishJSTest, function(result) {
+ error = result;
+ shouldBeNull("error");
+
+}).then(finishJSTest, failAndFinishJSTest);
+
+</script>
+
+</body>
+</html>
« no previous file with comments | « LayoutTests/crypto/digest-expected.txt ('k') | LayoutTests/crypto/digest-failures-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698