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

Unified Diff: src/d8.cc

Issue 1973363004: Expose a way to make a "same-origin" realm (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add a test Created 4 years, 7 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
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 9466ab7d3a727c2fe12d70ac977df0b0cac57f35..2f6f28bb1015932c96c588e47e6d86c13a0238b3 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -548,6 +548,23 @@ void Shell::RealmCreate(const v8::FunctionCallbackInfo<v8::Value>& args) {
args.GetReturnValue().Set(index);
}
+// Realm.makeSameOrigin(i) sets the security token of i to that of the
+// current realm.
+void Shell::RealmMakeSameOrigin(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ Isolate* isolate = args.GetIsolate();
+ PerIsolateData* data = PerIsolateData::Get(isolate);
+ int index = data->RealmIndexOrThrow(args, 0);
+ if (index == -1) return;
+ if (index == 0 || index == data->realm_current_ ||
+ index == data->realm_switch_) {
+ Throw(args.GetIsolate(), "Invalid realm index");
+ return;
+ }
+
+ data->realms_[index].Get(isolate)->SetSecurityToken(
+ isolate->GetEnteredContext()->GetSecurityToken());
+}
// Realm.dispose(i) disposes the reference to the realm i.
void Shell::RealmDispose(const v8::FunctionCallbackInfo<v8::Value>& args) {
@@ -1136,6 +1153,10 @@ Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
.ToLocalChecked(),
FunctionTemplate::New(isolate, RealmCreate));
realm_template->Set(
+ String::NewFromUtf8(isolate, "makeSameOrigin", NewStringType::kNormal)
+ .ToLocalChecked(),
+ FunctionTemplate::New(isolate, RealmMakeSameOrigin));
+ realm_template->Set(
String::NewFromUtf8(isolate, "dispose", NewStringType::kNormal)
.ToLocalChecked(),
FunctionTemplate::New(isolate, RealmDispose));
« src/d8.h ('K') | « src/d8.h ('k') | test/mjsunit/realm-property-access.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698