MCPcopy Create free account
hub / github.com/d0iasm/saba / test_multiple_nodes

Function test_multiple_nodes

core/src/renderer/html/parser.rs:840–904  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

838
839 #[test]
840 fn test_multiple_nodes() {
841 let browser = Browser::new();
842 let html = "<html><head></head><body><p><a foo=bar>text</a></p></body></html>".to_string();
843 let t = HtmlTokenizer::new(Rc::downgrade(&browser), html);
844 let window = HtmlParser::new(Rc::downgrade(&browser), t).construct_tree();
845 let document = window.borrow().document();
846
847 let body = document
848 .borrow()
849 .first_child()
850 .expect("failed to get a first child of document")
851 .borrow()
852 .first_child()
853 .expect("failed to get a first child of document")
854 .borrow()
855 .next_sibling()
856 .expect("failed to get a next sibling of head");
857 assert_eq!(
858 Rc::new(RefCell::new(Node::new(NodeKind::Element(Element::new(
859 "body",
860 Vec::new()
861 ))))),
862 body
863 );
864
865 let p = body
866 .borrow()
867 .first_child()
868 .expect("failed to get a first child of body");
869 assert_eq!(
870 Rc::new(RefCell::new(Node::new(NodeKind::Element(Element::new(
871 "p",
872 Vec::new()
873 ))))),
874 p
875 );
876
877 let mut attr = Attribute::new();
878 attr.add_char('f', true);
879 attr.add_char('o', true);
880 attr.add_char('o', true);
881 attr.add_char('b', false);
882 attr.add_char('a', false);
883 attr.add_char('r', false);
884 let a = p
885 .borrow()
886 .first_child()
887 .expect("failed to get a first child of p");
888 assert_eq!(
889 Rc::new(RefCell::new(Node::new(NodeKind::Element(Element::new(
890 "a",
891 vec![attr]
892 ))))),
893 a
894 );
895
896 let text = a
897 .borrow()

Callers

nothing calls this directly

Calls 6

to_stringMethod · 0.80
construct_treeMethod · 0.80
documentMethod · 0.80
add_charMethod · 0.80
next_siblingMethod · 0.45
first_childMethod · 0.45

Tested by

no test coverage detected