File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111#define V8_MAJOR_VERSION 5
1212#define V8_MINOR_VERSION 1
1313#define V8_BUILD_NUMBER 281
14- #define V8_PATCH_LEVEL 23
14+ #define V8_PATCH_LEVEL 24
1515
1616// Use 1 for candidates and 0 otherwise.
1717// (Boolean macro values are not supported by all preprocessors.)
Original file line number Diff line number Diff line change @@ -2637,6 +2637,10 @@ enum AccessControl {
26372637 PROHIBITS_OVERWRITING = 1 << 2
26382638};
26392639
2640+ /**
2641+ * Integrity level for objects.
2642+ */
2643+ enum class IntegrityLevel { kFrozen, kSealed };
26402644
26412645/**
26422646 * A JavaScript object (ECMA-262, 4.3.3)
@@ -2828,6 +2832,11 @@ class V8_EXPORT Object : public Value {
28282832 */
28292833 Local<String> GetConstructorName();
28302834
2835+ /**
2836+ * Sets the integrity level of the object.
2837+ */
2838+ Maybe<bool> SetIntegrityLevel(Local<Context> context, IntegrityLevel level);
2839+
28312840 /** Gets the number of internal fields for this Object. */
28322841 int InternalFieldCount();
28332842
Original file line number Diff line number Diff line change @@ -3910,6 +3910,19 @@ Local<String> v8::Object::GetConstructorName() {
39103910 return Utils::ToLocal (name);
39113911}
39123912
3913+ Maybe<bool > v8::Object::SetIntegrityLevel (Local<Context> context,
3914+ IntegrityLevel level) {
3915+ PREPARE_FOR_EXECUTION_PRIMITIVE (context, " v8::Object::SetIntegrityLevel()" ,
3916+ bool );
3917+ auto self = Utils::OpenHandle (this );
3918+ i::JSReceiver::IntegrityLevel i_level =
3919+ level == IntegrityLevel::kFrozen ? i::FROZEN : i::SEALED;
3920+ Maybe<bool > result =
3921+ i::JSReceiver::SetIntegrityLevel (self, i_level, i::Object::DONT_THROW);
3922+ has_pending_exception = result.IsNothing ();
3923+ RETURN_ON_FAILED_EXECUTION_PRIMITIVE (bool );
3924+ return result;
3925+ }
39133926
39143927Maybe<bool > v8::Object::Delete (Local<Context> context, Local<Value> key) {
39153928 PREPARE_FOR_EXECUTION_PRIMITIVE (context, " v8::Object::Delete()" , bool );
Original file line number Diff line number Diff line change @@ -24986,6 +24986,24 @@ TEST(MemoryPressure) {
2498624986 CHECK(!CcTest::i_isolate()->heap()->ShouldOptimizeForMemoryUsage());
2498724987}
2498824988
24989+ TEST(SetIntegrityLevel) {
24990+ LocalContext context;
24991+ v8::Isolate* isolate = CcTest::isolate();
24992+ v8::HandleScope scope(isolate);
24993+
24994+ v8::Local<v8::Object> obj = v8::Object::New(isolate);
24995+ CHECK(context->Global()->Set(context.local(), v8_str("o"), obj).FromJust());
24996+
24997+ v8::Local<v8::Value> is_frozen = CompileRun("Object.isFrozen(o)");
24998+ CHECK(!is_frozen->BooleanValue(context.local()).FromJust());
24999+
25000+ CHECK(obj->SetIntegrityLevel(context.local(), v8::IntegrityLevel::kFrozen)
25001+ .FromJust());
25002+
25003+ is_frozen = CompileRun("Object.isFrozen(o)");
25004+ CHECK(is_frozen->BooleanValue(context.local()).FromJust());
25005+ }
25006+
2498925007TEST(PrivateForApiIsNumber) {
2499025008 LocalContext context;
2499125009 v8::Isolate* isolate = CcTest::isolate();
You can’t perform that action at this time.
0 commit comments