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

Side by Side Diff: LayoutTests/crypto/importKey-badParameters.html

Issue 211933003: [refactor] Split importKey.html into smaller files. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../resources/js-test.js"></script>
5 <script src="resources/common.js"></script>
6 </head>
7 <body>
8 <p id="description"></p>
9 <div id="console"></div>
10
11 <script>
12 description("Tests calling cypto.subtle.importKey with bad parameters");
13
14 jsTestIsAsync = true;
15
16 var aesCbc = {name: 'aes-cbc'};
17 var aesKeyBytes = new Uint8Array(16);
18 var extractable = true;
19
20 // Undefined key usage.
21 // FIXME: http://crbug.com/262383
22 //shouldThrow("crypto.subtle.importKey('raw', aesKeyBytes, aesCbc, extractable, undefined)");
23
24 // Invalid data
25 shouldThrow("crypto.subtle.importKey('raw', [], aesCbc, extractable, ['encrypt'] )");
26 shouldThrow("crypto.subtle.importKey('raw', null, aesCbc, extractable, ['encrypt '])");
27
28 // Invalid algorithm
29 shouldThrow("crypto.subtle.importKey('raw', aesCbc, null, extractable, ['encrypt '])");
30
31 Promise.resolve(null).then(function() {
32 // Invalid format.
33 return crypto.subtle.importKey('invalid format', aesKeyBytes, aesCbc, extrac table, ['encrypt']);
34 }).then(failAndFinishJSTest, function(result) {
35 error = result;
36 shouldBeNull("error");
37
38 // Invalid key usage (case sensitive).
39 return crypto.subtle.importKey('raw', aesKeyBytes, aesCbc, extractable, ['EN CRYPT']);
40 }).then(failAndFinishJSTest, function(result) {
41 error = result;
42 shouldBeNull("error");
43
44 // If both the format and key usage are bogus, should complain about the
45 // format first.
46 return crypto.subtle.importKey('invalid format', aesKeyBytes, aesCbc, extrac table, ['ENCRYPT']);
47 }).then(failAndFinishJSTest, function(result) {
48 error = result;
49 shouldBeNull("error");
50
51 // Missing hash parameter for HMAC.
52 return crypto.subtle.importKey('raw', new Uint8Array(20), {name: 'hmac'}, ex tractable, ['sign']);
53 }).then(failAndFinishJSTest, function(result) {
54 error = result;
55 shouldBeNull("error");
56
57 // SHA-1 doesn't support the importKey operation.
58 return crypto.subtle.importKey('raw', new Uint8Array(20), {name: 'sha-1'}, e xtractable, ['sign']);
59 }).then(failAndFinishJSTest, function(result) {
60 error = result;
61 shouldBeNull("error");
62 }).then(finishJSTest, failAndFinishJSTest);
63
64 </script>
65
66 </body>
67 </html>
OLDNEW
« no previous file with comments | « LayoutTests/crypto/importKey.html ('k') | LayoutTests/crypto/importKey-badParameters-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698