diff options
Diffstat (limited to 'Source/WebCore/bindings/js/JSCryptoCustom.cpp')
-rw-r--r-- | Source/WebCore/bindings/js/JSCryptoCustom.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/Source/WebCore/bindings/js/JSCryptoCustom.cpp b/Source/WebCore/bindings/js/JSCryptoCustom.cpp index 9d1177146..a71b71aeb 100644 --- a/Source/WebCore/bindings/js/JSCryptoCustom.cpp +++ b/Source/WebCore/bindings/js/JSCryptoCustom.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2012 Google Inc. All rights reserved. + * Copyright (C) 2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -25,8 +26,9 @@ #include "config.h" #include "JSCrypto.h" -#include "ExceptionCode.h" - +#include "JSDOMConvertBufferSource.h" +#include "JSDOMExceptionHandling.h" +#include <heap/HeapInlines.h> #include <runtime/ArrayBufferView.h> #include <runtime/Error.h> #include <runtime/JSArrayBufferView.h> @@ -35,23 +37,20 @@ using namespace JSC; namespace WebCore { -JSValue JSCrypto::getRandomValues(ExecState* exec) +JSValue JSCrypto::getRandomValues(ExecState& state) { - if (exec->argumentCount() < 1) - return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec)); + VM& vm = state.vm(); + auto scope = DECLARE_THROW_SCOPE(vm); - JSValue buffer = exec->argument(0); - RefPtr<ArrayBufferView> arrayBufferView = toArrayBufferView(buffer); - if (!arrayBufferView) - return throwTypeError(exec); + if (state.argumentCount() < 1) + return throwException(&state, scope, createNotEnoughArgumentsError(&state)); - ExceptionCode ec = 0; - impl().getRandomValues(arrayBufferView.get(), ec); + JSValue buffer = state.argument(0); + auto arrayBufferView = toUnsharedArrayBufferView(vm, buffer); + if (!arrayBufferView) + return throwTypeError(&state, scope); - if (ec) { - setDOMException(exec, ec); - return jsUndefined(); - } + propagateException(state, scope, wrapped().getRandomValues(*arrayBufferView)); return buffer; } |