File Coverage

lib/HTML/Object/DOM/Element/IFrame.pm
Criterion Covered Total %
statement 22 51 43.1
branch 0 8 0.0
condition 0 2 0.0
subroutine 8 23 34.7
pod 14 14 100.0
total 44 98 44.9


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## HTML Object - ~/lib/HTML/Object/DOM/Element/IFrame.pm
3             ## Version v0.2.0
4             ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2021/12/23
7             ## Modified 2022/09/18
8             ## All rights reserved
9             ##
10             ##
11             ## This program is free software; you can redistribute it and/or modify it
12             ## under the same terms as Perl itself.
13             ##----------------------------------------------------------------------------
14             package HTML::Object::DOM::Element::IFrame;
15             BEGIN
16             {
17 1     1   1078 use strict;
  1         3  
  1         47  
18 1     1   6 use warnings;
  1         3  
  1         28  
19 1     1   5 use parent qw( HTML::Object::DOM::Element );
  1         1  
  1         5  
20 1     1   124 use vars qw( $VERSION );
  1         2  
  1         41  
21 1     1   15 use HTML::Object::DOM::Element::Shared qw( :iframe );
  1         3  
  1         157  
22 1     1   19 our $VERSION = 'v0.2.0';
23             };
24              
25 1     1   7 use strict;
  1         2  
  1         35  
26 1     1   10 use warnings;
  1         3  
  1         611  
