extensions_error.phpt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. --TEST--
  2. Test V8::registerExtension() : Register extension with errors
  3. --SKIPIF--
  4. <?php
  5. require_once(dirname(__FILE__) . '/skipif.inc');
  6. ob_start(NULL, 0, PHP_OUTPUT_HANDLER_CLEANABLE | PHP_OUTPUT_HANDLER_REMOVABLE);
  7. phpinfo(INFO_MODULES);
  8. $minfo = ob_get_contents();
  9. ob_end_clean();
  10. if(strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
  11. // On Windows the "Fatal error" happens to appear before the error
  12. // message output by V8 itself.
  13. echo "skip Windows";
  14. }
  15. if(preg_match("/V8 Engine Linked Version => (.*)/", $minfo, $matches)) {
  16. $version = explode('.', $matches[1]);
  17. if($version[0] < 3 || ($version[0] == 3 && $version[1] < 30)) {
  18. // old v8 version, has shorter error message and hence doesn't
  19. // fit our EXCEPTF below
  20. echo "skip";
  21. }
  22. }
  23. ?>
  24. --FILE--
  25. <?php
  26. $handlebarsJs = "var root = typeof global !== 'undefined' ? global : window, \$Handlebars = 'test';";
  27. echo "-- registerExtension --\n";
  28. V8Js::registerExtension('handlebars', $handlebarsJs, [], true);
  29. echo "-- creating V8Js object --\n";
  30. $v8 = new V8Js();
  31. var_dump($v8);
  32. ?>
  33. ===EOF===
  34. --EXPECTF--
  35. -- registerExtension --
  36. -- creating V8Js object --
  37. Exception thrown during bootstrapping
  38. Extension or internal compilation error%sin handlebars at line 1.
  39. Error installing extension 'handlebars'.
  40. Fatal error: Uncaught V8JsException: Failed to create V8 context. Check that registered extensions do not have errors. in %s%eextensions_error.php:7
  41. Stack trace:
  42. #0 %s%eextensions_error.php(7): V8Js->__construct()
  43. #1 {main}
  44. thrown in %s%eextensions_error.php on line 7