Skip to content

Commit

Permalink
Test results changed in issue phpv8#72 patch.
Browse files Browse the repository at this point in the history
There is a minor change to how properties of V8Js subclasses are exposed to
JavaScript: subclass properties are *not* visible to JS by default.

More significantly, all values exposed to JavaScript are fully mutable.
  • Loading branch information
cscott committed Oct 29, 2013
1 parent 81d4418 commit 7090291
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
3 changes: 2 additions & 1 deletion tests/derived_class_properties_init.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ class V8Wrapper extends V8Js {

$v8 = new V8Wrapper();
echo($v8->testing."\n");
// These are all properties of V8Wrapper, not exported to V8
$v8->executeString('print(PHP.testing + "\n");');
$v8->executeString('print(PHP.protectedVar + "\n");');
$v8->executeString('print(PHP.privateVar + "\n");');
?>
===EOF===
--EXPECT--
23
23
undefined
undefined
undefined
===EOF===
13 changes: 7 additions & 6 deletions tests/get_accessor.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ $JS = <<<'EOT'
print(typeof $foobar + "\n"); // Undefined
print(myobj.$foobar + "\n"); // Undefined (in 1st run!)
print(myobj.$_SERVER['REQUEST_TIME'] + "\n");
myobj.$foobar = 'CHANGED'; // should be read only!
myobj.$foobar = 'CHANGED'; // read-write from JS
print(myobj.$foobar + "\n"); // Undefined (in 1st run!)
EOT;

$a = new V8Js("myobj", array('$_SERVER' => '_SERVER', '$foobar' => 'myfoobar'));
$myfoobar = 'undefined';

$a = new V8Js("myobj", array('_SERVER' => &$_SERVER, 'foobar' => &$myfoobar));
$a->executeString($JS, "test1.js");

$myfoobar = 'myfoobarfromphp';

$a->executeString($JS, "test2.js");

// Check that variables do not get in object ..
var_dump($a->myfoobar, $a->foobar);

?>
Expand All @@ -31,11 +32,11 @@ var_dump($a->myfoobar, $a->foobar);
undefined
undefined
%d
undefined
CHANGED
undefined
myfoobarfromphp
%d
myfoobarfromphp
NULL
CHANGED
NULL
string(7) "CHANGED"
===EOF===
6 changes: 3 additions & 3 deletions tests/variable_passing.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function dump(a)
function test()
{
var a = 'From PHP: ' + PHP.somevar;
PHP.somevar = 'changed in JS!'; // Should not change..
PHP.somevar = 'changed in JS!';
dump(PHP.myarray);
Expand All @@ -42,7 +42,7 @@ $a->myarray = array(

$a->executeString($JS, "test.js");

// Check that variable has not been modified
// Check that variable was successfully modified
var_dump($a->somevar);
?>
===EOF===
Expand All @@ -54,5 +54,5 @@ d => value for key D
From PHP: From PHP with love!
123
3.14
string(19) "From PHP with love!"
string(14) "changed in JS!"
===EOF===

0 comments on commit 7090291

Please sign in to comment.