Class: Dommy::HTMLIFrameElement
- Inherits:
-
HTMLElement
- Object
- Element
- HTMLElement
- Dommy::HTMLIFrameElement
- Defined in:
- lib/dommy/html_elements.rb
Constant Summary
Constants inherited from Element
Element::ADJACENT_POSITIONS, Element::APPROX_CHAR_PX, Element::APPROX_LINE_PX, Element::ATTRIBUTE_NODE, Element::CDATA_SECTION_NODE, Element::COMMENT_NODE, Element::DOCUMENT_FRAGMENT_NODE, Element::DOCUMENT_NODE, Element::DOCUMENT_POSITION_CONTAINED_BY, Element::DOCUMENT_POSITION_CONTAINS, Element::DOCUMENT_POSITION_DISCONNECTED, Element::DOCUMENT_POSITION_FOLLOWING, Element::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, Element::DOCUMENT_POSITION_PRECEDING, Element::DOCUMENT_TYPE_NODE, Element::ELEMENT_NODE, Element::HTML_NAMESPACE, Element::INLINE_TAGS, Element::PROCESSING_INSTRUCTION_NODE, Element::REFLECTED_TOKEN_LIST_HOSTS, Element::SHADOW_HOST_TAGS, Element::SVG_NAMESPACE, Element::TEXT_NODE
Constants included from Node
Node::ATTRIBUTE_NODE, Node::CDATA_SECTION_NODE, Node::COMMENT_NODE, Node::DOCUMENT_FRAGMENT_NODE, Node::DOCUMENT_NODE, Node::DOCUMENT_POSITION_CONTAINED_BY, Node::DOCUMENT_POSITION_CONTAINS, Node::DOCUMENT_POSITION_DISCONNECTED, Node::DOCUMENT_POSITION_FOLLOWING, Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, Node::DOCUMENT_POSITION_PRECEDING, Node::DOCUMENT_TYPE_NODE, Node::ELEMENT_NODE, Node::HTML_NAMESPACE, Node::PROCESSING_INSTRUCTION_NODE, Node::TEXT_NODE, Node::XMLNS_NAMESPACE, Node::XML_NAMESPACE
Instance Attribute Summary
Attributes inherited from Element
Instance Method Summary collapse
- #__internal_set_content_document__(doc) ⇒ Object
- #__js_get__(key) ⇒ Object
- #__js_set__(key, value) ⇒ Object
-
#build_blank_content_document ⇒ Object
Build the blank nested document + its Window, back-linking the Window to this frame (so getComputedStyle can detect a non-rendered frame's content).
-
#content_document ⇒ Object
The nested browsing context's document.
- #content_window ⇒ Object
- #height ⇒ Object
- #height=(v) ⇒ Object
- #width ⇒ Object
- #width=(v) ⇒ Object
Methods inherited from HTMLElement
#case_sensitive_attribute_names?, #disabled_by_ancestor_fieldset?, #labels_node_list, #parse_non_negative_reflected, #set_non_negative_reflected
Methods included from Internal::ReflectedAttributes
Methods inherited from Element
#[], #[]=, #__dommy_backend_node__, #__internal_approx_box, #__internal_case_sensitive_attribute_names__?, #__internal_created_namespace__, #__internal_normalize_attr_key__, #__internal_set_namespace__, #__internal_shadow_root__, #__js_attribute_snapshot__, #__js_call__, #__run_click_activation_behavior__, #__test_scroll_log__, #access_key_label, #accessibility_tree, #activation_behavior, #activation_target, #activation_target?, #after, #anchor_href, #animate, #approximate_layout?, #aria_content_attr, #aria_element_attr, #aria_element_get, #aria_element_set, #aria_elements_attr, #aria_elements_current, #aria_elements_get, #aria_elements_set, #aria_find_in_root, #aria_get, #aria_ref_in_valid_scope?, #aria_set, #aria_snapshot, #assigned_slot, #at_xpath, #attach_shadow, #attributes, #base_uri, #before, #blur, #child_element_count, #child_nodes, #children, #class_list, #class_name, #class_name=, #clear_aria_element_ref_for, #click, #clone_node, #closest, #computed_description, #computed_label, #computed_role, #contains?, #dataset, #element_prefix, #equal_node?, #first_child, #first_element_child, #focus, #get_animations, #get_attribute, #get_attribute_names, #get_attribute_node, #get_attribute_node_ns, #get_attribute_ns, #get_bounding_client_rect, #get_client_rects, #get_elements_by_class_name, #get_elements_by_tag_name, #get_elements_by_tag_name_ns, #get_html, #get_inner_html, #has_attribute?, #has_attribute_ns?, #has_attributes?, #has_child_nodes?, #hide_popover, #id, #id=, #initialize, #inner_html, #inner_html=, #insert_adjacent_element, #insert_adjacent_html, #insert_adjacent_text, #insert_before, #insertion_parent!, #is_connected?, #last_child, #last_element_child, #live_child_nodes, #local_name, #mark_fragment_scripts_started, #matches?, #namespace_uri, #next_element_sibling, #next_sibling, #on, #outer_html, #outer_html=, #owner_document, #parent_element, #parent_node, #path, #pre_click_activation_state, #previous_element_sibling, #previous_sibling, #query_selector, #query_selector_all, #reflected_attr_name, #reflected_token_list, #remove, #remove_attribute, #remove_attribute_node, #remove_attribute_ns, #remove_child, #replace_child, #replace_with_nodes, #request_fullscreen, #restore_pre_click_activation, #role, #role=, #root_node, #run_post_click_activation, #same_node?, #set_attribute, #set_attribute_node, #set_attribute_ns, #shadow_root, #show_popover, #slot, #slot=, #style, #tag_name, #text_content, #text_content=, #to_s, #toggle_attribute, #toggle_popover, #translate_mode?, #validate_adjacent_document_insert!, #with_selector_errors, #xpath
Methods included from Bridge::Methods
Methods included from Internal::ParentNode
#append, #append_child, #normalize, #prepend, #replace_children
Methods included from Internal::ChildNode
#child_node_after, #child_node_before, #child_node_replace_with, #nullable_dom_string, #validate_insert_before_ref!
Methods included from Node
#compare_document_position, #get_root_node, #is_default_namespace, #is_equal_node, #is_same_node, #lookup_namespace_uri, #lookup_prefix
Methods included from EventTarget
#__dommy_dump_event_failure__, #__internal_deliver_event__, #__internal_event_parent__, #__internal_process_event_handler_return__, #add_event_listener, capture_flag, #deliver_at, #dispatch_event, #event_name_from_on, #invoke_listener_isolated, js_truthy?, #on_handler, #remove_event_listener, #set_on_handler
Constructor Details
This class inherits a constructor from Dommy::Element
Instance Method Details
#__internal_set_content_document__(doc) ⇒ Object
4279 4280 4281 4282 4283 4284 4285 |
# File 'lib/dommy/html_elements.rb', line 4279 def __internal_set_content_document__(doc) @content_document = doc # Back-link the nested window to its hosting frame, so getComputedStyle can # detect content inside a non-rendered (display:none / disconnected) frame. view = doc.respond_to?(:default_view) ? doc.default_view : nil view.frame_element = self if view.respond_to?(:frame_element=) end |
#__js_get__(key) ⇒ Object
4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 |
# File 'lib/dommy/html_elements.rb', line 4293 def __js_get__(key) case key when "width" width when "height" height when "contentDocument" content_document when "contentWindow" content_window when "sandbox" # JS-side `iframe.sandbox` is a DOMTokenList (the Ruby `#sandbox` string # accessor from reflect_string is kept for internal use). Non-iframe # frame elements get undefined via the element/namespace check. reflected_token_list("sandbox", "sandbox") else super end end |
#__js_set__(key, value) ⇒ Object
4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 |
# File 'lib/dommy/html_elements.rb', line 4313 def __js_set__(key, value) case key when "width" self.width = value when "height" self.height = value else super end end |
#build_blank_content_document ⇒ Object
Build the blank nested document + its Window, back-linking the Window to this frame (so getComputedStyle can detect a non-rendered frame's content).
4272 4273 4274 4275 4276 4277 |
# File 'lib/dommy/html_elements.rb', line 4272 def build_blank_content_document win = Window.new(nil, backend_doc: Backend.parse("<!DOCTYPE html><html><head></head><body></body></html>")) doc = win.document win.frame_element = self if win.respond_to?(:frame_element=) doc end |
#content_document ⇒ Object
The nested browsing context's document. An integration/test layer may
inject one via __internal_set_content_document__ (e.g. the src
resource); otherwise a connected iframe gets a lazily-created blank
about:blank document (with its own Window), matching a browser where
iframe.contentDocument is non-null once the frame is in a document.
A disconnected iframe has no browsing context, so contentDocument is null.
4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 |
# File 'lib/dommy/html_elements.rb', line 4258 def content_document return @content_document if @content_document return nil unless respond_to?(:is_connected?) && is_connected? # An iframe with a `src` (or `srcdoc`) is navigated by the host / test layer # (Dommy doesn't fetch), which injects the document via # `__internal_set_content_document__`; only a truly blank iframe gets the # auto about:blank document here, so we don't shadow a pending navigation. return nil unless get_attribute("src").to_s.empty? && get_attribute("srcdoc").nil? @content_document = build_blank_content_document end |
#content_window ⇒ Object
4287 4288 4289 4290 4291 |
# File 'lib/dommy/html_elements.rb', line 4287 def content_window # Go through the lazy accessor so a blank browsing context is created on # first `contentWindow` access too (not only via `contentDocument`). content_document&.default_view end |
#height ⇒ Object
4244 4245 4246 |
# File 'lib/dommy/html_elements.rb', line 4244 def height @__node__["height"].to_s end |
#height=(v) ⇒ Object
4248 4249 4250 |
# File 'lib/dommy/html_elements.rb', line 4248 def height=(v) set_reflected_string("height", v.to_s) end |
#width ⇒ Object
4236 4237 4238 |
# File 'lib/dommy/html_elements.rb', line 4236 def width @__node__["width"].to_s end |
#width=(v) ⇒ Object
4240 4241 4242 |
# File 'lib/dommy/html_elements.rb', line 4240 def width=(v) set_reflected_string("width", v.to_s) end |