Max Maischein > MozRepl-RemoteObject-0.36 > MozRepl::RemoteObject::Methods



Annotate this POD


Open  1
View/Report Bugs
Module Version: 0.36   Source   Latest Release: MozRepl-RemoteObject-0.39


MozRepl::RemoteObject::Methods - Perl methods for mozrepl objects


  my @links = $obj->MozRepl::RemoteObject::Methods::xpath('//a');

This module holds the routines that previously lived as injected object methods on all Javascript objects.


$obj->MozRepl::RemoteObject::Methods::invoke(METHOD, ARGS)

The invoke() object method is an alternate way to invoke Javascript methods. It is normally equivalent to $obj->$method(@ARGS). This function must be used if the METHOD name contains characters not valid in a Perl variable name (like foreign language characters). To invoke a Javascript objects native __invoke method (if such a thing exists), please use:

    $object->MozRepl::RemoteObject::Methods::invoke('__invoke', @args);

This method can be used to call the Javascript functions with the same name as other convenience methods implemented in Perl:



This method transforms the passed in arguments to their JSON string representations.

Things that match /^(?:[1-9][0-9]*|0+)$/ get passed through.

MozRepl::RemoteObject::Instance instances are transformed into strings that resolve to their Javascript global variables. Use the ->expr method to get an object representing these.

It's also impossible to pass a negative or fractional number as a number through to Javascript, or to pass digits as a Javascript string.


Readonly accessor for the internal object id that connects the Javascript object to the Perl object.


Accessor for the callback that gets invoked from DESTROY.


Readonly accessor for the bridge that connects the Javascript object to the Perl object.




Returns a reference to a hash/array/coderef. This is used by overload. Don't use these directly.

$obj->MozRepl::RemoteObject::Methods::xpath( $query [, $ref, $cont ] )

Executes an XPath query and returns the node snapshot result as a list.

This is a convenience method that should only be called on HTMLdocument nodes.

The optional $ref parameter can be a DOM node relative to which a relative XPath expression will be evaluated. It defaults to undef.

The optional $cont parameter can be a Javascript function that will get applied to every result. This can be used to directly map each DOM node in the XPath result to an attribute. For example for efficiently fetching the text value of an XPath query resulting in textnodes, the two snippets are equivalent, but the latter executes less roundtrips between Perl and Javascript:

    my @text = map { $_->{nodeValue} }
        $obj->MozRepl::RemoteObject::Methods::xpath( '//p/text()' )

    my $fetch_nodeValue = $bridge->declare(<<JS);
        function (e){ return e.nodeValue }
    my @text = map { $_->{nodeValue} }
        $obj->MozRepl::RemoteObject::Methods::xpath( '//p/text()', undef, $fetch_nodeValue )

Note that the result type is fetched with XPathResult.ORDERED_NODE_SNAPSHOT_TYPE . There is no support for retrieving results as XPathResult.ANY_TYPE yet.


Convenience method to quickly dive down a property chain.

If any element on the path is missing, the method dies with the error message which element was not found.

This method is faster than descending through the object forest with Perl, but otherwise identical.

  my $obj = $tab->{linkedBrowser}

  my $obj = $tab->MozRepl::RemoteObject::Methods::dive(
      qw(linkedBrowser contentWindow document body)


MozRepl::RemoteObject for the objects to use this with


The public repository of this module is


Max Maischein


Copyright 2011-2012 by Max Maischein


This module is released under the same terms as Perl itself.

syntax highlighting: