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

Unified Diff: src/objects.cc

Issue 1809233002: Throw exceptions from CreateDataProperty when should_throw (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: brackets Created 4 years, 9 months 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 | « src/objects.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 4a44e661de59c04c63cc1e5bb498c51ca6bc88f8..14030599eca246cbc11378ca7fe80df5e7153fc5 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -6707,7 +6707,7 @@ Maybe<bool> JSReceiver::CreateDataProperty(LookupIterator* it,
Isolate* isolate = receiver->GetIsolate();
if (receiver->IsJSObject()) {
- return JSObject::CreateDataProperty(it, value); // Shortcut.
+ return JSObject::CreateDataProperty(it, value, should_throw); // Shortcut.
}
PropertyDescriptor new_desc;
@@ -6720,17 +6720,26 @@ Maybe<bool> JSReceiver::CreateDataProperty(LookupIterator* it,
&new_desc, should_throw);
}
-
Maybe<bool> JSObject::CreateDataProperty(LookupIterator* it,
- Handle<Object> value) {
+ Handle<Object> value,
+ ShouldThrow should_throw) {
DCHECK(it->GetReceiver()->IsJSObject());
MAYBE_RETURN(JSReceiver::GetPropertyAttributes(it), Nothing<bool>());
+ Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(it->GetReceiver());
+ Isolate* isolate = receiver->GetIsolate();
if (it->IsFound()) {
- if (!it->IsConfigurable()) return Just(false);
+ if (!it->IsConfigurable()) {
+ RETURN_FAILURE(
+ isolate, should_throw,
+ NewTypeError(MessageTemplate::kRedefineDisallowed, it->GetName()));
+ }
} else {
- if (!JSObject::IsExtensible(Handle<JSObject>::cast(it->GetReceiver())))
- return Just(false);
+ if (!JSObject::IsExtensible(Handle<JSObject>::cast(it->GetReceiver()))) {
+ RETURN_FAILURE(
+ isolate, should_throw,
+ NewTypeError(MessageTemplate::kDefineDisallowed, it->GetName()));
+ }
}
RETURN_ON_EXCEPTION_VALUE(it->isolate(),
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698