OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 // Defined when linking against shared lib on Windows. | 6 // Defined when linking against shared lib on Windows. |
7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) | 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) |
8 #define V8_SHARED | 8 #define V8_SHARED |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 Local<Context> context = Context::New(isolate, NULL, global_template); | 541 Local<Context> context = Context::New(isolate, NULL, global_template); |
542 if (context.IsEmpty()) { | 542 if (context.IsEmpty()) { |
543 DCHECK(try_catch.HasCaught()); | 543 DCHECK(try_catch.HasCaught()); |
544 try_catch.ReThrow(); | 544 try_catch.ReThrow(); |
545 return; | 545 return; |
546 } | 546 } |
547 data->realms_[index].Reset(isolate, context); | 547 data->realms_[index].Reset(isolate, context); |
548 args.GetReturnValue().Set(index); | 548 args.GetReturnValue().Set(index); |
549 } | 549 } |
550 | 550 |
| 551 // Realm.makeSameOrigin(i) sets the security token of i to that of the |
| 552 // current realm. |
| 553 void Shell::RealmMakeSameOrigin( |
| 554 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 555 Isolate* isolate = args.GetIsolate(); |
| 556 PerIsolateData* data = PerIsolateData::Get(isolate); |
| 557 int index = data->RealmIndexOrThrow(args, 0); |
| 558 if (index == -1) return; |
| 559 if (index == 0 || index == data->realm_current_ || |
| 560 index == data->realm_switch_) { |
| 561 Throw(args.GetIsolate(), "Invalid realm index"); |
| 562 return; |
| 563 } |
| 564 |
| 565 data->realms_[index].Get(isolate)->SetSecurityToken( |
| 566 isolate->GetEnteredContext()->GetSecurityToken()); |
| 567 } |
551 | 568 |
552 // Realm.dispose(i) disposes the reference to the realm i. | 569 // Realm.dispose(i) disposes the reference to the realm i. |
553 void Shell::RealmDispose(const v8::FunctionCallbackInfo<v8::Value>& args) { | 570 void Shell::RealmDispose(const v8::FunctionCallbackInfo<v8::Value>& args) { |
554 Isolate* isolate = args.GetIsolate(); | 571 Isolate* isolate = args.GetIsolate(); |
555 PerIsolateData* data = PerIsolateData::Get(isolate); | 572 PerIsolateData* data = PerIsolateData::Get(isolate); |
556 int index = data->RealmIndexOrThrow(args, 0); | 573 int index = data->RealmIndexOrThrow(args, 0); |
557 if (index == -1) return; | 574 if (index == -1) return; |
558 if (index == 0 || | 575 if (index == 0 || |
559 index == data->realm_current_ || index == data->realm_switch_) { | 576 index == data->realm_current_ || index == data->realm_switch_) { |
560 Throw(args.GetIsolate(), "Invalid realm index"); | 577 Throw(args.GetIsolate(), "Invalid realm index"); |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 FunctionTemplate::New(isolate, RealmOwner)); | 1146 FunctionTemplate::New(isolate, RealmOwner)); |
1130 realm_template->Set( | 1147 realm_template->Set( |
1131 String::NewFromUtf8(isolate, "global", NewStringType::kNormal) | 1148 String::NewFromUtf8(isolate, "global", NewStringType::kNormal) |
1132 .ToLocalChecked(), | 1149 .ToLocalChecked(), |
1133 FunctionTemplate::New(isolate, RealmGlobal)); | 1150 FunctionTemplate::New(isolate, RealmGlobal)); |
1134 realm_template->Set( | 1151 realm_template->Set( |
1135 String::NewFromUtf8(isolate, "create", NewStringType::kNormal) | 1152 String::NewFromUtf8(isolate, "create", NewStringType::kNormal) |
1136 .ToLocalChecked(), | 1153 .ToLocalChecked(), |
1137 FunctionTemplate::New(isolate, RealmCreate)); | 1154 FunctionTemplate::New(isolate, RealmCreate)); |
1138 realm_template->Set( | 1155 realm_template->Set( |
| 1156 String::NewFromUtf8(isolate, "makeSameOrigin", NewStringType::kNormal) |
| 1157 .ToLocalChecked(), |
| 1158 FunctionTemplate::New(isolate, RealmMakeSameOrigin)); |
| 1159 realm_template->Set( |
1139 String::NewFromUtf8(isolate, "dispose", NewStringType::kNormal) | 1160 String::NewFromUtf8(isolate, "dispose", NewStringType::kNormal) |
1140 .ToLocalChecked(), | 1161 .ToLocalChecked(), |
1141 FunctionTemplate::New(isolate, RealmDispose)); | 1162 FunctionTemplate::New(isolate, RealmDispose)); |
1142 realm_template->Set( | 1163 realm_template->Set( |
1143 String::NewFromUtf8(isolate, "switch", NewStringType::kNormal) | 1164 String::NewFromUtf8(isolate, "switch", NewStringType::kNormal) |
1144 .ToLocalChecked(), | 1165 .ToLocalChecked(), |
1145 FunctionTemplate::New(isolate, RealmSwitch)); | 1166 FunctionTemplate::New(isolate, RealmSwitch)); |
1146 realm_template->Set( | 1167 realm_template->Set( |
1147 String::NewFromUtf8(isolate, "eval", NewStringType::kNormal) | 1168 String::NewFromUtf8(isolate, "eval", NewStringType::kNormal) |
1148 .ToLocalChecked(), | 1169 .ToLocalChecked(), |
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2526 } | 2547 } |
2527 | 2548 |
2528 } // namespace v8 | 2549 } // namespace v8 |
2529 | 2550 |
2530 | 2551 |
2531 #ifndef GOOGLE3 | 2552 #ifndef GOOGLE3 |
2532 int main(int argc, char* argv[]) { | 2553 int main(int argc, char* argv[]) { |
2533 return v8::Shell::Main(argc, argv); | 2554 return v8::Shell::Main(argc, argv); |
2534 } | 2555 } |
2535 #endif | 2556 #endif |
OLD | NEW |