Skip to content

Commit f81c34e

Browse files
committed
Version 5.1.281.24 (cherry-pick)
Merged 93c60dc [api] Expose ES6 7.3.14 SetIntegrityLevel on v8::Object BUG=v8:4846 LOG=N [email protected] Review URL: https://codereview.chromium.org/1940483002 . Cr-Commit-Position: refs/branch-heads/5.1@{#28} Cr-Branched-From: 167dc63-refs/heads/5.1.281@{#1} Cr-Branched-From: 03953f5-refs/heads/master@{#35282}
1 parent 666366b commit f81c34e

4 files changed

Lines changed: 41 additions & 1 deletion

File tree

include/v8-version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
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.)

include/v8.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff 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

src/api.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff 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

39143927
Maybe<bool> v8::Object::Delete(Local<Context> context, Local<Value> key) {
39153928
PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Delete()", bool);

test/cctest/test-api.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
2498925007
TEST(PrivateForApiIsNumber) {
2499025008
LocalContext context;
2499125009
v8::Isolate* isolate = CcTest::isolate();

0 commit comments

Comments
 (0)