@@ -15,9 +15,9 @@ $v8_helper = new PhpV8Helpers($helper);
1515
1616require '.tracking_dtors.php ' ;
1717
18- $ isolate = new v8Tests \TrackingDtors \Isolate ();
18+ $ isolate = new v8Tests \TrackingDtors \Isolate ();
1919$ global_template = new V8 \ObjectTemplate ($ isolate );
20- $ context = new V8 \Context ($ isolate , $ global_template );
20+ $ context = new V8 \Context ($ isolate , $ global_template );
2121
2222
2323$ func = new v8Tests \TrackingDtors \FunctionObject ($ context , function (\V8 \FunctionCallbackInfo $ info ) {
@@ -33,24 +33,32 @@ $helper->space();
3333$ helper ->assert ('FunctionObject extends ObjectValue ' , $ func instanceof \V8 \ObjectValue);
3434$ helper ->assert ('FunctionObject implements AdjustableExternalMemoryInterface ' , $ func instanceof \V8 \AdjustableExternalMemoryInterface);
3535$ helper ->assert ('FunctionObject is instanceof Function ' , $ func ->instanceOf ($ context , $ context ->globalObject ()->get ($ context , new \V8 \StringValue ($ isolate , 'Function ' ))));
36+ $ helper ->assert ('Function created from php holds no script id ' , $ func ->getScriptId () === null );
3637$ helper ->line ();
3738
3839$ v8_helper ->run_checks ($ func , 'Checkers ' );
3940
4041$ context ->globalObject ()->set ($ context , new \V8 \StringValue ($ isolate , 'print ' ), $ func );
4142
42- $ source = 'print("Hello, world"); delete print; "Script done" ' ;
43+ $ source = 'print("Hello, world"); delete print; "Script done" ' ;
4344$ file_name = 'test.js ' ;
4445
4546
4647$ script = new V8 \Script ($ context , new \V8 \StringValue ($ isolate , $ source ), new \V8 \ScriptOrigin ($ file_name ));
4748
4849$ helper ->dump ($ script ->run ($ context )->toString ($ context )->value ());
50+
51+ $ helper ->assert ('Function created from php still holds no script id after been passed to script ' , $ func ->getScriptId () === null );
52+
4953$ helper ->line ();
5054
5155$ helper ->dump_object_methods ($ func , [], new ArrayMapFilter (['getScriptOrigin ' => true ]));
5256$ helper ->line ();
5357
58+ $ helper ->line ();
59+ $ fnc2 = $ v8_helper ->CompileRun ($ context , 'function test() {}; test ' );
60+ $ helper ->assert ('Function from script holds script id ' , $ fnc2 ->getScriptId () !== null );
61+
5462echo 'We are done for now ' , PHP_EOL ;
5563
5664?>
@@ -73,6 +81,7 @@ object(v8Tests\TrackingDtors\FunctionObject)#6 (2) {
7381FunctionObject extends ObjectValue: ok
7482FunctionObject implements AdjustableExternalMemoryInterface: ok
7583FunctionObject is instanceof Function: ok
84+ Function created from php holds no script id: ok
7685
7786Checkers:
7887---------
@@ -132,17 +141,18 @@ v8Tests\TrackingDtors\FunctionObject(V8\Value)->isProxy(): bool(false)
132141
133142Should output Hello World string
134143string(11) "Script done"
144+ Function created from php still holds no script id after been passed to script: ok
135145
136146v8Tests\TrackingDtors\FunctionObject(V8\FunctionObject)->getScriptOrigin():
137- object(V8\ScriptOrigin)#128 (6) {
147+ object(V8\ScriptOrigin)#129 (6) {
138148 ["resource_name":"V8\ScriptOrigin":private]=>
139149 string(0) ""
140150 ["resource_line_offset":"V8\ScriptOrigin":private]=>
141151 int(0)
142152 ["resource_column_offset":"V8\ScriptOrigin":private]=>
143153 int(0)
144154 ["options":"V8\ScriptOrigin":private]=>
145- object(V8\ScriptOriginOptions)#132 (4) {
155+ object(V8\ScriptOriginOptions)#133 (4) {
146156 ["is_shared_cross_origin":"V8\ScriptOriginOptions":private]=>
147157 bool(false)
148158 ["is_opaque":"V8\ScriptOriginOptions":private]=>
@@ -158,6 +168,8 @@ v8Tests\TrackingDtors\FunctionObject(V8\FunctionObject)->getScriptOrigin():
158168 string(0) ""
159169 }
160170
171+
172+ Function from script holds script id: ok
161173We are done for now
162174FunctionObject dies now!
163175Isolate dies now!
0 commit comments