| 1 | package Firefox::Application::API36; | ||
| 2 | use strict; | ||
| 3 | use parent 'Firefox::Application'; | ||
| 4 | use Firefox::Application::API35; | ||
| 5 | our $VERSION = '0.80'; | ||
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | Firefox::Application::API36 - API wrapper for Firefox 3.6+ | ||
| 10 | |||
| 11 | =head1 SYNOPSIS | ||
| 12 | |||
| 13 | use Firefox::Application; | ||
| 14 | my $ff = Firefox::Application->new( | ||
| 15 | # Force the Firefox 3.5 API | ||
| 16 | api => 'Firefox::Application::API35', | ||
| 17 | ); | ||
| 18 | |||
| 19 | =head1 METHODS | ||
| 20 | |||
| 21 | =head2 C<< $api->updateitems( %args ) >> | ||
| 22 | |||
| 23 | for my $item ($api->updateitems) { | ||
| 24 | print sprintf "Name: %s\n", $item->{name}; | ||
| 25 | print sprintf "Version: %s\n", $item->{version}; | ||
| 26 | print sprintf "GUID: %s\n", $item->{id}; | ||
| 27 | }; | ||
| 28 | |||
| 29 | Returns the list of updateable items. Under Firefox 4, | ||
| 30 | can be restricted by the C<type> option. | ||
| 31 | |||
| 32 | =over 4 | ||
| 33 | |||
| 34 | =item * C<type> - type of items to fetch | ||
| 35 | |||
| 36 | C<ANY> - fetch any item | ||
| 37 | |||
| 38 | C<ADDON> - fetch add-ons | ||
| 39 | |||
| 40 | C<LOCALE> - fetch locales | ||
| 41 | |||
| 42 | C<THEME> - fetch themes | ||
| 43 | |||
| 44 | =back | ||
| 45 | |||
| 46 | =cut | ||
| 47 | |||
| 48 | sub import_from_api35 { | ||
| 49 | my ($name) = @_; | ||
| 50 | no strict 'refs'; | ||
| 51 | *{"$name"} = \&{ "Firefox::Application::API35::$name" }; | ||
| 52 | }; | ||
| 53 | |||
| 54 | import_from_api35($_) | ||
| 55 | for (qw(updateitems addons themes locales | ||
| 56 | selectedTab addTab autoclose_tab closeTab openTabs | ||
| 57 | )); | ||
| 58 | |||
| 59 | =head2 C<< $ff->closeTab( $tab [,$repl] ) >> | ||
| 60 | |||
| 61 | $ff->closeTab( $tab ); | ||
| 62 | |||
| 63 | Close the given tab. | ||
| 64 | |||
| 65 | =cut | ||
| 66 | |||
| 67 | =head2 C<< $api->element_query( \@elements, \%attributes ) >> | ||
| 68 | |||
| 69 | my $query = $element_query(['input', 'select', 'textarea'], | ||
| 70 | { name => 'foo' }); | ||
| 71 | |||
| 72 | Returns the XPath query that searches for all elements with C<tagName>s | ||
| 73 | in C<@elements> having the attributes C<%attributes>. The C<@elements> | ||
| 74 | will form an C<or> condition, while the attributes will form an C<and> | ||
| 75 | condition. | ||
| 76 | |||
| 77 | =cut | ||
| 78 | |||
| 79 | sub element_query { | ||
| 80 | my ($self, $elements, $attributes) = @_; | ||
| 81 | my $query = | ||
| 82 | './/*[(' . | ||
| 83 | join( ' or ', | ||
| 84 | map { | ||
| 85 | sprintf qq{local-name(.)="%s"}, lc $_ | ||
| 86 | } @$elements | ||
| 87 | ) | ||
| 88 | . ') and ' | ||
| 89 | . join( " and ", | ||
| 90 | map { sprintf q{@%s="%s"}, $_, $attributes->{$_} } | ||
| 91 | sort keys(%$attributes) | ||
| 92 | ) | ||
| 93 | . ']'; | ||
| 94 | }; | ||
| 95 | |||
| 96 | 1; | ||
| 97 | |||
| 98 | =head1 AUTHOR | ||
| 99 | |||
| 100 | Max Maischein C<corion@cpan.org> | ||
| 101 | |||
| 102 | =head1 COPYRIGHT (c) | ||
| 103 | |||
| 104 | Copyright 2009-2014 by Max Maischein C<corion@cpan.org>. | ||
| 105 | |||
| 106 | =head1 LICENSE | ||
| 107 | |||
| 108 | This module is released under the same terms as Perl itself. | ||
| 109 | |||
| 110 | =cut |