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

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: Added TODO comments + updated a test expectation. 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
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..dc4c32d31a59b62a49a2e49b0856fe20097478bb 100644
--- a/third_party/WebKit/Source/bindings/core/v8/DictionaryIterator.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/DictionaryIterator.cpp
@@ -28,12 +28,17 @@ bool DictionaryIterator::next(ExecutionContext* executionContext,
ExceptionState& exceptionState) {
DCHECK(!isNull());
+ v8::TryCatch tryCatch(m_isolate);
+
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()) {
- exceptionState.throwTypeError("Expected next() function on iterator.");
+ if (tryCatch.HasCaught()) {
+ exceptionState.rethrowV8Exception(tryCatch.Exception());
+ } else {
+ exceptionState.throwTypeError("Expected next() function on iterator.");
+ }
m_done = true;
return false;
}
@@ -44,8 +49,12 @@ bool DictionaryIterator::next(ExecutionContext* executionContext,
nullptr, m_isolate),
result) ||
!result->IsObject()) {
- exceptionState.throwTypeError(
- "Expected iterator.next() to return an Object.");
+ if (tryCatch.HasCaught()) {
+ exceptionState.rethrowV8Exception(tryCatch.Exception());
+ } else {
+ exceptionState.throwTypeError(
+ "Expected iterator.next() to return an Object.");
+ }
m_done = true;
return false;
}
@@ -64,6 +73,9 @@ bool DictionaryIterator::next(ExecutionContext* executionContext,
} else {
m_done = false;
}
+ if (tryCatch.HasCaught()) {
+ exceptionState.rethrowV8Exception(tryCatch.Exception());
+ }
return !m_done;
}

Powered by Google App Engine
This is Rietveld 408576698