File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Test V8Js::setModuleLoader : Module source naming
3
+ --SKIPIF--
4
+ <?php require_once (dirname (__FILE__ ) . '/skipif.inc ' ); ?>
5
+ --FILE--
6
+ <?php
7
+
8
+ $ JS = <<< EOT
9
+ require('./foo//bar');
10
+ EOT ;
11
+
12
+ $ v8 = new V8Js ();
13
+ $ v8 ->setModuleLoader (function ($ module ) {
14
+ // return code with syntax errors to provoke script exception
15
+ return "foo(blar); " ;
16
+ });
17
+
18
+ try {
19
+ $ v8 ->executeString ($ JS , 'commonjs_source_naming.js ' );
20
+ } catch (V8JsScriptException $ e ) {
21
+ var_dump ($ e ->getJsFileName ());
22
+ }
23
+ ?>
24
+ ===EOF===
25
+ --EXPECT--
26
+ string(7) "foo/bar"
27
+ ===EOF===
Original file line number Diff line number Diff line change @@ -326,7 +326,7 @@ V8JS_METHOD(require)
326
326
// Enter the module context
327
327
v8::Context::Scope scope (context);
328
328
// Set script identifier
329
- v8::Local<v8::String> sname = V8JS_SYM (" require " );
329
+ v8::Local<v8::String> sname = V8JS_SYM (normalised_module_id );
330
330
331
331
v8::Local<v8::String> source = V8JS_STRL (Z_STRVAL_P (module_code), Z_STRLEN_P (module_code));
332
332
zval_ptr_dtor (&module_code);
You can’t perform that action at this time.
0 commit comments