<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>DocumentUtil Tests</title>
    <link rel="icon" type="image/gif" href="data:image/gif;base64,R0lGODdhAQABAIABAAAAAP///ywAAAAAAQABAAACAkQBADs=">
    <link rel="stylesheet" href="test-stylesheet.css">
</head>
<body>

    <h1>DocumentUtil Tests</h1>

    <test-description>Automated test cases for DocumentUtil.</test-description>

    <test-case
        data-test-type="scan"
        data-test-data='{
            "elementFromPointSelector": "span",
            "caretRangeFromPointSelector": "span",
            "startNodeSelector": "span",
            "startOffset": 0,
            "endNodeSelector": "span",
            "endOffset": 0,
            "resultType": "TextSourceRange",
            "sentenceScanExtent": 100,
            "sentence": "真白「心配してくださって、ありがとございます」"
        }'
    >
        <span>真白「心配してくださって、ありがとございます」</span>
    </test-case>

    <test-case
        data-test-type="scan"
        data-test-data='{
            "elementFromPointSelector": "span",
            "caretRangeFromPointSelector": "span",
            "startNodeSelector": "span",
            "startOffset": 5,
            "endNodeSelector": "span",
            "endOffset": 5,
            "resultType": "TextSourceRange",
            "sentenceScanExtent": 100,
            "sentence": "心配してくださって、ありがとございます"
        }'
    >
        <span>真白「心配してくださって、ありがとございます」</span>
    </test-case>

    <test-case
        data-test-type="scan"
        data-test-data='{
            "elementFromPointSelector": "span",
            "caretRangeFromPointSelector": "span",
            "startNodeSelector": "span",
            "startOffset": 16,
            "endNodeSelector": "span",
            "endOffset": 16,
            "resultType": "TextSourceRange",
            "sentenceScanExtent": 100,
            "sentence": "心配して「くださって」、ありがと「ございます」"
        }'
    >
        <span>真白「心配して「くださって」、ありがと「ございます」」</span>
    </test-case>

    <test-case
        data-test-type="scan"
        data-test-data='{
            "elementFromPointSelector": "span",
            "caretRangeFromPointSelector": "span",
            "startNodeSelector": "span",
            "startOffset": 4,
            "endNodeSelector": "span",
            "endOffset": 4,
            "resultType": "TextSourceRange",
            "sentenceScanExtent": 100,
            "sentence": "ありがとございます。"
        }'
    >
        <span>ありがとございます。ありがとございます。</span>
    </test-case>

    <test-case
        data-test-type="scan"
        data-test-data='{
            "elementFromPointSelector": "span",
            "caretRangeFromPointSelector": "span",
            "startNodeSelector": "span",
            "startOffset": 14,
            "endNodeSelector": "span",
            "endOffset": 14,
            "resultType": "TextSourceRange",
            "sentenceScanExtent": 100,
            "sentence": "ありがとございます。"
        }'
    >
        <span>ありがとございます。ありがとございます。</span>
    </test-case>

    <test-case
        data-test-type="scan"
        data-test-data='{
            "elementFromPointSelector": "span",
            "caretRangeFromPointSelector": "span",
            "startNodeSelector": "span",
            "startOffset": 4,
            "endNodeSelector": "span",
            "endOffset": 4,
            "resultType": "TextSourceRange",
            "sentenceScanExtent": 100,
            "sentence": "ありがとございます。!?"
        }'
    >
        <span>ありがとございます。!?ありがとございます。!?</span>
    </test-case>

    <test-case
        data-test-type="scan"
        data-test-data='{
            "elementFromPointSelector": "span",
            "caretRangeFromPointSelector": "span",
            "startNodeSelector": "span",
            "startOffset": 4,
            "endNodeSelector": "span",
            "endOffset": 4,
            "resultType": "TextSourceRange",
            "sentenceScanExtent": 100,
            "sentence": "ありがとございます!!!"
        }'
    >
        <span>ありがとございます!!!ありがとございます!!!</span>
    </test-case>

    <test-case
        data-test-type="scan"
        data-test-data='{
            "elementFromPointSelector": "input",
            "caretRangeFromPointSelector": "input",
            "startNodeSelector": "input",
            "startOffset": 0,
            "endNodeSelector": "input",
            "endOffset": 0,
            "resultType": "TextSourceRange",
            "sentenceScanExtent": 100,
            "sentence": "真白「心配してくださって、ありがとございます」",
            "hasImposter": true
        }'
    >
        <input type="text" value="真白「心配してくださって、ありがとございます」" style="width: 100%; box-sizing: border-box; font-family: inherit; font-size: inherit; border: 1px solid #d8d8d8; padding: 0.2em;">
    </test-case>

    <test-case
        data-test-type="scan"
        data-test-data='{
            "elementFromPointSelector": "textarea",
            "caretRangeFromPointSelector": "textarea",
            "startNodeSelector": "textarea",
            "startOffset": 0,
            "endNodeSelector": "textarea",
            "endOffset": 0,
            "resultType": "TextSourceRange",
            "sentenceScanExtent": 100,
            "sentence": "真白「心配してくださって、ありがとございます」",
            "hasImposter": true
        }'
    >
        <textarea style="width: 100%; height: 3em; box-sizing: border-box; font-family: inherit; font-size: inherit; border: 1px solid #d8d8d8; padding: 0.2em;">真白「心配してくださって、ありがとございます」</textarea>
    </test-case>

    <test-case
        data-test-type="scan"
        data-test-data='{
            "elementFromPointSelector": "button",
            "caretRangeFromPointSelector": "button",
            "startNodeSelector": "button",
            "startOffset": 0,
            "endNodeSelector": "button",
            "endOffset": 0,
            "resultType": "TextSourceElement",
            "sentenceScanExtent": 100,
            "sentence": "よみたん"
        }'
    >
        <button type="button" style="width: 100%; box-sizing: border-box; font-family: inherit; font-size: inherit; border: 1px solid #d8d8d8; background-color: #f0f0f0; padding: 0.2em;">よみたん</button>
    </test-case>

    <test-case
        data-test-type="scan"
        data-test-data='{
            "elementFromPointSelector": "img",
            "caretRangeFromPointSelector": "img",
            "startNodeSelector": "img",
            "startOffset": 0,
            "endNodeSelector": "img",
            "endOffset": 0,
            "resultType": "TextSourceElement",
            "sentenceScanExtent": 100,
            "sentence": "よみたん"
        }'
    >
        <img src="data:image/gif;base64,R0lGODdhAQABAIABAAAAAP///ywAAAAAAQABAAACAkQBADs=" alt="よみたん" title="よみたん" style="width: 70px; height: 70px; image-rendering: crisp-edges; image-rendering: pixelated; display: block;">
    </test-case>

    <test-case
        data-test-type="scan"
        data-test-data='{
            "elementFromPointSelector": "span:nth-of-type(3)",
            "caretRangeFromPointSelector": "span:nth-of-type(3)",
            "startNodeSelector": "span:nth-of-type(3)",
            "startOffset": 0,
            "endNodeSelector": "span:nth-of-type(3)",
            "endOffset": 0,
            "resultType": "TextSourceRange",
            "sentenceScanExtent": 22,
            "sentence": "ありがとございます3",
            "terminateAtNewlines": true
        }'
    >
