()
| 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() |
nothing calls this directly
no test coverage detected