Subject: | property_by_path() doesn't work as expected |
distribution name: JavaScript-SpiderMonkey-0.11
perl version: v5.8.7 built for i386-linux-thread-multi
operating system: Linux hst2 2.6.8-1-386 #1 Mon Sep 13 23:29:55 EDT 2004 i686 GNU/Linux
Function property_by_path() doesn't work as expected. The following perl code emits segmentation fault:
use JavaScript::SpiderMonkey;
my $js = JavaScript::SpiderMonkey->new();
$js->init();
$js->property_by_path('a.a');
$js->eval('a.a = 1');
Another problem that property_by_path() modifies parent objects in
property path to Global object. This is completely unexpected behaviour:
my $js = JavaScript::SpiderMonkey->new();
$js->init();
$js->function_set("alert", sub { print shift(@_) . "\n"; });
# creates object [a] with Object property [b], which has Number property
[c] with value [123].
$js->eval('a = {b:{c:123}};');
# try to setup getter handler on a.b.innerHTML
$js->property_by_path('a.b.innerHTML', 'test', sub { print "getter\n";}
);
# check elements of object [a]
$js->eval('alert(a.b.innerHTML)'); # prints "getter\ntest\n". All ok
$js->eval('alert(a.b.c)'); # prints "undefined". Expected "123"
$js->eval('alert(a.b)'); # prints "object Global". Expected "object
Object"
$js->eval('alert(a)'); # prints "object Global". Expected "object
Object"