コード例 #1
0
def test_html_blacklist_template():
    """The template element provides HTML fragments for use by scripts."""
    check_html_output_does_not_contain_tag(
        """
        <p>
            Click the button to fill the web page with one new DIV element for
            each item in an array.
        </p>

        <button onclick="showContent()">Show content</button>

        <template>
            <div>I like: </div>
        </template>

        <script>
            var myArr = ["preference 1", "preference 2"];
            function showContent() {
                var a, i;
                var temp = document.getElementsByTagName("template")[0];
                var item = temp.content.querySelector("div");
                for (i = 0; i < myArr.length; i++) {
                    a = document.importNode(item, true);
                    a.textContent += myArr[i];
                    document.body.appendChild(a);
                }
            }
        </script>
    """, "template")
コード例 #2
0
def test_html_blacklist_link():
    """The link element provides access to other resources."""
    check_html_output_does_not_contain_tag(
        """
        <link rel="stylesheet" type="text/css" href="styles.css">
        <p>I am formatted with a linked style sheet</p>
    """, "link")
コード例 #3
0
def test_html_blacklist_math():
    """The math element contains MathML elements."""
    check_html_output_does_not_contain_tag(
        """
        <p>
            <math>
                <mi>x</mi>
                <mo>=</mo>
                <mfrac>
                    <mrow>
                        <mo form="prefix">-</mo> <mi>b</mi>
                        <mo>±</mo>
                        <msqrt>
                            <msup> <mi>b</mi> <mn>2</mn> </msup>
                            <mo>-</mo>
                            <mn>4</mn> <mi>a</mi> <mi>c</mi>
                        </msqrt>
                    </mrow>
                    <mrow>
                        <mn>2</mn> <mi>a</mi>
                    </mrow>
                </mfrac>
            </math>
        </p>
    """, "math")
コード例 #4
0
def test_html_blacklist_object():
    """The object element contains an external resource."""
    check_html_output_does_not_contain_tag(
        """
        <object data="flashgame.swf">
            <param name="quality" value="high">
        </object>
    """, "object")
コード例 #5
0
def test_html_blacklist_dialog():
    """The dialog element is a user-interactive area for performing."""
    check_html_output_does_not_contain_tag(
        """
        <p><b>Note:</b> The dialog tag is not supported in Edge.</p>
        <p>January <dialog open>This is an open dialog window</dialog></p>
        <p>February</p>
    """, "dialog")
コード例 #6
0
def test_html_blacklist_param():
    """The param element defines plugin parameters for object elements."""
    check_html_output_does_not_contain_tag(
        """
        <object data="flashgame.swf">
            <param name="quality" value="high">
        </object>
    """, "param")
コード例 #7
0
def test_html_blacklist_option():
    """The option element is an option in a select or datalist element."""
    check_html_output_does_not_contain_tag(
        """
        <datalist id=sexes>
            <option value="Female"/>
            <option value="Male"/>
        </datalist>
    """, "option")
コード例 #8
0
def test_html_blacklist_legend():
    """The legend element has a caption for its parent fieldset."""
    check_html_output_does_not_contain_tag(
        """
        <fieldset>
            <legend>Pizza Size</legend>
            <label><input type=radio name=size/>Small</label>
        </fieldset>
    """, "legend")
コード例 #9
0
def test_html_blacklist_data():
    """The data element has text and a machine-readable value attribute."""
    check_html_output_does_not_contain_tag(
        """
        <ul>
          <li><data value="21053">Cherry Tomato</data></li>
          <li><data value="21054">Beef Tomato</data></li>
          <li><data value="21055">Snack Tomato</data></li>
        </ul>
    """, "data")
コード例 #10
0
def test_html_blacklist_audio():
    """The audio element is a media element containing audio data."""
    check_html_output_does_not_contain_tag(
        """
        <audio controls>
            <source src="baa.ogg" type="audio/ogg">
            <source src="baa.mp3" type="audio/mpeg">
            Your browser does not support the audio element.
        </audio>
    """, "audio")
コード例 #11
0
def test_html_blacklist_picture():
    """The picture element provides multiple sources for its img element."""
    check_html_output_does_not_contain_tag(
        """
        <picture>
            <source media="(min-width: 650px)" srcset="img_pink_flowers.jpg"/>
            <source media="(min-width: 465px)" srcset="img_white_flower.jpg"/>
            <img src="img_orange_flowers.jpg" style="width:auto;"/>
        </picture>
    """, "picture")
