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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/Dictionary.cpp

Issue 2520273002: binding: Makes Dictionary::hasProperty rethrow an exception. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 if (dictionaryObject->IsObject()) { 50 if (dictionaryObject->IsObject()) {
51 m_valueType = ValueType::Object; 51 m_valueType = ValueType::Object;
52 m_dictionaryObject = dictionaryObject.As<v8::Object>(); 52 m_dictionaryObject = dictionaryObject.As<v8::Object>();
53 return; 53 return;
54 } 54 }
55 55
56 exceptionState.throwTypeError( 56 exceptionState.throwTypeError(
57 "The dictionary provided is neither undefined, null nor an Object."); 57 "The dictionary provided is neither undefined, null nor an Object.");
58 } 58 }
59 59
60 bool Dictionary::hasProperty(const StringView& key) const { 60 bool Dictionary::hasProperty(const StringView& key,
61 ExceptionState& exceptionState) const {
61 if (m_dictionaryObject.IsEmpty()) 62 if (m_dictionaryObject.IsEmpty())
62 return false; 63 return false;
63 64
64 // TODO(bashi,yukishiino): Should rethrow the exception. 65 v8::TryCatch tryCatch(m_isolate);
65 // Has() on a revoked proxy will throw an exception. 66 bool hasKey = false;
66 // http://crbug.com/666661 67 if (!m_dictionaryObject->Has(v8Context(), v8String(m_isolate, key))
67 return v8CallBoolean( 68 .To(&hasKey)) {
68 m_dictionaryObject->Has(v8Context(), v8String(m_isolate, key))); 69 exceptionState.rethrowV8Exception(tryCatch.Exception());
70 return false;
71 }
72
73 return hasKey;
69 } 74 }
70 75
71 DictionaryIterator Dictionary::getIterator( 76 DictionaryIterator Dictionary::getIterator(
72 ExecutionContext* executionContext) const { 77 ExecutionContext* executionContext) const {
73 v8::Local<v8::Value> iteratorGetter; 78 v8::Local<v8::Value> iteratorGetter;
74 if (!getInternal(v8::Symbol::GetIterator(m_isolate), iteratorGetter) || 79 if (!getInternal(v8::Symbol::GetIterator(m_isolate), iteratorGetter) ||
75 !iteratorGetter->IsFunction()) 80 !iteratorGetter->IsFunction())
76 return nullptr; 81 return nullptr;
77 v8::Local<v8::Value> iterator; 82 v8::Local<v8::Value> iterator;
78 if (!v8Call(V8ScriptRunner::callFunction( 83 if (!v8Call(V8ScriptRunner::callFunction(
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 if (!v8CallBoolean(m_dictionaryObject->Has(v8Context(), key))) 181 if (!v8CallBoolean(m_dictionaryObject->Has(v8Context(), key)))
177 continue; 182 continue;
178 TOSTRING_DEFAULT(V8StringResource<>, stringKey, key, false); 183 TOSTRING_DEFAULT(V8StringResource<>, stringKey, key, false);
179 names.append(stringKey); 184 names.append(stringKey);
180 } 185 }
181 186
182 return true; 187 return true;
183 } 188 }
184 189
185 } // namespace blink 190 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698