Beispiel #1
0
def test_js_file(err, filename, data, line=0, context=None, pollutable=False):
    "Tests a JS file by parsing and analyzing its tokens"

    if SPIDERMONKEY_INSTALLATION is None or \
       err.get_resource("SPIDERMONKEY") is None:  # Default value is False
        return

    before_tier = None
    # Set the tier to 4 (Security Tests)
    if err is not None:
        before_tier = err.tier
        err.set_tier(3)

    tree = get_tree(data,
                    filename=filename,
                    shell=(err and err.get_resource("SPIDERMONKEY")) or
                          SPIDERMONKEY_INSTALLATION,
                    err=err)
    if not tree:
        if before_tier:
            err.set_tier(before_tier)
        return

    # Generate a context if one is not available.
    if context is None:
        context = ContextGenerator(data)

    t = traverser.Traverser(err, filename, line, context=context)
    t.pollutable = pollutable
    t.run(tree)

    # Reset the tier so we don't break the world
    if err is not None:
        err.set_tier(before_tier)
def test_js_file(err, filename, data, line=0, context=None):
    "Tests a JS file by parsing and analyzing its tokens"

    if (SPIDERMONKEY_INSTALLATION is None or
        err.get_resource("SPIDERMONKEY") is None):  # Default value is False
        return

    # Set the tier to 4 (Security Tests)
    if err is not None:
        before_tier = err.tier
        err.set_tier(3)

    tree = get_tree(data, err, filename,
                    err and err.get_resource("SPIDERMONKEY") or
                    SPIDERMONKEY_INSTALLATION)
    if not tree:
        err.metadata["ran_js_tests"] = "no;missing ast"
        if err is not None:
            err.set_tier(before_tier)
        return

    trav = traverser.Traverser(
        err, filename, line, context=context or ContextGenerator(data))
    trav.run(tree)

    err.metadata["ran_js_tests"] = "yes"

    # Reset the tier so we don't break the world
    if err is not None:
        err.set_tier(before_tier)
Beispiel #3
0
def test_js_file(err, filename, data, line=0, context=None):
    "Tests a JS file by parsing and analyzing its tokens"

    if (SPIDERMONKEY_INSTALLATION is None or
        err.get_resource("SPIDERMONKEY") is None):  # Default value is False
        return

    # Set the tier to 4 (Security Tests)
    if err is not None:
        before_tier = err.tier
        err.set_tier(3)

    tree = get_tree(data, err, filename,
                    err and err.get_resource("SPIDERMONKEY") or
                    SPIDERMONKEY_INSTALLATION)
    if not tree:
        if err is not None:
            err.set_tier(before_tier)
        return

    trav = traverser.Traverser(
        err, filename, line, context=context or ContextGenerator(data))
    trav.run(tree)

    # Reset the tier so we don't break the world
    if err is not None:
        err.set_tier(before_tier)