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

Side by Side Diff: LayoutTests/crypto/digest-failures.html

Issue 243853004: [webcrypto] Reject failed operations with a DOMException rather than null. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix compile warning Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../resources/js-test.js"></script> 4 <script src="../resources/js-test.js"></script>
5 <script src="resources/common.js"></script> 5 <script src="resources/common.js"></script>
6 </head> 6 </head>
7 <body> 7 <body>
8 <p id="description"></p> 8 <p id="description"></p>
9 <div id="console"></div> 9 <div id="console"></div>
10 10
11 <script> 11 <script>
12 description("Tests incorrect calls to crypto.subtle.digest()"); 12 description("Tests incorrect calls to crypto.subtle.digest()");
13 13
14 jsTestIsAsync = true; 14 jsTestIsAsync = true;
15 15
16 Promise.resolve(null).then(function(result) { 16 Promise.resolve(null).then(function(result) {
17 // Called with too few parameters. 17 // Called with too few parameters.
18 return crypto.subtle.digest({name: 'sha-1'}); 18 return crypto.subtle.digest({name: 'sha-1'});
19 }).then(failAndFinishJSTest, function(result) { 19 }).then(failAndFinishJSTest, function(result) {
20 error = result; 20 logError(result);
21 shouldBeTypeError("error");
22 21
23 // "null" is not a valid data argument. 22 // "null" is not a valid data argument.
24 return crypto.subtle.digest({name: 'sha-1'}, null); 23 return crypto.subtle.digest({name: 'sha-1'}, null);
25 }).then(failAndFinishJSTest, function(result) { 24 }).then(failAndFinishJSTest, function(result) {
26 error = result; 25 logError(result);
27 shouldBeNull("error");
28 26
29 // 10 is not a valid data argument. 27 // 10 is not a valid data argument.
30 return crypto.subtle.digest({name: 'sha-1'}, 10); 28 return crypto.subtle.digest({name: 'sha-1'}, 10);
31 }).then(failAndFinishJSTest, function(result) { 29 }).then(failAndFinishJSTest, function(result) {
32 error = result; 30 logError(result);
33 shouldBeNull("error");
34 31
35 // null is not a valid algorithm argument. 32 // null is not a valid algorithm argument.
36 data = new Uint8Array([0]); 33 data = new Uint8Array([0]);
37 return crypto.subtle.digest(null, data); 34 return crypto.subtle.digest(null, data);
38 }).then(failAndFinishJSTest, function(result) { 35 }).then(failAndFinishJSTest, function(result) {
39 error = result; 36 logError(result);
40 shouldBeNull("error");
41 37
42 // "sha" is not a recognized algorithm name 38 // "sha" is not a recognized algorithm name
43 return crypto.subtle.digest({name: 'sha'}, data); 39 return crypto.subtle.digest({name: 'sha'}, data);
44 }).then(failAndFinishJSTest, function(result) { 40 }).then(failAndFinishJSTest, function(result) {
45 error = result; 41 logError(result);
46 shouldBeNull("error");
47 42
48 // Algorithm lacks a name. 43 // Algorithm lacks a name.
49 return crypto.subtle.digest({}, data); 44 return crypto.subtle.digest({}, data);
50 }).then(failAndFinishJSTest, function(result) { 45 }).then(failAndFinishJSTest, function(result) {
51 error = result; 46 logError(result);
52 shouldBeNull("error");
53 47
54 }).then(finishJSTest, failAndFinishJSTest); 48 }).then(finishJSTest, failAndFinishJSTest);
55 49
56 </script> 50 </script>
57 51
58 </body> 52 </body>
59 </html> 53 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698