Example #1
0
def _do_test_raw(script,
                 path='foo.js',
                 bootstrap=False,
                 ignore_pollution=True,
                 detected_type=None,
                 jetpack=False,
                 instant=True):
    """Perform a test on a JS file."""

    err = ErrorBundle(instant=instant)
    if jetpack:
        err.metadata['is_jetpack'] = True

    err.handler = OutputHandler(sys.stdout, True)
    err.supported_versions = {}
    if bootstrap:
        err.save_resource('em:bootstrap', True)
    if detected_type:
        err.detected_type = detected_type

    validator.testcases.content._process_file(err, MockXPI(), path, script,
                                              path.lower(),
                                              not ignore_pollution)
    if err.final_context is not None:
        print 'CONTEXT', repr(err.final_context.keys())

    return err
Example #2
0
def _do_test(path):
    script = validator.unicodehelper.decode(open(path, 'rb').read())
    print script.encode('ascii', 'replace')

    err = ErrorBundle(instant=True)
    err.supported_versions = {}
    err.handler = OutputHandler(sys.stdout, False)
    validator.testcases.scripting.test_js_file(err, path, script)
    return err
Example #3
0
def _do_test_raw(script, path="foo.js", bootstrap=False, ignore_pollution=True,
                 detected_type=None):
    "Performs a test on a JS file"

    err = ErrorBundle(instant=True)
    err.handler = OutputHandler(sys.stdout, True)
    err.supported_versions = {}
    if bootstrap:
        err.save_resource("em:bootstrap", True)
    if detected_type:
        err.detected_type = detected_type

    validator.testcases.content._process_file(
            err, MockXPI(), path, script, path.lower(), not ignore_pollution)
    if err.final_context is not None:
        print err.final_context.output()

    return err
Example #4
0
def _do_test_raw(script, path='foo.js', bootstrap=False, ignore_pollution=True,
                 detected_type=None, jetpack=False, instant=True):
    """Perform a test on a JS file."""

    err = ErrorBundle(instant=instant)
    if jetpack:
        err.metadata['is_jetpack'] = True

    err.handler = OutputHandler(sys.stdout, True)
    err.supported_versions = {}
    if bootstrap:
        err.save_resource('em:bootstrap', True)
    if detected_type:
        err.detected_type = detected_type

    validator.testcases.content._process_file(
        err, MockXPI(), path, script, path.lower(), not ignore_pollution)
    if err.final_context is not None:
        print 'CONTEXT', repr(err.final_context.keys())

    return err
Example #5
0
def _do_test_raw(script, path="foo.js", bootstrap=False, ignore_pollution=True,
                 detected_type=None, jetpack=False):
    "Performs a test on a JS file"

    err = ErrorBundle(instant=True)
    err.save_resource("SPIDERMONKEY", False)
    if jetpack:
        err.metadata["is_jetpack"] = True

    err.handler = OutputHandler(sys.stdout, True)
    err.supported_versions = {}
    if bootstrap:
        err.save_resource("em:bootstrap", True)
    if detected_type:
        err.detected_type = detected_type

    validator.testcases.content._process_file(
            err, MockXPI(), path, script, path.lower(), not ignore_pollution)
    if err.final_context is not None:
        print err.final_context.output()

    return err
Example #6
0
#!/usr/bin/env python

import sys
import os

from validator.errorbundler import ErrorBundle
from validator.outputhandlers.shellcolors import OutputHandler
import validator.testcases.scripting as scripting
import validator.testcases.javascript.traverser
from validator.testcases.javascript.predefinedentities import GLOBAL_ENTITIES
import validator.testcases.javascript.spidermonkey as spidermonkey
validator.testcases.javascript.traverser.DEBUG = True

if __name__ == '__main__':
    err = ErrorBundle(instant=True)
    err.handler = OutputHandler(sys.stdout, False)
    err.supported_versions = {}
    if len(sys.argv) > 1:
        path = sys.argv[1]
        script = open(path).read()
        scripting.test_js_file(err=err,
                               filename=path,
                               data=script)
    else:
        trav = validator.testcases.javascript.traverser.Traverser(err, "stdin")
        trav._push_context()

        def do_inspect(wrapper, arguments, traverser):
            print "~" * 50
            for arg in arguments:
                if arg["type"] == "Identifier":
Example #7
0
import sys
import os

from validator.constants import SPIDERMONKEY_INSTALLATION
from validator.errorbundler import ErrorBundle
from validator.outputhandlers.shellcolors import OutputHandler
import validator.testcases.scripting as scripting
import validator.testcases.javascript.traverser
from validator.testcases.javascript.predefinedentities import GLOBAL_ENTITIES
import validator.testcases.javascript.spidermonkey as spidermonkey
validator.testcases.javascript.traverser.DEBUG = True

if __name__ == '__main__':
    err = ErrorBundle(instant=True)
    err.handler = OutputHandler(sys.stdout, False)
    err.supported_versions = {}
    if len(sys.argv) > 1:
        path = sys.argv[1]
        script = open(path).read()
        scripting.test_js_file(err=err,
                               filename=path,
                               data=script)
    else:
        trav = validator.testcases.javascript.traverser.Traverser(err, "stdin")
        trav._push_context()

        def do_inspect(wrapper, arguments, traverser):
            print "~" * 50
            for arg in arguments:
                if arg["type"] == "Identifier":