exception_propagation_3.phpt 949 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. --TEST--
  2. Test V8::executeString() : Exception propagation test 3
  3. --SKIPIF--
  4. <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
  5. --FILE--
  6. <?php
  7. class Foo {
  8. private $v8 = NULL;
  9. public function __construct()
  10. {
  11. $this->v8 = new V8Js(null, array(), array(), false);
  12. $this->v8->foo = $this;
  13. $this->v8->executeString('function foobar() { throw new SyntaxError(); }', 'throw_1');
  14. $this->v8->executeString('try { foobar(); } catch (e) { print(e + " caught in JS!\n"); }', 'trycatch1');
  15. $this->v8->executeString('try { PHP.foo.bar(); } catch (e) { print(e + " caught via PHP callback!\n"); }', 'trycatch2');
  16. }
  17. public function bar()
  18. {
  19. echo "To Bar!\n";
  20. $this->v8->executeString('throw new Error();', 'throw_2');
  21. }
  22. }
  23. try {
  24. $foo = new Foo();
  25. } catch (V8JsScriptException $e) {
  26. echo "PHP Exception: ", $e->getMessage(), "\n";
  27. }
  28. ?>
  29. ===EOF===
  30. --EXPECT--
  31. SyntaxError caught in JS!
  32. To Bar!
  33. Error caught via PHP callback!
  34. ===EOF===