<span>ありがとございます1</span>
<span>ありがとございます2</span>
<span>ありがとございます3</span>
<span>ありがとございます4</span>
<span>ありがとございます5</span>
    </test-case>

    <test-case
        data-test-type="scan"
        data-test-data='{
            "elementFromPointSelector": "span:nth-of-type(3)",
            "caretRangeFromPointSelector": "span:nth-of-type(3)",
            "startNodeSelector": "span:nth-of-type(3)",
            "startOffset": 0,
            "endNodeSelector": "span:nth-of-type(3)",
            "endOffset": 0,
            "resultType": "TextSourceRange",
            "sentenceScanExtent": 22,
            "sentence": "ありがとございます1\nありがとございます2\nありがとございます3\nありがとございます4",
            "terminateAtNewlines": false
        }'
    >
<span>ありがとございます1</span>
<span>ありがとございます2</span>
<span>ありがとございます3</span>
<span>ありがとございます4</span>
<span>ありがとございます5</span>
    </test-case>

    <test-case
    data-test-type="text-source-range-seek"
        data-test-data='{
            "seekNodeSelector": "span:nth-of-type(1)",
            "seekNodeIsText": true,
            "seekOffset": 0,
            "seekLength": 149,
            "seekDirection": "forward",
            "expectedResultNodeSelector": "span:nth-of-type(1)",
            "expectedResultNodeIsText": true,
            "expectedResultOffset": 149,
            "expectedResultContent": [
                "",
                "        あいうえお",
                "        かきくけこ",
                "        さしすせそ",
                "        たちつてと",
                "        なにぬねの",
                "        はひふへほ",
                "        まみむめも",
                "        や ゆ よ",
                "        らりるれろ",
                "        わゐ ゑを",
                "        "
            ]
        }'
    >
        <span>
        あいうえお
        かきくけこ
        さしすせそ
        たちつてと
        なにぬねの
        はひふへほ
        まみむめも
        や&#x3000;ゆ&#x3000;よ
        らりるれろ
        わゐ&#x3000;ゑを
        </span><span>trailing content</span>
    </test-case>

    <test-case
        data-test-type="text-source-range-seek"
        data-test-data='{
            "seekNodeSelector": "span:nth-of-type(1)",
            "seekNodeIsText": true,
            "seekOffset": 149,
            "seekLength": 149,
            "seekDirection": "backward",
            "expectedResultNodeSelector": "span:nth-of-type(1)",
            "expectedResultNodeIsText": true,
            "expectedResultOffset": 0,
            "expectedResultContent": [
                "",
                "        あいうえお",
                "        かきくけこ",
                "        さしすせそ",
                "        たちつてと",
                "        なにぬねの",
                "        はひふへほ",
                "        まみむめも",
                "        や ゆ よ",
                "        らりるれろ",
                "        わゐ ゑを",
                "        "
            ]
        }'
    >
        <span>
        あいうえお
        かきくけこ
        さしすせそ
        たちつてと
        なにぬねの
        はひふへほ
        まみむめも
        や&#x3000;ゆ&#x3000;よ
        らりるれろ
        わゐ&#x3000;ゑを
        </span><span>trailing content</span>
    </test-case>

    <test-case
        data-test-type="text-source-range-seek"
        data-test-data='{
            "seekNodeSelector": "span:nth-of-type(1)",
            "seekNodeIsText": true,
            "seekOffset": 0,
            "seekLength": 150,
            "seekDirection": "forward",
            "expectedResultNodeSelector": "span:nth-of-type(2)",
            "expectedResultNodeIsText": true,
            "expectedResultOffset": 1,
            "expectedResultContent": [
                "",
                "        あいうえお",
                "        かきくけこ",
                "        さしすせそ",
                "        たちつてと",
                "        なにぬねの",
                "        はひふへほ",
                "        まみむめも",
                "        や ゆ よ",
                "        らりるれろ",
                "        わゐ ゑを",
                "        t"
            ]
        }'
    >
        <span>
        あいうえお
        かきくけこ
        さしすせそ
        たちつてと
        なにぬねの
        はひふへほ
        まみむめも
        や&#x3000;ゆ&#x3000;よ
        らりるれろ
        わゐ&#x3000;ゑを
        </span><span>trailing content</span>
    </test-case>

    <test-case
        data-test-type="text-source-range-seek"
        data-test-data='{
            "seekNodeSelector": "span:nth-of-type(2)",
            "seekNodeIsText": true,
            "seekOffset": 1,
            "seekLength": 150,
            "seekDirection": "bacward",
            "expectedResultNodeSelector": "span:nth-of-type(1)",
            "expectedResultNodeIsText": true,
            "expectedResultOffset": 0,
            "expectedResultContent": [
                "",
                "        あいうえお",
                "        かきくけこ",
                "        さしすせそ",
                "        たちつてと",
                "        なにぬねの",
                "        はひふへほ",
                "        まみむめも",
                "        や ゆ よ",
                "        らりるれろ",
                "        わゐ ゑを",
                "        t"
            ]
        }'
    >
        <span>
        あいうえお
        かきくけこ
        さしすせそ
        たちつてと
        なにぬねの
        はひふへほ
        まみむめも
        や&#x3000;ゆ&#x3000;よ
        らりるれろ
        わゐ&#x3000;ゑを
        </span><span>trailing content</span>
    </test-case>

</body>
</html>