27              
28             sub init
29             {
30 0     0 1   my $self = shift( @_ );
31 0           $self->{allowfullscreen} = 0;
32 0           $self->{_init_strict_use_sub} = 1;
33 0 0         $self->SUPER::init( @_ ) || return( $self->pass_error );
34 0 0         $self->{tag} = 'iframe' if( !CORE::length( "$self->{tag}" ) );
35             $self->_set_get_internal_attribute_callback( sandbox => sub
36             {
37 0     0     my( $this, $val ) = @_;
38 0           my $list;
39 0 0         return if( !( $list = $this->{_sanbox_list} ) );
40             # $list->debug( $self->debug );
41 0           $list->update( $val );
42 0           });
43 0           return( $self );
44             }
45              
46             # Note: property attribute align inherited
47              
48             # Note: property attribute
49 0     0 1   sub allow : lvalue { return( shift->_set_get_property( 'allow', @_ ) ); }
50              
51             # Note: property
52 0     0 1   sub allowfullscreen : lvalue { return( shift->_set_get_boolean( 'allowfullscreen', @_ ) ); }
53              
54             # TODO: property; fetch remote content and return a HTML::Object::DOM::Document object
55 0     0 1   sub contentDocument { return; }
56              
57             # Note: property does nothing
58 0     0 1   sub contentWindow : lvalue { return( shift->_set_get_object_lvalue( 'contentwindow', 'HTML::Object::DOM::WindowProxy', @_ ) ); }
59              
60             # Note: property
61 0     0 1   sub csp : lvalue { return( shift->_set_get_property( 'csp', @_ ) ); }
62              
63             # Note: property
64 0     0 1   sub featurePolicy { return; }
65              
66             # Note: property
67 0     0 1   sub frameBorder : lvalue { return( shift->_set_get_property( 'frameborder', @_ ) ); }
68              
69             # Note: property height inherited
70              
71             # Note: property
72 0     0 1   sub longDesc : lvalue { return( shift->_set_get_property( 'longdesc', @_ ) ); }
73              
74             # Note: property
75 0     0 1   sub marginHeight : lvalue { return( shift->_set_get_property( 'marginheight', @_ ) ); }
76              
77             # Note: property
78 0     0 1   sub marginWidth : lvalue { return( shift->_set_get_property( 'marginwidth', @_ ) ); }
79              
80             # Note: property name inherited
81              
82             # Note: property referrerPolicy inherited
83              
84             # Note: property read-only
85             sub sandbox
86             {
87 0     0 1   my $self = shift( @_ );
88 0 0         unless( $self->{_sanbox_list} )
89             {
90 0           my $sandbox = $self->attr( 'sandbox' );
91 0           require HTML::Object::TokenList;
92 0   0       $self->{_sanbox_list} = HTML::Object::TokenList->new( $sandbox, element => $self, attribute => 'sandbox', debug => $self->debug ) ||
93             return( $self->pass_error( HTML::Object::TokenList->error ) );
94             }
95 0           return( $self->{_sanbox_list} );
96             }
97              
98             # Note: property
99 0     0 1   sub scrolling : lvalue { return( shift->_set_get_property( 'scrolling', @_ ) ); }
100              
101             # Note: property src inherited
102              
103             # Note: property
104 0     0 1   sub srcdoc : lvalue { return( shift->_set_get_property( 'srcdoc', @_ ) ); }
105              
106             # Note: property width inherited
107              
108             1;
109             # NOTE: POD
110             __END__
111              
112             =encoding utf-8
113              
114             =head1 NAME
115              
116             HTML::Object::DOM::Element::IFrame - HTML Object DOM iFrame Class
117              
118             =head1 SYNOPSIS
119              
120             use HTML::Object::DOM::Element::IFrame;
121             my $iframe = HTML::Object::DOM::Element::IFrame->new ||
122             die( HTML::Object::DOM::Element::IFrame->error, "\n" );
123              
124             =head1 VERSION
125              
126             v0.2.0
127              
128             =head1 DESCRIPTION
129              
130             The L<HTML::Object::DOM::Element::IFrame> interface provides special properties and methods (beyond those of the L<HTML::Object::Element> interface it also has available to it by inheritance) for manipulating the layout and presentation of inline frame elements.
131              
132             =head1 INHERITANCE
133              
134             +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +------------------------------------+
135             | HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::IFrame |
136             +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +------------------------------------+
137              
138             =head1 PROPERTIES
139              
140             Inherits properties from its parent L<HTML::Object::DOM::Element>
141              
142             =head2 align
143              
144             Provided with a string and this set or get the attribute that specifies the alignment of the frame with respect to the surrounding context.
145              
146             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLiFrameElement/align>
147              
148             =head2 allow
149              
150             A list of origins the frame is allowed to display content from. This attribute also accepts the values self and src which represent the origin in the iframe's src attribute. The default value is src.
151              
152             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLiFrameElement/allow>
153              
154             =head2 allowfullscreen
155              
156             A boolean value indicating whether the inline frame is willing to be placed into full screen mode. See Using full-screen mode for details. This defaults to false.
157              
158             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLiFrameElement/allowfullscreen>
159              
160             =head2 contentDocument
161              
162             This does nothing and returns C<undef> under perl environment.
163              
164             In JavaScript environment, this returns a C<Document>, the active document in the inline frame's nested browsing context.
165              
166             Maybe, in the future, this could fetch the remote page at the specified url, parse the html and return its L<HTML::Object::DOM> object?
167              
168             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/contentDocument>
169              
170             =head2 contentWindow
171              
172             Normally this returns C<undef> under perl, but you can set a L<HTML::Object::DOM::WindowProxy> object.
173              
174             In JavaScript environment, this returns a C<WindowProxy>, the window proxy for the nested browsing context.
175              
176             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/contentWindow>
177              
178             =head2 csp
179              
180             Provided with a value and this sets or gets the attribute that specifies the Content Security Policy that an embedded document must agree to enforce upon itself.
181              
182             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/csp>
183              
184             =head2 featurePolicy
185              
186             Read-only.
187              
188             This does nothing and returns C<undef> under perl environment.
189              
190             In JavaScript environment, this returns the C<FeaturePolicy> interface which provides a simple API for introspecting the feature policies applied to a specific document.
191              
192             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/featurePolicy>
193              
194             =head2 frameBorder
195              
196             Provided with a string (C<yes> or C<no>) or a integer (1 or 0) and this will set or get the HTML attribute to indicate whether to create borders between frames.
197              
198             Example:
199              
200             $iframe->frameBorder = 1;
201              
202             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLiFrameElement/frameBorder>
203              
204             =head2 height
205              
206             A string that reflects the height HTML attribute, indicating the height of the frame.
207              
208             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLiFrameElement/height>
209              
210             =head2 longDesc
211              
212             A string that contains the URI of a long description of the frame.
213              
214             Example:
215              
216             <img src="some_pic.png" id="myPicture" height="1024" width="512" longdesc="/some/where/longdescription.html" />
217              
218             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLiFrameElement/longDesc>
219              
220             =head2 marginHeight
221              
222             A string being the height of the frame margin.
223              
224             Example:
225              
226             <iframe src="/some/where" frameborder="0" name="resource" title="Resource" marginheight="10">
227              
228             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLiFrameElement/marginHeight>
229              
230             =head2 marginWidth
231              
232             A string being the width of the frame margin.
233              
234             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLiFrameElement/marginWidth>
235              
236             =head2 name
237              
238             A string that reflects the name HTML attribute, containing a name by which to refer to the frame.
239              
240             Example:
241              
242             <iframe src="/some/where" frameborder="0" name="resource" title="Resource" marginheight="10">
243              
244             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLiFrameElement/name>
245              
246             =head2 referrerPolicy
247              
248             A string that reflects the C<referrerpolicy> HTML attribute indicating which referrer to use when fetching the linked resource.
249              
250             You can use whatever value you want, but the values supported by web browser are:
251              
252             =over 4
253              
254             =item C<no-referrer>
255              
256             This means that the C<Referer> HTTP header will not be sent.
257              
258             =item C<origin>
259              
260             This means that the referrer will be the origin of the page, that is roughly the scheme, the host and the port.
261              
262             =item C<unsafe-url>
263              
264             This means that the referrer will include the origin and the path (but not the fragment, password, or username). This case is unsafe as it can leak path information that has been concealed to third-party by using TLS.
265              
266             =back
267              
268             Example:
269              
270             my $iframe = $doc->createElement("iframe");
271             $iframe->src = '/';
272             $iframe->referrerPolicy = "unsafe-url";
273             my $body = $doc->getElementsByTagName('body')[0];
274             $body->appendChild($iframe); # Fetch the image using the complete URL as the referrer
275              
276             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/referrerPolicy>
277              
278             =head2 sandbox
279              
280             Read-only.
281              
282             A L<TokenList|HTML::Object::DOM::TokenList> object that reflects the sandbox HTML attribute, indicating extra restrictions on the behavior of the nested content.
283              
284             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLiFrameElement/sandbox>
285              
286             =head2 scrolling
287              
288             Provided with a string (C<true> or C<false>) and this set or gets a string that indicates whether the browser should provide scrollbars for the frame.
289              
290             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLiFrameElement/scrolling>
291              
292             =head2 src
293              
294             A string that reflects the src HTML attribute, containing the address of the content to be embedded. Note that programmatically removing an <iframe>'s src attribute (e.g. via L<HTML::Object::DOM::Element/emoveAttribute>) causes about:blank to be loaded in the frame in Firefox (from version 65), Chromium-based browsers, and Safari/iOS.
295              
296             Example:
297              
298             my $iframe = $doc->createElement( 'iframe' );
299             $iframe->src = '/';
300             my $body = $doc->getElementsByTagName( 'body' )->[0];
301             $body->appendChild( $iframe ); # Fetch the image using the complete URL as the referrer
302              
303             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/src>
304              
305             =head2 srcdoc
306              
307             This does nothing and returns C<undef> under perl environment.
308              
309             In JavaScript environment, this sets a string that represents the content to display in the frame.
310              
311             Example:
312              
313             var iframe = document.createElement("iframe");
314             iframe.srcdoc = `<!DOCTYPE html><p>Hello World!</p>`;
315             document.body.appendChild(iframe);
316              
317             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/srcdoc>
318              
319             =head2 width
320              
321             A string that reflects the width HTML attribute, indicating the width of the frame.
322              
323             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLiFrameElement/width>
324              
325             =head1 METHODS
326              
327             Inherits methods from its parent L<HTML::Object::DOM::Element>
328              
329             =head1 AUTHOR
330              
331             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
332              
333             =head1 SEE ALSO
334              
335             L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement>, L<Mozilla documentation on iframe element|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe>
336              
337             =head1 COPYRIGHT & LICENSE
338              
339             Copyright(c) 2021 DEGUEST Pte. Ltd.
340              
341             All rights reserved
342              
343             This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
344              
345             =cut