@@ -13,6 +13,16 @@ Value createScope(const CallbackInfo& info) {
1313 return String::New (info.Env (), " scope" );
1414}
1515
16+ Value createScopeFromExisting (const CallbackInfo& info) {
17+ {
18+ napi_handle_scope scope;
19+ napi_open_handle_scope (info.Env (), &scope);
20+ HandleScope scope_existing (info.Env (), scope);
21+ String::New (scope_existing.Env (), " inner-existing-scope" );
22+ }
23+ return String::New (info.Env (), " existing_scope" );
24+ }
25+
1626Value escapeFromScope (const CallbackInfo& info) {
1727 Value result;
1828 {
@@ -22,6 +32,18 @@ Value escapeFromScope(const CallbackInfo& info) {
2232 return result;
2333}
2434
35+ Value escapeFromExistingScope (const CallbackInfo& info) {
36+ Value result;
37+ {
38+ napi_escapable_handle_scope scope;
39+ napi_open_escapable_handle_scope (info.Env (), &scope);
40+ EscapableHandleScope scope_existing (info.Env (), scope);
41+ result = scope_existing.Escape (
42+ String::New (scope_existing.Env (), " inner-existing-scope" ));
43+ }
44+ return result;
45+ }
46+
2547#define LOOP_MAX 1000000
2648Value stressEscapeFromScope (const CallbackInfo& info) {
2749 Value result;
@@ -52,7 +74,11 @@ Object InitHandleScope(Env env) {
5274 Object exports = Object::New (env);
5375
5476 exports[" createScope" ] = Function::New (env, createScope);
77+ exports[" createScopeFromExisting" ] =
78+ Function::New (env, createScopeFromExisting);
5579 exports[" escapeFromScope" ] = Function::New (env, escapeFromScope);
80+ exports[" escapeFromExistingScope" ] =
81+ Function::New (env, escapeFromExistingScope);
5682 exports[" stressEscapeFromScope" ] = Function::New (env, stressEscapeFromScope);
5783 exports[" doubleEscapeFromScope" ] = Function::New (env, doubleEscapeFromScope);
5884
0 commit comments