コード例 #12
0
def test_html_blacklist_style():
    """The style element embeds style information in the document."""
    check_html_output_does_not_contain_tag(
        """
        <style>
            h1 {color:red;}
            p {color:blue;}
        </style>
        <p><strong>You add coins at your own risk.</strong></p>
    """, "style")
コード例 #13
0
def test_html_blacklist_video():
    """The video element is a media element containing video data."""
    check_html_output_does_not_contain_tag(
        """
        <video width="320" height="240" controls>
            <source src="film.mp4" type="video/mp4">
            <source src="film.ogg" type="video/ogg">
            Your browser does not support the video tag.
        </video>
    """, "video")
コード例 #14
0
def test_html_blacklist_source():
    """The source element specifies an alternative source for a resource."""
    check_html_output_does_not_contain_tag(
        """
        <picture>
            <source media="(min-width: 650px)" srcset="img_pink_flowers.jpg"/>
            <source media="(min-width: 465px)" srcset="img_white_flower.jpg"/>
            <img src="img_orange_flowers.jpg" style="width:auto;"/>
        </picture>
    """, "source")
コード例 #15
0
def test_html_blacklist_output():
    """The output element is the result of a calculation or a user action."""
    check_html_output_does_not_contain_tag(
        """
        <form onsubmit="return false"
              oninput="o.value = a.valueAsNumber + b.valueAsNumber">
            <input name=a type=number step=any> +
            <input name=b type=number step=any> =
            <output name=o for="a b"></output>
        </form>
    """, "output")
コード例 #16
0
def test_html_blacklist_nav():
    """The nav element represents a section with navigation links."""
    check_html_output_does_not_contain_tag(
        """
        <nav>
            <a href="/html/">HTML</a> |
            <a href="/css/">CSS</a> |
            <a href="/js/">JavaScript</a> |
            <a href="/jquery/">jQuery</a>
        </nav>
    """, "nav")
コード例 #17
0
def test_html_blacklist_select():
    """The select element is a control for selecting from a set of options."""
    check_html_output_does_not_contain_tag(
        """
        <select id="number" name="number">
            <option value="1"> One </option>
            <option value="2"> Two </option>
            <option value="3" selected> Three </option>
            <option value="4"> Four </option>
        </select>
    """, "select")
コード例 #18
0
def test_html_blacklist_hr():
    """The hr element represents a thematic break in text content."""
    check_html_output_does_not_contain_tag(
        """
        <h1>HTML</h1>
        <p>HTML is a language for describing web pages.....</p>

        <hr/>

        <h1>CSS</h1>
        <p>CSS defines how to display HTML elements.....</p>
    """, "hr")
コード例 #19
0
def test_html_blacklist_track():
    """The track element specifies subtitles or other text for media."""
    check_html_output_does_not_contain_tag(
        """
        <video width="320" height="240" controls>
            <source src="film.mp4" type="video/mp4">
            <track src="subtitles_en.vtt" kind="subtitles"
                   srclang="en" label="English">
            <track src="subtitles_no.vtt" kind="subtitles"
                   srclang="no" label="Norwegian">
            Your browser does not support the video tag.
        </video>
    """, "track")
コード例 #20
0
def test_html_blacklist_map():
    """The area element represents a corresponding area on an image map."""
    check_html_output_does_not_contain_tag(
        """
        <p>
            Please select a shape:
            <img src="shapes.png" usemap="#shapes" alt="Shapes."/>
            <map name="shapes">
                <area shape=rect coords="25,25,125,125" href="red.html"/>
                <area shape=circle coords="200,75,50" href="green.html"/>
            </map>
        </p>
    """, "area")
コード例 #21
0
def test_html_blacklist_svg():
    """The svg element contains an embedded SVG graphic."""
    check_html_output_does_not_contain_tag(
        """
        <svg xmlns="http://www.w3.org/2000/svg" version="1.1"
             width="5cm" height="5cm">
            <desc>A group of two rectangles</desc>
            <g id="group1" fill="red">
                <rect x="1cm" y="1cm" width="1cm" height="1cm"/>
                <rect x="3cm" y="1cm" width="1cm" height="1cm"/>
            </g>
        </svg>
    """, "svg")
