mirror of
https://github.com/phpv8/v8js.git
synced 2024-12-23 04:51:53 +00:00
de23e8dba4
This way the PHP script can handle V8 errors gracefully (and e.g. provide feedback to the user). This especially changes behaviour when circular extension dependencies happen (PHP code can go on, just V8 fails to start). This also fixes memory leaks of V8 and V8Js itself caused by bailing out directly otherwise.
46 lines
956 B
PHP
46 lines
956 B
PHP
--TEST--
|
|
Test V8::registerExtension() : Circular dependencies
|
|
--SKIPIF--
|
|
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
|
--FILE--
|
|
<?php
|
|
|
|
V8Js::registerExtension('a', 'print("A");', array('b'));
|
|
V8Js::registerExtension('b', 'print("B");', array('a'));
|
|
|
|
var_dump(V8JS::getExtensions());
|
|
|
|
$a = new V8Js('myobj', array(), array('a'));
|
|
?>
|
|
--EXPECTF--
|
|
array(2) {
|
|
["a"]=>
|
|
array(2) {
|
|
["auto_enable"]=>
|
|
bool(false)
|
|
["deps"]=>
|
|
array(1) {
|
|
[0]=>
|
|
string(1) "b"
|
|
}
|
|
}
|
|
["b"]=>
|
|
array(2) {
|
|
["auto_enable"]=>
|
|
bool(false)
|
|
["deps"]=>
|
|
array(1) {
|
|
[0]=>
|
|
string(1) "a"
|
|
}
|
|
}
|
|
}
|
|
|
|
Warning: Fatal V8 error in v8::Context::New(): Circular extension dependency in %s on line 8
|
|
|
|
Fatal error: Uncaught V8JsException: Failed to create V8 context. Check that registered extensions do not have errors. in %s:8
|
|
Stack trace:
|
|
#0 %s(8): V8Js->__construct('myobj', Array, Array)
|
|
#1 {main}
|
|
thrown in %s on line 8
|