Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Firefox/dom/bindings/parser/tests/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 5 kB image not shown  

Quelle  test_reflected_attribute.py   Sprache: Python

 
import WebIDL


def WebIDLTest(parser, harness):
    def parseWithNode(test):
        parser.parse(
            """
            interface Node {};
            interface Document : Node {};
            interface Element : Node {};
            interface HTMLElement : Element {};
            """
            + test
        )

    def parseFrozenArrayAttribute(innerType):
        parseWithNode(
            """
            interface ReflectedAttribute {
               [Frozen, ReflectedHTMLAttributeReturningFrozenArray]
               attribute sequence<%s>? reflectedHTMLAttribute;
            };
            """
            % innerType
        )

        results = parser.finish()

        harness.check(len(results), 5, "Should know about one thing")
        harness.ok(
            isinstance(results[4], WebIDL.IDLInterface), "Should have an interface here"
        )
        members = results[4].members
        harness.check(len(members), 1, "Should have one member")
        harness.ok(members[0].isAttr(), "Should have attribute")
        harness.ok(
            members[0].getExtendedAttribute(
                "ReflectedHTMLAttributeReturningFrozenArray"
            )
            is not None,
            "Should have extended attribute",
        )

    parseFrozenArrayAttribute("Element")

    parser = parser.reset()
    parseFrozenArrayAttribute("HTMLElement")

    parser = parser.reset()
    threw = False
    try:
        parseWithNode(
            """
            interface ReflectedAttribute {
              [ReflectedHTMLAttributeReturningFrozenArray]
              attribute Element? reflectedHTMLAttribute;
            };
            """
        )

        parser.finish()
    except WebIDL.WebIDLError:
        threw = True
    harness.ok(
        threw,
        "Should have thrown because [ReflectedHTMLAttributeReturningFrozenArray] "
        "should only be used on attributes with a sequence<*Element> type.",
    )

    parser = parser.reset()
    threw = False
    try:
        parseWithNode(
            """
            interface ReflectedAttribute {
              [Frozen, ReflectedHTMLAttributeReturningFrozenArray]
              attribute sequence<long> reflectedHTMLAttribute;
            };
            """
        )

        parser.finish()
    except WebIDL.WebIDLError:
        threw = True
    harness.ok(
        threw,
        "Should have thrown because [ReflectedHTMLAttributeReturningFrozenArray] "
        "should only be used on attributes with a sequence<*Element> type.",
    )

    parser = parser.reset()
    threw = False
    try:
        parseWithNode(
            """
            interface ReflectedAttribute {
              [Frozen, ReflectedHTMLAttributeReturningFrozenArray]
              attribute sequence<Document> reflectedHTMLAttribute;
            };
            """
        )

        parser.finish()
    except WebIDL.WebIDLError:
        threw = True
    harness.ok(
        threw,
        "Should have thrown because [ReflectedHTMLAttributeReturningFrozenArray] "
        "should only be used on attributes with a sequence<*Element> type.",
    )

    parser = parser.reset()
    threw = False
    try:
        parseWithNode(
            """
            interface ReflectedAttribute {
              [ReflectedHTMLAttributeReturningFrozenArray]
              sequence<Element>? reflectedHTMLAttribute();
            };
            """
        )

        parser.finish()
    except WebIDL.WebIDLError:
        threw = True
    harness.ok(
        threw,
        "Should have thrown because [ReflectedHTMLAttributeReturningFrozenArray] "
        "should only be used on attributes with a sequence<*Element> type.",
    )

    parser = parser.reset()
    threw = False
    try:
        parseWithNode(
            """
            interface ReflectedAttribute {
              [Frozen, ReflectedHTMLAttributeReturningFrozenArray, Cached, Pure]
              attribute sequence<Element>? reflectedHTMLAttribute;
            };
            """
        )

        parser.finish()
    except WebIDL.WebIDLError:
        threw = True
    harness.ok(
        threw,
        "Should have thrown because [ReflectedHTMLAttributeReturningFrozenArray] "
        "should not be used together with [Cached].",
    )

    parser = parser.reset()
    threw = False
    try:
        parseWithNode(
            """
            interface ReflectedAttribute {
              [Frozen, ReflectedHTMLAttributeReturningFrozenArray, StoreInSlot, Pure]
              attribute sequence<Element>? reflectedHTMLAttribute;
            };
            """
        )

        parser.finish()
    except WebIDL.WebIDLError:
        threw = True
    harness.ok(
        threw,
        "Should have thrown because [ReflectedHTMLAttributeReturningFrozenArray] "
        "should not be used together with [Cached].",
    )

    parser = parser.reset()
    threw = False
    try:
        parseWithNode(
            """
            interface ReflectedAttributeBase {
              [Frozen, ReflectedHTMLAttributeReturningFrozenArray]
              attribute sequence<Element>? reflectedHTMLAttributeBase;
            };
            interface ReflectedAttribute : ReflectedAttributeBase {
              [Frozen, ReflectedHTMLAttributeReturningFrozenArray]
              attribute sequence<Element>? reflectedHTMLAttribute;
            };
            """
        )

        parser.finish()
    except WebIDL.WebIDLError:
        threw = True
    harness.ok(
        threw,
        "Should have thrown because [ReflectedHTMLAttributeReturningFrozenArray] "
        "should not be used on the attribute of an interface that inherits from "
        "an interface that also has an attribute with "
        "[ReflectedHTMLAttributeReturningFrozenArray].",
    )

Messung V0.5
C=93 H=98 G=95

¤ Dauer der Verarbeitung: 0.9 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.