@@ -58,15 +58,18 @@ namespace nodex {
58
58
if (expression.IsEmpty ())
59
59
RETURN (Undefined ());
60
60
61
+ Local<Context> current_context = Isolate::GetCurrent ()->GetCurrentContext ();
61
62
Local<Context> debug_context = v8::Debug::GetDebugContext ();
62
63
#if (NODE_MODULE_VERSION > 45)
63
64
if (debug_context.IsEmpty ()) {
64
65
// Force-load the debug context.
65
- v8::Debug::GetMirror (info. GetIsolate ()-> GetCurrentContext (), info[ 0 ] );
66
+ v8::Debug::GetMirror (current_context, New<Object>() );
66
67
debug_context = v8::Debug::GetDebugContext ();
67
68
}
68
- #endif
69
69
70
+ // Share security token
71
+ debug_context->SetSecurityToken (current_context->GetSecurityToken ());
72
+ #endif
70
73
Context::Scope context_scope (debug_context);
71
74
72
75
TryCatch tryCatch;
@@ -77,12 +80,39 @@ namespace nodex {
77
80
};
78
81
79
82
static NAN_METHOD (AllowNatives) {
83
+ // TODO: deprecate this useless method
80
84
const char allow_natives_syntax[] = " --allow_natives_syntax" ;
81
85
v8::V8::SetFlagsFromString (allow_natives_syntax, sizeof (allow_natives_syntax) - 1 );
82
86
83
87
RETURN (Undefined ());
84
88
}
85
89
90
+ static NAN_METHOD (ShareSecurityToken) {
91
+ Local<Context> current_context = info.GetIsolate ()->GetCurrentContext ();
92
+ Local<Context> debug_context = v8::Debug::GetDebugContext ();
93
+ #if (NODE_MODULE_VERSION > 45)
94
+ if (debug_context.IsEmpty ()) {
95
+ // Force-load the debug context.
96
+ v8::Debug::GetMirror (current_context, New<Object>());
97
+ debug_context = v8::Debug::GetDebugContext ();
98
+ }
99
+ #endif
100
+ // Share security token
101
+ debug_context->SetSecurityToken (current_context->GetSecurityToken ());
102
+ }
103
+
104
+ static NAN_METHOD (UnshareSecurityToken) {
105
+ Local<Context> current_context = info.GetIsolate ()->GetCurrentContext ();
106
+ Local<Context> debug_context = v8::Debug::GetDebugContext ();
107
+ #if (NODE_MODULE_VERSION > 45)
108
+ if (debug_context.IsEmpty ()) {
109
+ // Force-load the debug context.
110
+ v8::Debug::GetMirror (current_context, New<Object>());
111
+ debug_context = v8::Debug::GetDebugContext ();
112
+ }
113
+ #endif
114
+ debug_context->UseDefaultSecurityToken ();
115
+ }
86
116
private:
87
117
Debug () {}
88
118
~Debug () {}
@@ -97,6 +127,8 @@ namespace nodex {
97
127
SetMethod (target, " sendCommand" , Debug::SendCommand);
98
128
SetMethod (target, " runScript" , Debug::RunScript);
99
129
SetMethod (target, " allowNatives" , Debug::AllowNatives);
130
+ SetMethod (target, " shareSecurityToken" , Debug::ShareSecurityToken);
131
+ SetMethod (target, " unshareSecurityToken" , Debug::UnshareSecurityToken);
100
132
}
101
133
102
134
NODE_MODULE (debug, Initialize)
0 commit comments