| Index: LayoutTests/crypto/digest.html | 
| diff --git a/LayoutTests/crypto/digest.html b/LayoutTests/crypto/digest.html | 
| index d1931111cbc99eb0f8ef0d66cbbea627669b2205..9cc1a0e696f47172290d82865496288191caaf30 100644 | 
| --- a/LayoutTests/crypto/digest.html | 
| +++ b/LayoutTests/crypto/digest.html | 
| @@ -13,38 +13,119 @@ description("Tests cypto.subtle.digest."); | 
|  | 
| jsTestIsAsync = true; | 
|  | 
| -function printRejectedResult(value) | 
| -{ | 
| -    debug("    rejected with value of " + value); | 
| +// These SHA-* test vectors were taking from: | 
| +// http://csrc.nist.gov/groups/STM/cavp/documents/shs/shabytetestvectors.zip | 
| +// | 
| +// This is not intended to be an exhaustive test, but rather give basic | 
| +// confidence that things work. | 
| +// | 
| +// Both inputs and outputs are written as a hex-encoded string. | 
| +kDigestTestVectors = [ | 
| +  { | 
| +    algorithm: "SHA-1", | 
| +    input: "", | 
| +    output: "da39a3ee5e6b4b0d3255bfef95601890afd80709" | 
| +  }, | 
| +  { | 
| +    algorithm: "SHA-224", | 
| +    input: "", | 
| +    output: "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f" | 
| +  }, | 
| +  { | 
| +    algorithm: "SHA-256", | 
| +    input: "", | 
| +    output: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" | 
| +  }, | 
| +  { | 
| +    algorithm: "SHA-384", | 
| +    input: "", | 
| +    output: "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b" | 
| +  }, | 
| +  { | 
| +    algorithm: "SHA-512", | 
| +    input: "", | 
| +    output: "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" | 
| +  }, | 
| +  { | 
| +    algorithm: "SHA-1", | 
| +    input: "00", | 
| +    output: "5ba93c9db0cff93f52b521d7420e43f6eda2784f" | 
| +  }, | 
| +  { | 
| +    algorithm: "SHA-224", | 
| +    input: "00", | 
| +    output: "fff9292b4201617bdc4d3053fce02734166a683d7d858a7f5f59b073" | 
| +  }, | 
| +  { | 
| +    algorithm: "SHA-256", | 
| +    input: "00", | 
| +    output: "6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d" | 
| +  }, | 
| +  { | 
| +    algorithm: "SHA-384", | 
| +    input: "00", | 
| +    output: "bec021b4f368e3069134e012c2b4307083d3a9bdd206e24e5f0d86e13d6636655933ec2b413465966817a9c208a11717" | 
| +  }, | 
| +  { | 
| +    algorithm: "SHA-512", | 
| +    input: "00", | 
| +    output: "b8244d028981d693af7b456af8efa4cad63d282e19ff14942c246e50d9351d22704a802a71c3580b6370de4ceb293c324a8423342557d4e5c38438f0e36910ee" | 
| +  }, | 
| +  { | 
| +    algorithm: "SHA-1", | 
| +    input: "000102030405", | 
| +    output: "868460d98d09d8bbb93d7b6cdd15cc7fbec676b9" | 
| +  }, | 
| +  { | 
| +    algorithm: "SHA-224", | 
| +    input: "000102030405", | 
| +    output: "7d92e7f1cad1818ed1d13ab41f04ebabfe1fef6bb4cbeebac34c29bc" | 
| +  }, | 
| +  { | 
| +    algorithm: "SHA-256", | 
| +    input: "000102030405", | 
| +    output: "17e88db187afd62c16e5debf3e6527cd006bc012bc90b51a810cd80c2d511f43" | 
| +  }, | 
| +  { | 
| +    algorithm: "SHA-384", | 
| +    input: "000102030405", | 
| +    output: "79f4738706fce9650ac60266675c3cd07298b09923850d525604d040e6e448adc7dc22780d7e1b95bfeaa86a678e4552" | 
| +  }, | 
| +  { | 
| +    algorithm: "SHA-512", | 
| +    input: "000102030405", | 
| +    output: "2f3831bccc94cf061bcfa5f8c23c1429d26e3bc6b76edad93d9025cb91c903af6cf9c935dc37193c04c2c66e7d9de17c358284418218afea2160147aaa912f4c" | 
| +  }, | 
| +]; | 
| + | 
| +// Run each test. | 
| +for (var i = 0; i < kDigestTestVectors.length; ++i) { | 
| +    var testCase = kDigestTestVectors[i]; | 
| +    var promise = crypto.subtle.digest({name: testCase.algorithm}, hexStringToUint8Array(testCase.input)); | 
| +    promise.then(onTestCaseComplete.bind(null, testCase), failAndFinishJSTest); | 
| } | 
|  | 
| -function printAcceptedResult(result) | 
| +function onTestCaseComplete(testCase, result) | 
| { | 
| -    debug("    = " + byteArrayToHexString(new Uint8Array(result))); | 
| +    var testDescription = testCase.algorithm + " of [" + testCase.input + "]"; | 
| +    bytesShouldMatchHexString(testDescription, testCase.output, result); | 
| + | 
| +    // Once the last test has completed, done. | 
| +    if (testCase == kDigestTestVectors[kDigestTestVectors.length - 1]) { | 
| +      finishJSTest(); | 
| +    } | 
| } | 
|  | 
| -Promise.resolve(null).then(function() { | 
| -    debug("SHA1 of []"); | 
| -    return crypto.subtle.digest({name: 'sha-1'}, new Uint8Array([])); | 
| -}).then(function(result) { | 
| -    printAcceptedResult(result); | 
| - | 
| -    debug("SHA1 of [0x0]") | 
| -    return crypto.subtle.digest({name: 'sha-1'}, new Uint8Array([0])); | 
| -}).then(function(result) { | 
| -    printAcceptedResult(result); | 
| - | 
| -    // Pass invalid data to digeset() | 
| -    shouldThrow("crypto.subtle.digest({name: 'sha-1'})"); | 
| -    shouldThrow("crypto.subtle.digest({name: 'sha-1'}, null)"); | 
| -    shouldThrow("crypto.subtle.digest({name: 'sha-1'}, 10)"); | 
| - | 
| -    // Pass invalid algorithmIdentifiers to digest() | 
| -    data = new Uint8Array([0]); | 
| -    shouldThrow("crypto.subtle.digest({name: 'sha'}, data)"); | 
| -    shouldThrow("crypto.subtle.digest(null, data)"); | 
| -    shouldThrow("crypto.subtle.digest({}, data)"); | 
| -}).then(finishJSTest, failAndFinishJSTest); | 
| +// Pass invalid data to digeset() | 
| +shouldThrow("crypto.subtle.digest({name: 'sha-1'})"); | 
| +shouldThrow("crypto.subtle.digest({name: 'sha-1'}, null)"); | 
| +shouldThrow("crypto.subtle.digest({name: 'sha-1'}, 10)"); | 
| + | 
| +// Pass invalid algorithmIdentifiers to digest() | 
| +data = new Uint8Array([0]); | 
| +shouldThrow("crypto.subtle.digest({name: 'sha'}, data)"); | 
| +shouldThrow("crypto.subtle.digest(null, data)"); | 
| +shouldThrow("crypto.subtle.digest({}, data)"); | 
|  | 
| </script> | 
|  | 
|  |