@@ -13,7 +13,11 @@ fn element() {
13
13
14
14
#[wasm_bindgen]
15
15
pub fn test_element(element: &web_sys::Element) {
16
- assert_eq!(element.local_name(), "div", "Shouldn't have a div local name");
16
+ /* Tests needed for:
17
+ namespace_uri
18
+ */
19
+ assert_eq!(element.prefix(), None, "Shouldn't have a prefix");
20
+ assert_eq!(element.local_name(), "div", "Should have a div local name");
17
21
assert_eq!(element.tag_name(), "div", "Should be a div tag");
18
22
assert!(!element.has_attribute("id"), "Shouldn't have an id");
19
23
element.set_id("beep");
@@ -27,7 +31,11 @@ fn element() {
27
31
assert_eq!(element.class_name(), "", "Shouldn't have a class name");
28
32
element.set_class_name("test thing");
29
33
assert_eq!(element.class_name(), "test thing", "Should have a class name");
34
+ assert_eq!(element.get_attribute("class").unwrap(), "test thing", "Should have a class name");
30
35
assert_eq!(element.remove_attribute("class").unwrap(), (), "Should return nothing if removed");
36
+ /* Tests needed for:
37
+ get_attribute_ns
38
+ */
31
39
32
40
/*TODO should we enable toggle_attribute tests? (Firefox Nightly + Chrome canary only)
33
41
// TODO toggle_attribute should permit a single argument when optional arguments are supported
@@ -44,11 +52,19 @@ fn element() {
44
52
// TODO check get_attribute here when supported
45
53
assert_eq!(element.remove_attribute("title").unwrap(), (), "Should return nothing if removed");
46
54
assert!(!element.has_attribute("title"), "Should not have a title");
55
+ /* Tests needed for:
56
+ set_attribute_ns
57
+ */
47
58
48
59
assert!(!element.has_attributes(), "Should not have any attributes");
49
60
assert_eq!(element.set_attribute("title", "boop").unwrap(), (), "Should return nothing if set correctly");
50
61
assert!(element.has_attributes(), "Should have attributes");
51
62
assert_eq!(element.remove_attribute("title").unwrap(), (), "Should return nothing if removed");
63
+ /* Tests needed for:
64
+ remove_attribute_ns
65
+ has_attribure_ns
66
+ closest
67
+ */
52
68
53
69
assert_eq!(element.matches(".this-is-a-thing").unwrap(), false, "Should not match selector");
54
70
assert_eq!(element.webkit_matches_selector(".this-is-a-thing").unwrap(), false, "Should not match selector");
@@ -57,15 +73,53 @@ fn element() {
57
73
assert_eq!(element.webkit_matches_selector(".this-is-a-thing").unwrap(), true, "Should match selector");
58
74
assert_eq!(element.remove_attribute("class").unwrap(), (), "Should return nothing if removed");
59
75
60
-
61
76
// TODO non standard moz_matches_selector should we even support?
77
+
62
78
/* Tests needed for:
79
+ insert_adjacent_element
63
80
insert_adjacent_text
64
81
set_pointer_capture
65
82
release_pointer_capture
66
83
has_pointer_capture
67
84
set_capture
68
85
release_capture
86
+ scroll_top
87
+ set_scroll_top
88
+ scroll_left
89
+ set_scroll_left
90
+ scroll_width
91
+ scroll_height
92
+ scroll,
93
+ scroll_to
94
+ scroll_by
95
+ client_top
96
+ client_left
97
+ client_width
98
+ client_height
99
+ scroll_top_max
100
+ scroll_left_max
101
+ */
102
+ assert_eq!(element.inner_html(), "", "Should return no content");
103
+ element.set_inner_html("<strong>Hey!</strong><em>Web!</em>");
104
+ assert_eq!(element.inner_html(), "<strong>Hey!</strong><em>Web!</em>", "Should return HTML conent");
105
+ assert_eq!(element.query_selector_all("strong").unwrap().length(), 1, "Should return one element");
106
+ assert!(element.query_selector("strong").unwrap().is_some(), "Should return an element");
107
+ element.set_inner_html("");
108
+ assert_eq!(element.inner_html(), "", "Should return no content");
109
+
110
+ /* Tests needed for:
111
+ outer_html
112
+ set_outer_html
113
+ insert_adjacent_html
114
+ */
115
+
116
+ assert!(element.query_selector(".none-existant").unwrap().is_none(), "Should return no results");
117
+ assert_eq!(element.query_selector_all(".none-existant").unwrap().length(), 0, "Should return no results");
118
+ /* Tests needed for:
119
+ slot
120
+ set_slot
121
+ request_fullscreen
122
+ request_pointer_lock
69
123
*/
70
124
}
71
125
"# ,
0 commit comments