(t *testing.T)
| 98 | html := `<p>Visible</p><script>hidden script</script><style>.hidden { content: "style text" }</style><action-text-attachment filename="report.pdf"><span>attachment internals</span></action-text-attachment>` |
| 99 | if got := strings.Join(strings.Fields(MessageSourceText(html)), " "); got != "Visible" { |
| 100 | t.Errorf("MessageSourceText = %q, want visible message text only", got) |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | func TestMessageSourceTextHonorsHTMLVisibility(t *testing.T) { |
| 105 | tests := []struct { |
| 106 | name string |
| 107 | html string |
| 108 | want string |
| 109 | }{ |
| 110 | {name: "hidden attribute", html: `<p>Before</p><p hidden>Secret</p><p>After</p>`, want: "Before After"}, |
| 111 | {name: "inert subtree", html: `<p>Before</p><div inert>Inactive</div><p>After</p>`, want: "Before After"}, |
| 112 | {name: "display none", html: `<p>Before</p><div style="DISPLAY: none !important">Hidden</div><p>After</p>`, want: "Before After"}, |
| 113 | {name: "later display wins", html: `<p style="display: none; display: block">Visible</p>`, want: "Visible"}, |
| 114 | {name: "important display wins", html: `<p style="display: none !important; display: block">Hidden</p>`, want: ""}, |
| 115 | {name: "visibility hidden", html: `<p>Before</p><span style="visibility: hidden">Hidden</span><p>After</p>`, want: "Before After"}, |
nothing calls this directly
no test coverage detected