I got some findings, here is the code:

sub js_call_to_perl_struct { my ($self,$js,$context) = @_; $context ||= ''; $self->{stats}->{roundtrip}++; my $repl = $self->repl; if (! $repl) { # Likely during global destruction return }; my $queue = join '', map( { /;$/? $_ : "$_;" } map { s/\s*$//; $_ } @{ + $self->queue }); @{ $self->queue } = (); #warn "<<$js>>"; my @js; if ($queue) { push @js, $self->repl_API('q', $queue); }; push @js, $self->repl_API('ejs', $js, $context ); $js = join ";", @js; if (defined wantarray) { #warn $js; # When going async, we would want to turn this into a callback my $res = $self->execute_command($js); $res =~ s/^(?:\.+\>\s+)+//g; while ($res !~ /\S/) { # Gobble up continuation prompts warn "No result yet from repl"; $res = $self->execute_command(";"); # no-op $res =~ s/^(?:\.+\>\s+)+//g; }; my $d = $self->to_perl($res); if ($d->{status} eq 'ok') { return $d->{result} } else { croak ((ref $self).": $d->{name}: $d->{message}"); }; } else { #warn "Executing $js"; # When going async, we would want to turn this into a callback # This produces additional, bogus prompts... $self->execute_command($js); () }; };

Where in the code :

my $res = $self->execute_command($js);
$js is:

repl.ejs(" var f=function() {\n var wm = Components.classes[\"@mozilla.org/appshell/window-mediator;1\ +"]\n.getService(Components.interfaces.nsIWindowMediator);\n var win = wm.getMostRecentWindow('navigator:browser');\n if (! win) {\n// No browser windows are open, so open a new one.\n + win = window.open('about:blank');\n };\n return win.getBrowser()\n }\n;\n; f","" );
In firefox7.0, after command execution, the return value $res is:

"{"status":"ok", "result":{"result":1,"type":"function"} }"

But in firefox 8,it returns something different: "8.0!"?!? Thats why it fails always. Any solutions?

In reply to Re^7: RemoteObject.pm fails in open firefox8.0 by seven_shen
in thread RemoteObject.pm fails in open firefox8.0 by seven_shen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.