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

Side by Side Diff: LayoutTests/crypto/resources/common.js

Issue 141413003: [webcrypto] Match the error handling defined by the spec. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 11 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
« no previous file with comments | « LayoutTests/crypto/importKey-expected.txt ('k') | LayoutTests/crypto/sign-verify.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 function importTestKeys() 1 function importTestKeys()
2 { 2 {
3 var keyFormat = "raw"; 3 var keyFormat = "raw";
4 var data = asciiToUint8Array("16 bytes of key!"); 4 var data = asciiToUint8Array("16 bytes of key!");
5 var extractable = true; 5 var extractable = true;
6 var keyUsages = ['wrapKey', 'unwrapKey', 'encrypt', 'decrypt', 'sign', 'veri fy']; 6 var keyUsages = ['wrapKey', 'unwrapKey', 'encrypt', 'decrypt', 'sign', 'veri fy'];
7 7
8 var hmacPromise = crypto.subtle.importKey(keyFormat, data, {name: 'hmac', ha sh: {name: 'sha-1'}}, extractable, keyUsages); 8 var hmacPromise = crypto.subtle.importKey(keyFormat, data, {name: 'hmac', ha sh: {name: 'sha-1'}}, extractable, keyUsages);
9 var aesCbcPromise = crypto.subtle.importKey(keyFormat, data, {name: 'AES-CBC '}, extractable, keyUsages); 9 var aesCbcPromise = crypto.subtle.importKey(keyFormat, data, {name: 'AES-CBC '}, extractable, keyUsages);
10 var aesCbcJustDecrypt = crypto.subtle.importKey(keyFormat, data, {name: 'AES -CBC'}, false, ['decrypt']); 10 var aesCbcJustDecrypt = crypto.subtle.importKey(keyFormat, data, {name: 'AES -CBC'}, false, ['decrypt']);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 chars.push(str.charCodeAt(i)); 80 chars.push(str.charCodeAt(i));
81 return new Uint8Array(chars); 81 return new Uint8Array(chars);
82 } 82 }
83 83
84 function failAndFinishJSTest(error) 84 function failAndFinishJSTest(error)
85 { 85 {
86 if (error) 86 if (error)
87 debug(error); 87 debug(error);
88 finishJSTest(); 88 finishJSTest();
89 } 89 }
90
91 numOutstandingTasks = 0;
92
93 function addTask(promise)
94 {
95 numOutstandingTasks++;
96
97 function taskFinished()
98 {
99 numOutstandingTasks--;
100 completeTestWhenAllTasksDone();
101 }
102
103 promise.then(taskFinished, taskFinished);
104 }
105
106 function completeTestWhenAllTasksDone()
107 {
108 if (numOutstandingTasks == 0) {
109 finishJSTest();
110 }
111 }
112
113 function shouldRejectPromiseWithNull(code)
114 {
115 var promise = eval(code);
116
117 function acceptCallback(result)
118 {
119 debug("FAIL: '" + code + "' accepted with " + result + " but should have been rejected");
120 }
121
122 function rejectCallback(result)
123 {
124 if (result == null)
125 debug("PASS: '" + code + "' rejected with null");
126 else
127 debug("FAIL: '" + code + "' rejected with " + result + " but was exp ecting null");
128 }
129
130 addTask(promise.then(acceptCallback, rejectCallback));
131 }
132
133 function shouldAcceptPromise(code)
134 {
135 var promise = eval(code);
136
137 function acceptCallback(result)
138 {
139 debug("PASS: '" + code + "' accepted with " + result);
140 }
141
142 function rejectCallback(result)
143 {
144 debug("FAIL: '" + code + "' rejected with " + result);
145 }
146
147 addTask(promise.then(acceptCallback, rejectCallback));
148 }
OLDNEW
« no previous file with comments | « LayoutTests/crypto/importKey-expected.txt ('k') | LayoutTests/crypto/sign-verify.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698