blib/lib/HTML/Object/DOM/Element/IFrame.pm untested

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