コード例 #22
0
def test_html_blacklist_script():
    """The script element contains dynamic scripts."""
    check_html_output_does_not_contain_tag(
        """
        <p id="demo"></p>

        <script>
            document.getElementById("demo").innerHTML = "Hello JavaScript!";
        </script>

        <noscript>
            <p>Sorry, your browser does not support JavaScript!</p>
        </noscript>

        <p>Browsers without JavaScript support will show the noscript text.</p>
    """, "script")
コード例 #23
0
def test_html_blacklist_noscript():
    """The noscript element hides its children unless scripting is disabled."""
    check_html_output_does_not_contain_tag(
        """
        <p id="demo"></p>

        <script>
            document.getElementById("demo").innerHTML = "Hello JavaScript!";
        </script>

        <noscript>
            <p>Sorry, your browser does not support JavaScript!</p>
        </noscript>

        <p>Browsers without JavaScript support will show the noscript text.</p>
    """, "noscript")
コード例 #24
0
def test_html_blacklist_summary():
    """The summary element provides a summary for its details element."""
    check_html_output_does_not_contain_tag(
        """
        <section class="progress window">
            <h1>Copying "Really Achieving Your Childhood Dreams"</h1>
            <details>
                <summary>Copying...
                    <progress max="100" value="25">25%</progress>
                </summary>
                <dl>
                    <dt>Transfer rate:</dt> <dd>452KB/s</dd>
                    <dt>Duration:</dt> <dd>01:16:27</dd>
                </dl>
            </details>
        </section>
    """, "summary")
コード例 #25
0
def test_html_blacklist_optgroup():
    """The optgroup element is a group of option elements."""
    check_html_output_does_not_contain_tag(
        """
        <select name="c">
            <optgroup label="8.01 Subject 1"/>
                <option value="8.01.1">Lecture 01: Topic 1</option>
                <option value="8.01.2">Lecture 02: Topic 2</option>
                <option value="8.01.3">Lecture 03: Topic 3</option>
            </optgroup>
            <optgroup label="8.02 Subject 2"/>
                <option value="8.02.1">Lecture 01: Topic 1</option>
                <option value="8.02.2">Lecture 02: Topic 2</option>
                <option value="8.02.3">Lecture 03: Topic 3</option>
            </optgroup>
        </select>
    """, "optgroup")
コード例 #26
0
def test_html_blacklist_details():
    """The details element is an expandable widget with additional context."""
    check_html_output_does_not_contain_tag(
        """
        <section class="progress window">
            <h1>Copying "Really Achieving Your Childhood Dreams"</h1>
            <details>
                <summary>Copying...
                    <progress max="100" value="25">25%</progress>
                </summary>
                <dl>
                    <dt>Transfer rate:</dt> <dd>452KB/s</dd>
                    <dt>Duration:</dt> <dd>01:16:27</dd>
                </dl>
            </details>
        </section>
    """, "details")
コード例 #27
0
def test_html_blacklist_progress():
    """The progress element represents the completion progress of a task."""
    check_html_output_does_not_contain_tag(
        """
        <section>
        <h2>Task Progress</h2>
        <p>
            Progress:
            <progress id="progbar" max=100><span>0</span>%</progress>
        </p>
        <script>
            var progressBar = document.getElementById('progbar');
            function updateProgress(amount) {
                progressBar.value += amount;
                progressBar.getElementsByTagName('span')[0]
                    .textContent = progressBar.value;
            }
        </script>
        <button type=button onclick="updateProgress(10)">Click here</button>
        </section>
    """, "progress")
コード例 #28
0
def test_html_blacklist_br():
    """The br element represents a line break."""
    check_html_output_does_not_contain_tag(
        """
        <p>This text contains<br/>a line break.</p>
    """, "br")
コード例 #29
0
def test_html_blacklist_embed():
    """The embed element provides an external (typically non-HTML) resource."""
    check_html_output_does_not_contain_tag(
        """
        <embed src="flashgame.swf" quality="high"/>
    """, "embed")
コード例 #30
0
def test_html_blacklist_canvas():
    """The canvas element provides a resolution-dependent bitmap canvas."""
    check_html_output_does_not_contain_tag(
        """
        <canvas id="myCanvas" width="200" height="100"></canvas>
    """, "canvas")