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

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

Issue 222003006: [webcrypto] Don't throw any extra WebIDL exceptions from WebCrypto methods. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 8 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 exportKey() given bad inputs."); 12 description("Tests exportKey() given bad inputs.");
13 13
14 jsTestIsAsync = true; 14 jsTestIsAsync = true;
15 15
16 // Not keys
17 shouldThrow("crypto.subtle.exportKey('raw', null)");
18 shouldThrow("crypto.subtle.exportKey('raw', 3)");
19
20 function importAesKey() 16 function importAesKey()
21 { 17 {
22 var keyData = new Uint8Array(16); 18 var keyData = new Uint8Array(16);
23 var usages = ['encrypt']; 19 var usages = ['encrypt'];
24 var extractable = true; 20 var extractable = true;
25 var algorithm = {name: 'aes-cbc'}; 21 var algorithm = {name: 'aes-cbc'};
26 22
27 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage s); 23 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage s);
28 } 24 }
29 25
30 importAesKey().then(function(result) { 26 Promise.resolve(null).then(function(result) {
27 // null is not a valid Key.
28 return crypto.subtle.exportKey('raw', null);
29 }).then(failAndFinishJSTest, function(result) {
30 error = result;
31 shouldBeNull("error");
32
33 // 3 is not a valid Key.
34 return crypto.subtle.exportKey('raw', 3);
35 }).then(failAndFinishJSTest, function(result) {
36 error = result;
37 shouldBeNull("error");
38
39 return importAesKey();
40 }).then(function(result) {
31 key = result; 41 key = result;
32 42
33 // Invalid export format 43 // Invalid export format
34 return crypto.subtle.exportKey(3, key); 44 return crypto.subtle.exportKey(3, key);
35 }).then(failAndFinishJSTest, function(result) { 45 }).then(failAndFinishJSTest, function(result) {
36 error = result; 46 error = result;
37 shouldBeNull("error"); 47 shouldBeNull("error");
38 48
39 // Invalid export format 49 // Invalid export format
40 return crypto.subtle.exportKey(null, key); 50 return crypto.subtle.exportKey(null, key);
41 }).then(failAndFinishJSTest, function(result) { 51 }).then(failAndFinishJSTest, function(result) {
42 error = result; 52 error = result;
43 shouldBeNull("error"); 53 shouldBeNull("error");
44 54
45 // Invalid export format 55 // Invalid export format
46 return crypto.subtle.exportKey('invalid', key); 56 return crypto.subtle.exportKey('invalid', key);
47 }).then(failAndFinishJSTest, function(result) { 57 }).then(failAndFinishJSTest, function(result) {
48 error = result; 58 error = result;
49 shouldBeNull("error"); 59 shouldBeNull("error");
50 }).then(finishJSTest, failAndFinishJSTest); 60 }).then(finishJSTest, failAndFinishJSTest);
51 61
52 </script> 62 </script>
53 63
54 </body> 64 </body>
55 </html> 65 </html>
OLDNEW
« no previous file with comments | « LayoutTests/crypto/digest-failures-expected.txt ('k') | LayoutTests/crypto/exportKey-badParameters-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698