Chromium Code Reviews| Index: third_party/WebKit/Source/modules/crypto/CryptoResultImpl.cpp |
| diff --git a/third_party/WebKit/Source/modules/crypto/CryptoResultImpl.cpp b/third_party/WebKit/Source/modules/crypto/CryptoResultImpl.cpp |
| index 7efd0097e99174319967326f84ecda015b77219b..8217f13358e20d257b9a9048b8821bed68fb29f6 100644 |
| --- a/third_party/WebKit/Source/modules/crypto/CryptoResultImpl.cpp |
| +++ b/third_party/WebKit/Source/modules/crypto/CryptoResultImpl.cpp |
| @@ -181,7 +181,21 @@ void CryptoResultImpl::completeWithBuffer(const void* bytes, unsigned bytesSize) |
| if (!m_resolver) |
| return; |
| - m_resolver->resolve(DOMArrayBuffer::create(bytes, bytesSize)); |
| + // TODO(junov): crbug.com/536816 |
| + // Instead of crashing when array buffer allocation fails, we could |
| + // and probably should use DOMArrayBuffer::createOrNull and reject |
| + // the promise with a RangeError exception when crewation returns null. |
|
haraken
2015/10/29 18:58:37
creation
Justin Novosad
2015/11/05 00:17:52
Done.
|
| + // The specs for all crypto methods that use this code state: "If the |
| + // following steps or referenced procedures say to throw an error, |
| + // reject promise with the returned error and then terminate the algorithm." |
| + // In this case, the procedure of allocating an ArrayBuffer is not explicitly |
| + // referenced in the algorithms laid out in the spec, but one could argue |
| + // that it is implied, and the ECMAScript spec says that failure to |
| + // allocate the buffer should result in a RangeError being thrown. |
| + // http://ecma-international.org/ecma-262/6.0/#sec-createbytedatablock |
| + // The crypto spec probably needs to be edited to be more explicit about |
| + // this issue. |
| + m_resolver->resolve(DOMArrayBuffer::deprecatedCreateOrCrash(bytes, bytesSize)); |
| clearResolver(); |
| } |