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

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

Issue 23164012: WebCrypto: Remove support for multi-part operations. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 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="../fast/js/resources/js-test-pre.js"></script> 4 <script src="../fast/js/resources/js-test-pre.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
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 function failHandler(value) 49 function failHandler(value)
50 { 50 {
51 testFailed(value); 51 testFailed(value);
52 startNextTest(); 52 startNextTest();
53 } 53 }
54 54
55 allTests = [ 55 allTests = [
56 function() 56 function()
57 { 57 {
58 debug("SHA1 of [] -- with empty process()") 58 debug("SHA1 of []")
59 op = crypto.subtle.digest({name: 'sha-1'}); 59 crypto.subtle.digest({name: 'sha-1'}, new Uint8Array([])).then(resultHan dler, rejectHandler);
60 op.process(new Uint8Array([]));
61 op.finish().then(resultHandler, rejectHandler);
62 },
63
64 function()
65 {
66 debug("SHA1 of [] -- without calling process()")
67 op = crypto.subtle.digest({name: 'sha-1'});
68 op.finish().then(resultHandler, rejectHandler);
69 }, 60 },
70 61
71 function() 62 function()
72 { 63 {
73 debug("SHA1 of [0x0]") 64 debug("SHA1 of [0x0]")
74 op = crypto.subtle.digest({name: 'sha-1'}); 65 crypto.subtle.digest({name: 'sha-1'}, new Uint8Array([0])).then(resultHa ndler, rejectHandler);
75 op.process(new Uint8Array([0]));
76 op.finish().then(resultHandler, rejectHandler);
77 },
78
79 function()
80 {
81 debug("SHA1 of [0x0] -- as an ArrayBuffer")
82 op = crypto.subtle.digest({name: 'sha-1'});
83 op.process(new Uint8Array([0]).buffer);
84 op.finish().then(resultHandler, rejectHandler);
85 },
86
87 function()
88 {
89 debug("SHA1 of [0, 1, 2, 3, 4, 5] -- multipart")
90 op = crypto.subtle.digest({name: 'sha-1'});
91 op.process(new Uint8Array([0]));
92 op.process(new Uint8Array([1]));
93 op.process(new Uint8Array([2]));
94 op.process(new Uint8Array([3]));
95 op.process(new Uint8Array([4]));
96 op.process(new Uint8Array([5]));
97 op.finish().then(resultHandler, rejectHandler);
98 },
99
100 function()
101 {
102 debug("Call process() after finish()");
103 op = crypto.subtle.digest({name: 'sha-1'});
104 op.finish().then(resultHandler, rejectHandler);
105 // These should all be no-ops, since has already finished.
106 op.process(new Uint8Array([0]));
107 op.process(new Uint8Array([1]));
108 op.process(new Uint8Array([2]));
109 op.process(new Uint8Array([3]));
110 },
111
112 function()
113 {
114 debug("abort()");
115 op = crypto.subtle.digest({name: 'sha-1'});
116 op.abort().then(resultHandler, rejectHandler);
117 },
118
119 function()
120 {
121 debug("abort() and then abort()");
122 op = crypto.subtle.digest({name: 'sha-1'});
123 op.abort().then(failHandler, function(value) {
124 rejectHandler(value, true);
125 op.abort().then(resultHandler, rejectHandler);
126 });
127 },
128
129 function()
130 {
131 debug("process() and then abort()");
132 op = crypto.subtle.digest({name: 'sha-1'});
133 op.process(new Uint8Array([0]));
134 op.abort().then(resultHandler, rejectHandler);
135 },
136
137 function()
138 {
139 debug("finish() and then abort()");
140 op = crypto.subtle.digest({name: 'sha-1'});
141 op.finish().then(function(value) {
142 resultHandler(value, true);
143 op.abort().then(resultHandler, rejectHandler);
144 }, failHandler);
145 },
146
147 function()
148 {
149 debug("finish() and then process()");
150 op = crypto.subtle.digest({name: 'sha-1'});
151 op.finish().then(resultHandler, rejectHandler);
152 op.process(new Uint8Array([0]));
153 },
154
155 function()
156 {
157 debug("finish() and then finish()");
158 op = crypto.subtle.digest({name: 'sha-1'});
159 op.finish().then(function(value) {
160 resultHandler(value, true);
161 op.finish().then(resultHandler, rejectHandler);
162 }, failHandler);
163 }, 66 },
164 67
165 function() 68 function()
166 { 69 {
167 debug("SHA-256 rejects (dummy implementation)"); 70 debug("SHA-256 rejects (dummy implementation)");
168 op = crypto.subtle.digest({name: 'sha-256'}); 71 crypto.subtle.digest({name: 'sha-256'}, new Uint8Array([])).then(resultH andler, rejectHandler);
169 op.finish().then(resultHandler, rejectHandler);
170 }, 72 },
171 73
172 function() 74 function()
173 { 75 {
174 debug("Error during process() (dummy implementation rejects inputs over 6 bytes)"); 76 debug("Error (dummy implementation rejects this input)");
175 op = crypto.subtle.digest({name: 'sha-1'}); 77 var data = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
176 op.process(new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])); 78 crypto.subtle.digest({name: 'sha-1'}, data).then(resultHandler, rejectHa ndler);
177 op.finish().then(resultHandler, rejectHandler);
178 }, 79 },
179 80
180 function() 81 function()
181 { 82 {
182 op = crypto.subtle.digest({name: 'sha-1'}); 83 shouldThrow("crypto.subtle.digest({name: 'sha-1'})");
183 shouldThrow("op.process(null)"); 84 shouldThrow("crypto.subtle.digest({name: 'sha-1'}, null)");
184 shouldThrow("op.process()"); 85 shouldThrow("crypto.subtle.digest({name: 'sha-1'}, 10)");
185 shouldThrow("op.process(-1)");
186 startNextTest(); 86 startNextTest();
187 }, 87 },
188 ]; 88 ];
189 89
190 // Begin! 90 // Begin!
191 startNextTest(); 91 startNextTest();
192 92
193 </script> 93 </script>
194 94
195 <script src="../fast/js/resources/js-test-post.js"></script> 95 <script src="../fast/js/resources/js-test-post.js"></script>
196 </body> 96 </body>
197 </html> 97 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/crypto/digest-expected.txt » ('j') | Source/core/platform/chromium/support/WebCrypto.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698