seven_shen has asked for the wisdom of the Perl Monks concerning the following question:

Test with firefox 8.0b4, RemoteObject.pm reports error always.

The code is:

$ffpath='C:\\Program Files\\Mozilla Firefox\\firefox.exe'; $mech = WWW::Mechanize::Firefox>new(tab=>'current',activate=>1,launch= +>$ffpath); $mech->get('about:blank');

The error output is:

Transport still not UTF-8 safe: "8.0!"?!? at C:/Perl/site/lib/MozRepl/RemoteOb ject.pm line 522, <DATA> line 1. (Sub)string is [8.0!"锟?!锟絔 at C:/Perl/site/lib/MozRepl/RemoteObject.pm line 2 52, <DATA> line 1.

Any solutions?

Replies are listed 'Best First'.
Re: RemoteObject.pm fails in open firefox8.0
by spazm (Monk) on Oct 26, 2011 at 09:41 UTC
    At a minimum, you're missing a dash between Firefox and >new. Let's assume that was introduced while typing into the perlmonk form. I don't have Firefox installed, so I can't help further.

    $ffpath='C:\\Program Files\\Mozilla Firefox\\firefox.exe'; $mech = WWW::Mechanize::Firefox->new( tab =>'current', activate =>1, launch =>$ffpath ); $mech->get('about:blank');

    The CHANGES file for MozRepl::RemoteObject lists Firefox 7 Beta 5 as the most recent browser tested.

        + The module is now tested with
            Firefox 3.0.9
            Firefox 3.5.x
            Firefox 4.0.1
            Firefox 5
            Firefox 6.0.1
            Firefox 7 Beta 5
    

      Yes, the latest firefox 8.0 was not in test list. But how to fix this?

        1. view the source. Line 522. Do you see a likely path to fixing it? If so then move on to
        2. Check the Repository section of the documentation for a pointer to the best way to download the source.
        3. Check the repo to see if there are newer changes that haven't been pushed. (there aren't).
        4. clone the sources from github: http://github.com/Corion/mozrepl-remoteobject, patch and push back to author.
        git clone http://github.com/Corion/mozrepl-remoteobject cd mozrepl-remoteobject make test # make changes # ...
        apologies if I've gone in to too little or too much detail.

        It looks like the test uses MozRepl::Plugin::JSON2 and sends a unicode string through the pipeline to see if it comes out cleanly. It doesn't. So either the problem is in MozRepl::Plugin::JSON2, firefox 8 or MozRepl::RemoteObject.

        Edit: I almost forgot to suggest Write a bug report. Since the author doesn't mention his rt.cpan queue in the documentation, I'd suggest creating a new issue in the github issue tracker for the repository.

        The next option is to write a nice note to the author and inquire as to the status of Firefox8 support.

        Dear $authorname,

        I am a fan of your module $module. I use it to solve $my_use_case.

        I see in the Changes file that Firefox8 is not listed as a currently tested browser. Is FF8 on the roadmap? How can I help test and move this feature forward?

        Thank you again for your awesome module.

        sincerely,
        $yourname

        You could also disable that safety check and see if it runs otherwise and make sure to use all 7-bit clean ascii. If you go this route, you'll be uncharted territory and responsible if things Just Don't Work(tm).

        Have fun!

Re: RemoteObject.pm fails in open firefox8.0
by Corion (Patriarch) on Oct 26, 2011 at 18:04 UTC

    That output is not an error, it's just a warning message from MozRepl::RemoteObject because it tried to make the transport between Firefox and Perl UTF-8 safe, but the transport was not made UTF-8 safe.

    As Firefox 8 is still in beta and has no portable version available, I can't test this.

      The error should happen in following code

      ... warn sprintf "(Sub)string is [%s]", substr($js,$offset,20); die $@ ...

      The function is:

      # Take a JSON response and convert it to a Perl data structure sub to_perl { my ($self,$js) = @_; local $_ = $js; #s/^(\.+\>\s*)+//; # remove Mozrepl continuation prompts s/^"//; s/"$//; if (/\.+>/) { # This should now be eliminated! die "Continuation prompt found in [$_]"; } #warn $js; # reraise JS errors from perspective of caller if (/^!!!\s+(.*)$/m) { croak "MozRepl::RemoteObject: $1"; }; if (! /\S/) { # We got an empty string back from the REPL ... warn "Got empty string from REPL"; return; } # In the case that we don't have a unicode string # already, decode the string from UTF-8 $js = decode('UTF-8', $_); #warn "[[$_]]"; my $res; local $@; my $json = $self->json; if (! eval { $res = $json->decode($js); #use Data::Dumper; #warn Dumper $res; 1 }) { my $err = $@; my $offset; if ($err =~ /character offset (\d+)\b/) { $offset = $1 }; $offset -= 10; $offset = 0 if $offset < 0; warn sprintf "(Sub)string is [%s]", substr($js,$offset,20); die $@ }; $res };

      As i remember, with previous firefox releases(6.0,5.0,4.0), i encounter this problem occasionally. Now it happens always in firefox 8. How could avoid this problem?

        Ah - this error occurs, because the JSON string is malformed. Most likely because the JSON string includes UTF-8, but the transport is not UTF-8 safe, as the warning message upon initialization says.

        As I said, I can't test it because Firefox 8 is in beta and not available as a portable installation. My recommendation is to avoid pages that need encoding outside the 7-bit ASCII characters.

        You could tell me what version of MozRepl::RemoteObject and WWW::Mechanize::Firefox and what version of the mozrepl plugin for Firefox you use. There are branches of mozrepl with UTF-8 safe transport, and I wonder why installing my own UTF-8-safe transport fails. But, again, I don't have your version of Firefox and thus can't test it.

Re: RemoteObject.pm fails in open firefox8.0
by Corion (Patriarch) on Nov 04, 2011 at 07:26 UTC

    The mozrepl plug-in just received some updates regarding script caching. These might be related to your problem.

    But this makes me wonder how you installed MozRepl::RemoteObject. Did it ever pass its test suite on Firefox 8? If it didn't pass its test suite, why do you expect it to work?

      It was installed by ppm install before.

      And it never pass any testing suite on FF8(8.0b1~8.0b6)! But it works under FF3.6~FF7.

      For me now I need to find a solution to automate FF8, even it is under beta developing. This is helpful for me(Maybe also other firefox developers).

      And back to the cause, I now could almost see the problem may come to firefox 8.0 final release in the future. In that case, fixing the problem will be urgently enough. So bring investigation forward for this issue might be a nice suggestion.

        Hi, after updating mozrepl to the latest one as you mentioned, now it works!

        This is quite exciting!

        Thanks a lot!