| OLD | NEW |
| 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 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 input: "000102030405", | 91 input: "000102030405", |
| 92 output: "79f4738706fce9650ac60266675c3cd07298b09923850d525604d040e6e448adc7d
c22780d7e1b95bfeaa86a678e4552" | 92 output: "79f4738706fce9650ac60266675c3cd07298b09923850d525604d040e6e448adc7d
c22780d7e1b95bfeaa86a678e4552" |
| 93 }, | 93 }, |
| 94 { | 94 { |
| 95 algorithm: "SHA-512", | 95 algorithm: "SHA-512", |
| 96 input: "000102030405", | 96 input: "000102030405", |
| 97 output: "2f3831bccc94cf061bcfa5f8c23c1429d26e3bc6b76edad93d9025cb91c903af6cf
9c935dc37193c04c2c66e7d9de17c358284418218afea2160147aaa912f4c" | 97 output: "2f3831bccc94cf061bcfa5f8c23c1429d26e3bc6b76edad93d9025cb91c903af6cf
9c935dc37193c04c2c66e7d9de17c358284418218afea2160147aaa912f4c" |
| 98 }, | 98 }, |
| 99 ]; | 99 ]; |
| 100 | 100 |
| 101 var allTests = []; | |
| 102 | |
| 103 // Run each test. | 101 // Run each test. |
| 104 for (var i = 0; i < kDigestTestVectors.length; ++i) { | 102 for (var i = 0; i < kDigestTestVectors.length; ++i) { |
| 105 allTests.push(runTestCase(kDigestTestVectors[i])); | 103 addTask(runTestCase(kDigestTestVectors[i])); |
| 106 } | 104 } |
| 107 | 105 |
| 108 function runTestCase(testCase) | 106 function runTestCase(testCase) |
| 109 { | 107 { |
| 110 return crypto.subtle.digest({name: testCase.algorithm}, hexStringToUint8Arra
y(testCase.input)).then(function(result) { | 108 return crypto.subtle.digest({name: testCase.algorithm}, hexStringToUint8Arra
y(testCase.input)).then(function(result) { |
| 111 var testDescription = testCase.algorithm + " of [" + testCase.input + "]
"; | 109 var testDescription = testCase.algorithm + " of [" + testCase.input + "]
"; |
| 112 bytesShouldMatchHexString(testDescription, testCase.output, result); | 110 bytesShouldMatchHexString(testDescription, testCase.output, result); |
| 113 }); | 111 }); |
| 114 } | 112 } |
| 115 | 113 |
| 116 Promise.all(allTests).then(finishJSTest, failAndFinishJSTest); | 114 // Pass invalid data to digest() |
| 117 | |
| 118 // Pass invalid data to digeset() | |
| 119 shouldThrow("crypto.subtle.digest({name: 'sha-1'})"); | 115 shouldThrow("crypto.subtle.digest({name: 'sha-1'})"); |
| 120 shouldThrow("crypto.subtle.digest({name: 'sha-1'}, null)"); | 116 shouldThrow("crypto.subtle.digest({name: 'sha-1'}, null)"); |
| 121 shouldThrow("crypto.subtle.digest({name: 'sha-1'}, 10)"); | 117 shouldThrow("crypto.subtle.digest({name: 'sha-1'}, 10)"); |
| 122 | 118 |
| 123 // Pass invalid algorithmIdentifiers to digest() | 119 // Pass invalid algorithmIdentifiers to digest() |
| 124 data = new Uint8Array([0]); | 120 data = new Uint8Array([0]); |
| 125 shouldThrow("crypto.subtle.digest({name: 'sha'}, data)"); | 121 shouldThrow("crypto.subtle.digest({name: 'sha'}, data)"); |
| 126 shouldThrow("crypto.subtle.digest(null, data)"); | 122 shouldThrow("crypto.subtle.digest(null, data)"); |
| 127 shouldThrow("crypto.subtle.digest({}, data)"); | 123 shouldThrow("crypto.subtle.digest({}, data)"); |
| 128 | 124 |
| 125 completeTestWhenAllTasksDone(); |
| 126 |
| 129 </script> | 127 </script> |
| 130 | 128 |
| 131 </body> | 129 </body> |
| 132 </html> | 130 </html> |
| OLD | NEW |