|
| 1 | +use webf_sys::{ExecutingContext, NativeValue, NodeMethods}; |
| 2 | +use webf_test_macros::webf_test_async; |
| 3 | +use webf_test_utils::{common::TestCaseMetadata, snapshot::snapshot_with_filename}; |
| 4 | + |
| 5 | +#[webf_test_async] |
| 6 | +pub async fn test_span_should_work_with_texts(metadata: TestCaseMetadata, context: ExecutingContext) { |
| 7 | + let document = context.document(); |
| 8 | + let exception_state = context.create_exception_state(); |
| 9 | + let body = document.body(); |
| 10 | + |
| 11 | + // Create first span with text |
| 12 | + let span = document.create_element("span", &exception_state).unwrap(); |
| 13 | + let text = document.create_text_node("hello world", &exception_state).unwrap(); |
| 14 | + span.append_child(&text.as_node(), &exception_state).unwrap(); |
| 15 | + |
| 16 | + // Set style properties for first span |
| 17 | + let span_style = span.style(); |
| 18 | + span_style.set_property("font-size", NativeValue::new_string("80px"), &exception_state).unwrap(); |
| 19 | + span_style.set_property("text-decoration", NativeValue::new_string("line-through"), &exception_state).unwrap(); |
| 20 | + span_style.set_property("font-weight", NativeValue::new_string("bold"), &exception_state).unwrap(); |
| 21 | + span_style.set_property("font-style", NativeValue::new_string("italic"), &exception_state).unwrap(); |
| 22 | + span_style.set_property("font-family", NativeValue::new_string("arial"), &exception_state).unwrap(); |
| 23 | + |
| 24 | + // Append first span to body |
| 25 | + body.append_child(&span.as_node(), &exception_state).unwrap(); |
| 26 | + |
| 27 | + // Create second span with text |
| 28 | + let span2 = document.create_element("span", &exception_state).unwrap(); |
| 29 | + let text2 = document.create_text_node("hello world", &exception_state).unwrap(); |
| 30 | + span2.append_child(&text2.as_node(), &exception_state).unwrap(); |
| 31 | + |
| 32 | + // Set style properties for second span |
| 33 | + let span2_style = span2.style(); |
| 34 | + span2_style.set_property("font-size", NativeValue::new_string("40px"), &exception_state).unwrap(); |
| 35 | + span2_style.set_property("text-decoration", NativeValue::new_string("underline"), &exception_state).unwrap(); |
| 36 | + span2_style.set_property("font-weight", NativeValue::new_string("lighter"), &exception_state).unwrap(); |
| 37 | + span2_style.set_property("font-style", NativeValue::new_string("normal"), &exception_state).unwrap(); |
| 38 | + span2_style.set_property("font-family", NativeValue::new_string("georgia"), &exception_state).unwrap(); |
| 39 | + |
| 40 | + // Append second span to body |
| 41 | + body.append_child(&span2.as_node(), &exception_state).unwrap(); |
| 42 | + |
| 43 | + // Take snapshot |
| 44 | + snapshot_with_filename(context, metadata.snapshot_filename).await.unwrap(); |
| 45 | +} |
0 commit comments