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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/DictionaryIterator.cpp

Issue 2496533002: binding: Makes Dictionary handle a possible exception in [[Get]]. (Closed)
Patch Set: Fixed a coding style. Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/Dictionary.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/DictionaryIterator.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/DictionaryIterator.cpp b/third_party/WebKit/Source/bindings/core/v8/DictionaryIterator.cpp
index 444d225dcc84a911e16534a61787fd4dea01e32f..a3c4898dd7a7cfeb2d2f867414afc917488e148a 100644
--- a/third_party/WebKit/Source/bindings/core/v8/DictionaryIterator.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/DictionaryIterator.cpp
@@ -28,22 +28,33 @@ bool DictionaryIterator::next(ExecutionContext* executionContext,
ExceptionState& exceptionState) {
DCHECK(!isNull());
+ v8::TryCatch tryCatch(m_isolate);
+ v8::Local<v8::Context> context = m_isolate->GetCurrentContext();
+
v8::Local<v8::Value> next;
- // TODO(alancutter): Support callable objects as well as functions.
- if (!v8Call(m_iterator->Get(m_isolate->GetCurrentContext(), m_nextKey),
- next) ||
- !next->IsFunction()) {
+ if (!m_iterator->Get(context, m_nextKey).ToLocal(&next)) {
+ CHECK(!tryCatch.Exception().IsEmpty());
+ exceptionState.rethrowV8Exception(tryCatch.Exception());
+ m_done = true;
+ return false;
+ }
+ if (!next->IsFunction()) {
exceptionState.throwTypeError("Expected next() function on iterator.");
m_done = true;
return false;
}
v8::Local<v8::Value> result;
- if (!v8Call(V8ScriptRunner::callFunction(v8::Local<v8::Function>::Cast(next),
- executionContext, m_iterator, 0,
- nullptr, m_isolate),
- result) ||
- !result->IsObject()) {
+ if (!V8ScriptRunner::callFunction(v8::Local<v8::Function>::Cast(next),
+ executionContext, m_iterator, 0, nullptr,
+ m_isolate)
+ .ToLocal(&result)) {
+ CHECK(!tryCatch.Exception().IsEmpty());
+ exceptionState.rethrowV8Exception(tryCatch.Exception());
+ m_done = true;
+ return false;
+ }
+ if (!result->IsObject()) {
exceptionState.throwTypeError(
"Expected iterator.next() to return an Object.");
m_done = true;
@@ -51,19 +62,23 @@ bool DictionaryIterator::next(ExecutionContext* executionContext,
}
v8::Local<v8::Object> resultObject = v8::Local<v8::Object>::Cast(result);
- m_value = resultObject->Get(m_isolate->GetCurrentContext(), m_valueKey);
+ m_value = resultObject->Get(context, m_valueKey);
+ if (m_value.IsEmpty()) {
+ CHECK(!tryCatch.Exception().IsEmpty());
+ exceptionState.rethrowV8Exception(tryCatch.Exception());
+ }
v8::Local<v8::Value> done;
- if (v8Call(resultObject->Get(m_isolate->GetCurrentContext(), m_doneKey),
- done)) {
- v8::Local<v8::Boolean> doneBoolean;
- m_done =
- v8Call(done->ToBoolean(m_isolate->GetCurrentContext()), doneBoolean)
- ? doneBoolean->Value()
- : false;
- } else {
- m_done = false;
+ v8::Local<v8::Boolean> doneBoolean;
+ if (!resultObject->Get(context, m_doneKey).ToLocal(&done) ||
+ !done->ToBoolean(context).ToLocal(&doneBoolean)) {
+ CHECK(!tryCatch.Exception().IsEmpty());
+ exceptionState.rethrowV8Exception(tryCatch.Exception());
+ m_done = true;
+ return false;
}
+
+ m_done = doneBoolean->Value();
return !m_done;
}
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/Dictionary.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698