dymokomi/luce-browser-engine
Source of release 0.6.0
0.6.0 / src / web / html / tests_html_structure_cases.lucb
#==============================================================================================
#
# tests_html_structure_cases - region r26's element, table, list, source set and
# image-request cases pinned to the reference build
#
# DESCRIPTION:
# Generated (a test vector table) from the output of a local oracle that runs the
# reference Ladybird build's LibWeb on the same inputs (luce-browser-tools,
# oracles/luce-browser-engine/html_structure: cases.txt, oracle.cpp,
# gen_luce_cases.py, build.sh). tests_html_structure runs each case through the port
# and compares the output.
#
#==============================================================================================
## One oracle case: the mode, its arguments, and the reference build's output.
struct TestHtmlStructureCase:
let mode: str
let arguments: str[3]
let expected: str
## Every oracle case, in cases.txt order (4 more, marked "!" in cases.txt, wait for other regions).
let test_html_structure_cases: TestHtmlStructureCase[96] = [
TestHtmlStructureCase(mode = "srcset", arguments = ["a.png", "", ""], expected = "a.png|-\n"),
TestHtmlStructureCase(mode = "srcset", arguments = ["a.png 1x, b.png 2x", "", ""], expected = "a.png|x 1000000\nb.png|x 2000000\n"),
TestHtmlStructureCase(mode = "srcset", arguments = ["a.png 2x,b.png 1.5x , c.png 3x", "", ""], expected = "a.png|x 2000000\nc.png|x 3000000\n"),
TestHtmlStructureCase(mode = "srcset", arguments = [" ,, a.png, b.png 100w,c.png 50w", "", ""], expected = "a.png|-\nb.png|w 6400\nc.png|w 3200\n"),
TestHtmlStructureCase(mode = "srcset", arguments = ["a.png 100w 2x", "", ""], expected = ""),
TestHtmlStructureCase(mode = "srcset", arguments = ["a.png 10h", "", ""], expected = ""),
TestHtmlStructureCase(mode = "srcset", arguments = ["a.png 10w 20h", "", ""], expected = ""),
TestHtmlStructureCase(mode = "srcset", arguments = ["a.png -1x, b.png 0.5x", "", ""], expected = "a.png|x -1000000\nb.png|x 500000\n"),
TestHtmlStructureCase(mode = "srcset", arguments = ["data:image/png;base64,AAA= 1x", "", ""], expected = "data:image/png;base64,AAA=|x 1000000\n"),
TestHtmlStructureCase(mode = "srcset", arguments = ["a.png (foo bar) 1x", "", ""], expected = ""),
TestHtmlStructureCase(mode = "srcset", arguments = ["a.png 1x (unterminated", "", ""], expected = ""),
TestHtmlStructureCase(mode = "srcset", arguments = ["a.png, , b.png", "", ""], expected = "a.png|-\nb.png|-\n"),
TestHtmlStructureCase(mode = "srcset", arguments = ["x,,,", "", ""], expected = "x|-\n"),
TestHtmlStructureCase(mode = "srcset", arguments = ["a.png 1e1x, b.png 1.25x", "", ""], expected = "a.png|x 10000000\nb.png|x 1250000\n"),
TestHtmlStructureCase(mode = "srcset", arguments = ["a.png 0w, b.png 12abcw", "", ""], expected = "a.png|w 0\n"),
TestHtmlStructureCase(mode = "srcset", arguments = ["a.png 1x,b.png 1x", "", ""], expected = "a.png|x 1000000\nb.png|x 1000000\n"),
TestHtmlStructureCase(mode = "srcset", arguments = ["é.png 2x", "", ""], expected = "é.png|x 2000000\n"),
TestHtmlStructureCase(mode = "srcset", arguments = ["", "", ""], expected = ""),
TestHtmlStructureCase(mode = "select", arguments = ["<img src=a.png>", "", ""], expected = "a.png 1000000\ndimension source img\n"),
TestHtmlStructureCase(mode = "select", arguments = ["<img srcset=\"a.png 1x, b.png 2x\">", "", ""], expected = "a.png 1000000\ndimension source img\n"),
TestHtmlStructureCase(mode = "select", arguments = ["<img srcset=\"a.png 0.5x, b.png 3x, c.png 1.5x\">", "", ""], expected = "c.png 1500000\ndimension source img\n"),
TestHtmlStructureCase(mode = "select", arguments = ["<img srcset=\"a.png 0.5x, b.png 0.25x\">", "", ""], expected = "a.png 500000\ndimension source img\n"),
TestHtmlStructureCase(mode = "select", arguments = ["<img src=d.png srcset=\"a.png 2x\">", "", ""], expected = "d.png 1000000\ndimension source img\n"),
TestHtmlStructureCase(mode = "select", arguments = ["<img src=d.png srcset=\"a.png 1x\">", "", ""], expected = "a.png 1000000\ndimension source img\n"),
TestHtmlStructureCase(mode = "select", arguments = ["<img srcset=\"a.png 400w, b.png 800w, c.png 1600w\" sizes=\"800px\">", "", ""], expected = "b.png 1000000\ndimension source img\n"),
TestHtmlStructureCase(mode = "select", arguments = ["<img srcset=\"a.png 400w, b.png 800w\" sizes=\"(min-width: 1px) 200px, 50px\">", "", ""], expected = "a.png 8000000\ndimension source img\n"),
TestHtmlStructureCase(mode = "select", arguments = ["<img src=d.png srcset=\"a.png 100w\">", "", ""], expected = "a.png 1000000\ndimension source img\n"),
TestHtmlStructureCase(mode = "select", arguments = ["<img>", "", ""], expected = "none\ndimension source img\n"),
TestHtmlStructureCase(mode = "select", arguments = ["<picture><source srcset=\"s.png 2x\"><img src=i.png></picture>", "", ""], expected = "s.png 2000000\ndimension source img\n"),
TestHtmlStructureCase(mode = "select", arguments = ["<picture><source srcset=\"s.png 2x\" media=\"(max-width: 0px)\"><source srcset=\"t.png 1x\" width=10><img src=i.png></picture>", "", ""], expected = "t.png 1000000\ndimension source source\n"),
TestHtmlStructureCase(mode = "select", arguments = ["<picture><source srcset=\"s.png\" type=\"image/x-unknown\"><source srcset=\"u.png\" type=\"image/png\"><img src=i.png></picture>", "", ""], expected = "u.png 1000000\ndimension source img\n"),
TestHtmlStructureCase(mode = "select", arguments = ["<picture><source><source srcset=\"\"><img src=i.png></picture>", "", ""], expected = "i.png 1000000\ndimension source img\n"),
TestHtmlStructureCase(mode = "cors", arguments = ["-", "", ""], expected = "0 1\n"),
TestHtmlStructureCase(mode = "cors", arguments = ["use-credentials", "", ""], expected = "2 2\n"),
TestHtmlStructureCase(mode = "cors", arguments = ["USE-Credentials", "", ""], expected = "2 2\n"),
TestHtmlStructureCase(mode = "cors", arguments = ["anonymous", "", ""], expected = "1 1\n"),
TestHtmlStructureCase(mode = "cors", arguments = ["", "", ""], expected = "1 1\n"),
TestHtmlStructureCase(mode = "cors", arguments = ["bogus", "", ""], expected = "1 1\n"),
TestHtmlStructureCase(mode = "keyhash", arguments = ["a.png", "0", "-"], expected = "360909423\n"),
TestHtmlStructureCase(mode = "keyhash", arguments = ["http://example.com/a.png", "1", "http://example.com"], expected = "3290757082\n"),
TestHtmlStructureCase(mode = "keyhash", arguments = ["http://example.com/a.png", "2", "https://example.com:8443"], expected = "3039144572\n"),
TestHtmlStructureCase(mode = "keyhash", arguments = ["", "0", "-"], expected = "0\n"),
TestHtmlStructureCase(mode = "tablerows", arguments = ["<table id=t><caption>c</caption><colgroup span=3><col span=2><col span=0><col span=1001></colgroup><thead><tr id=h><th id=hc>h</thead><tbody><tr id=b1><td id=c1 colspan=3 rowspan=2>x<td id=c2 colspan=0 rowspan=0>y<td id=c3 colspan=2000 rowspan=70000><tr id=b2><td id=c4 colspan=\" 4\" rowspan=abc></tbody><tfoot><tr id=f><td id=c5></tfoot></table>", "", ""], expected = "caption 1 thead 1 tfoot 1 tbodies 1\nrows h b1 b2 f\ntr h 0 0 cells 1\ntr b1 1 0 cells 3\ntr b2 2 1 cells 1\ntr f 3 0 cells 1\ncell hc 0 1 1\ncell c1 0 3 2\ncell c2 1 1 0\ncell c3 2 1000 65534\ncell c4 0 4 1\ncell c5 0 1 1\ncol 3\ncol 2\ncol 1\ncol 1000\nsection thead rows 1\nsection tbody rows 2\nsection tfoot rows 1\n"),
TestHtmlStructureCase(mode = "tablerows", arguments = ["<table id=t><tr id=r1><td id=a></tr><tfoot><tr id=f1></tfoot><tbody><tr id=r2></tbody><thead><tr id=h1></thead><tr id=r3></table>", "", ""], expected = "caption 0 thead 1 tfoot 1 tbodies 3\nrows h1 r1 r2 r3 f1\ntr r1 1 0 cells 1\ntr f1 4 0 cells 0\ntr r2 2 0 cells 0\ntr h1 0 0 cells 0\ntr r3 3 0 cells 0\ncell a 0 1 1\nsection tbody rows 1\nsection tfoot rows 1\nsection tbody rows 1\nsection thead rows 1\nsection tbody rows 1\n"),
TestHtmlStructureCase(mode = "tablerows", arguments = ["<table id=t><tbody><tr id=x><td id=d colspan=+2 rowspan=65535></tbody><tbody><tr id=y></tbody></table>", "", ""], expected = "caption 0 thead 0 tfoot 0 tbodies 2\nrows x y\ntr x 0 0 cells 1\ntr y 1 0 cells 0\ncell d 0 2 65534\nsection tbody rows 1\nsection tbody rows 1\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["insertRow:0", "<table><tr><td>a</tr></table>", ""], expected = "| <table>\n| <tbody>\n| <tr>\n| <tr>\n| <td>\n| \"a\"\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["insertRow:-1", "<table></table>", ""], expected = "| <table>\n| <tbody>\n| <tr>\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["insertRow:-1", "<table><thead><tr><td>h</thead><tbody><tr><td>b</tbody></table>", ""], expected = "| <table>\n| <thead>\n| <tr>\n| <td>\n| \"h\"\n| <tbody>\n| <tr>\n| <td>\n| \"b\"\n| <tr>\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["insertRow:1", "<table><tbody><tr><td>a</td></tr><tr><td>b</td></tr></tbody></table>", ""], expected = "| <table>\n| <tbody>\n| <tr>\n| <td>\n| \"a\"\n| <tr>\n| <tr>\n| <td>\n| \"b\"\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["insertRow:5", "<table><tr><td>a</table>", ""], expected = "exception IndexSizeError\n| <table>\n| <tbody>\n| <tr>\n| <td>\n| \"a\"\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["insertRow:-2", "<table><tr><td>a</table>", ""], expected = "exception IndexSizeError\n| <table>\n| <tbody>\n| <tr>\n| <td>\n| \"a\"\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["deleteRow:0", "<table><tr><td>a<tr><td>b</table>", ""], expected = "| <table>\n| <tbody>\n| <tr>\n| <td>\n| \"b\"\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["deleteRow:-1", "<table><tr><td>a<tr><td>b</table>", ""], expected = "| <table>\n| <tbody>\n| <tr>\n| <td>\n| \"a\"\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["deleteRow:-1", "<table></table>", ""], expected = "| <table>\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["deleteRow:3", "<table><tr><td>a</table>", ""], expected = "exception IndexSizeError\n| <table>\n| <tbody>\n| <tr>\n| <td>\n| \"a\"\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["createCaption", "<table><tr><td>a</table>", ""], expected = "| <table>\n| <caption>\n| <tbody>\n| <tr>\n| <td>\n| \"a\"\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["createCaption", "<table><caption>x</caption></table>", ""], expected = "| <table>\n| <caption>\n| \"x\"\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["deleteCaption", "<table><caption>x</caption><tr><td>a</table>", ""], expected = "| <table>\n| <tbody>\n| <tr>\n| <td>\n| \"a\"\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["createTHead", "<table><caption>c</caption><colgroup><col></colgroup><tbody><tr><td>a</tbody></table>", ""], expected = "| <table>\n| <caption>\n| \"c\"\n| <colgroup>\n| <col>\n| <thead>\n| <tbody>\n| <tr>\n| <td>\n| \"a\"\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["createTHead", "<table><thead></thead></table>", ""], expected = "| <table>\n| <thead>\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["deleteTHead", "<table><thead><tr><td>h</thead><tbody></tbody></table>", ""], expected = "| <table>\n| <tbody>\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["createTFoot", "<table><tbody><tr><td>a</tbody></table>", ""], expected = "| <table>\n| <tbody>\n| <tr>\n| <td>\n| \"a\"\n| <tfoot>\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["deleteTFoot", "<table><tfoot></tfoot><tfoot></tfoot></table>", ""], expected = "| <table>\n| <tfoot>\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["createTBody", "<table><tbody id=a></tbody><tfoot></tfoot></table>", ""], expected = "| <table>\n| <tbody>\n| id=\"a\"\n| <tbody>\n| <tfoot>\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["createTBody", "<table><caption></caption></table>", ""], expected = "| <table>\n| <caption>\n| <tbody>\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["insertCell:0", "<table><tr><td>a</table>", ""], expected = "| <table>\n| <tbody>\n| <tr>\n| <td>\n| <td>\n| \"a\"\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["insertCell:-1", "<table><tr><td>a<th>b</table>", ""], expected = "| <table>\n| <tbody>\n| <tr>\n| <td>\n| \"a\"\n| <th>\n| \"b\"\n| <td>\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["insertCell:2", "<table><tr><td>a</table>", ""], expected = "exception IndexSizeError\n| <table>\n| <tbody>\n| <tr>\n| <td>\n| \"a\"\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["deleteCell:0", "<table><tr><td>a<td>b</table>", ""], expected = "| <table>\n| <tbody>\n| <tr>\n| <td>\n| \"b\"\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["deleteCell:-1", "<table><tr></table>", ""], expected = "| <table>\n| <tbody>\n| <tr>\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["deleteCell:1", "<table><tr><td>a</table>", ""], expected = "exception IndexSizeError\n| <table>\n| <tbody>\n| <tr>\n| <td>\n| \"a\"\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["sectionInsertRow:0", "<table><tbody><tr><td>a</tbody></table>", ""], expected = "| <table>\n| <tbody>\n| <tr>\n| <tr>\n| <td>\n| \"a\"\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["sectionInsertRow:-1", "<table><tbody></tbody></table>", ""], expected = "| <table>\n| <tbody>\n| <tr>\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["sectionInsertRow:3", "<table><tbody></tbody></table>", ""], expected = "exception IndexSizeError\n| <table>\n| <tbody>\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["sectionDeleteRow:-1", "<table><tbody><tr><td>a<tr><td>b</tbody></table>", ""], expected = "| <table>\n| <tbody>\n| <tr>\n| <td>\n| \"a\"\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["sectionDeleteRow:0", "<table><tbody></tbody></table>", ""], expected = "exception IndexSizeError\n| <table>\n| <tbody>\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["setTHeadTFoot", "<table><tfoot></tfoot></table>", ""], expected = "exception HierarchyRequestError\n| <table>\n| <tfoot>\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["setCaptionNull", "<table><caption>x</caption></table>", ""], expected = "| <table>\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["setColSpan:5", "<table><tr><td>a</table>", ""], expected = "colspan 5\n| <table>\n| <tbody>\n| <tr>\n| <td>\n| colspan=\"5\"\n| \"a\"\n"),
TestHtmlStructureCase(mode = "tableop", arguments = ["setColSpan:-1", "<table><tr><td>a</table>", ""], expected = "colspan 1\n| <table>\n| <tbody>\n| <tr>\n| <td>\n| colspan=\"1\"\n| \"a\"\n"),
TestHtmlStructureCase(mode = "ol", arguments = ["<ol><li>a<li value=7>b<li value=x>c<li value=-3>d</ol>", "", ""], expected = "start 1 starting 1\nli 0\nli 7\nli 0\nli -3\n"),
TestHtmlStructureCase(mode = "ol", arguments = ["<ol start=5></ol>", "", ""], expected = "start 5 starting 5\n"),
TestHtmlStructureCase(mode = "ol", arguments = ["<ol start=abc><li>a</ol>", "", ""], expected = "start 1 starting 1\nli 0\n"),
TestHtmlStructureCase(mode = "ol", arguments = ["<ol reversed><li>a<li>b<li>c</ol>", "", ""], expected = "start 1 starting 0\nli 0\nli 0\nli 0\n"),
TestHtmlStructureCase(mode = "ol", arguments = ["<ol reversed start=2><li>a</ol>", "", ""], expected = "start 2 starting 2\nli 0\n"),
TestHtmlStructureCase(mode = "ol", arguments = ["<ol start=\" 12\"><li value=\" 3\">a</ol>", "", ""], expected = "start 12 starting 12\nli 3\n"),
TestHtmlStructureCase(mode = "title", arguments = ["<title> Hello world </title>", "", ""], expected = "title [Hello world]\ntext [ Hello world ]\n"),
TestHtmlStructureCase(mode = "title", arguments = ["<title></title>", "", ""], expected = "title []\ntext []\n"),
TestHtmlStructureCase(mode = "title", arguments = ["<title>a<b>b</b>c</title>", "", ""], expected = "title [a<b>b</b>c]\ntext [a<b>b</b>c]\n"),
TestHtmlStructureCase(mode = "title", arguments = ["<head><title>first</title><title>second</title></head>", "", ""], expected = "title [first]\ntext [first]\n"),
TestHtmlStructureCase(mode = "meta", arguments = ["<meta http-equiv=refresh><meta http-equiv=Content-Type><meta http-equiv=x><meta http-equiv=X-UA-COMPATIBLE><meta http-equiv=content-security-policy><meta http-equiv=set-cookie><meta http-equiv=default-style><meta http-equiv=content-language>", "", ""], expected = "http-equiv 3\nhttp-equiv 1\nhttp-equiv none\nhttp-equiv 5\nhttp-equiv 6\nhttp-equiv 4\nhttp-equiv 2\nhttp-equiv 0\n"),
TestHtmlStructureCase(mode = "referrer", arguments = ["<meta name=referrer content=never>", "", ""], expected = "referrer policy 1\n"),
TestHtmlStructureCase(mode = "referrer", arguments = ["<meta name=referrer content=no-referrer-when-downgrade>", "", ""], expected = "referrer policy 2\n"),
TestHtmlStructureCase(mode = "referrer", arguments = ["<meta name=referrer content=always>", "", ""], expected = "referrer policy 8\n"),
TestHtmlStructureCase(mode = "referrer", arguments = ["<meta name=referrer content=bogus>", "", ""], expected = "referrer policy 7\n"),
TestHtmlStructureCase(mode = "referrer", arguments = ["<meta name=referrer content=\"\">", "", ""], expected = "referrer policy 7\n"),
]