示例#1
0
def test_scripting_enabled():
    err = ErrorBundle()
    err.save_resource("SPIDERMONKEY", None)
    assert scripting.test_js_file(err, "abc def", "foo bar") is None
示例#2
0
def test_scripting_disabled():
    """Ensures that Spidermonkey is not run if it is set to be disabled."""
    err = ErrorBundle()
    assert scripting.test_js_file(err, "abc def", "foo bar") is None
def test_scripting_disabled():
    """Ensures that Spidermonkey is not run if it is set to be disabled."""
    err = ErrorBundle()
    assert scripting.test_js_file(err, "abc def", "foo bar") is None
示例#4
0
from appvalidator.errorbundle.outputhandlers.shellcolors import OutputHandler
import appvalidator.testcases.scripting as scripting
import appvalidator.testcases.javascript.traverser
from appvalidator.testcases.javascript.predefinedentities import GLOBAL_ENTITIES
import appvalidator.testcases.javascript.spidermonkey as spidermonkey

appvalidator.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 = appvalidator.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":
                    print 'Identifier: "%s"' % arg["name"]
                else:
                    print arg["type"]

                a = traverser._traverse_node(arg)
                print a.output()
def test_scripting_enabled():
    err = ErrorBundle()
    err.save_resource("SPIDERMONKEY", None)
    assert scripting.test_js_file(err, "abc def", "foo bar") is None
示例#6
0
from appvalidator.errorbundle.outputhandlers.shellcolors import OutputHandler
import appvalidator.testcases.scripting as scripting
import appvalidator.testcases.javascript.traverser
from appvalidator.testcases.javascript.predefinedentities import GLOBAL_ENTITIES
import appvalidator.testcases.javascript.spidermonkey as spidermonkey
appvalidator.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 = appvalidator.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":
                    print 'Identifier: "%s"' % arg["name"]
                else:
                    print arg["type"]

                a = traverser._traverse_node(arg)
                print a.output()
示例#7
0
                  help="Path to test, or directory containing tests. "
                       "Directories will be recursively searched."
parser.add_option("-v", "--verbose", dest="verbose",
                  default=False,
                  action="store_true",
                  help="Use verbose mode for output.")

opt, args = parser.parse_args()

if os.path.isfile(opt.test):
    files = [opt.test]
else:
    files = []
    for root, folders, fileList in os.walk(opt.test):
        for f in fileList:
            files.append(os.path.join(root,f))

bundle = ErrorBundle()
for name in files:
    print name
    f = open(name, 'r')
    if name.endswith('.js'):
        test_js_file(bundle, name, f.read())
    else:
        soup = BeautifulSoup(f.read())
        for script in soup.find_all('script'):
            test_js_snippet(bundle, script.renderContents(), name)
    f.close()

print bundle.print_summary(verbose=opt.verbose)
def test_tempfiles_are_not_used_when_not_needed(run_with_tempfile):
    run_with_tempfile.return_value = "{}"
    err = ErrorBundle()
    scripting.test_js_file(err, "foo.js", "var x = [123, 456];")
    assert not run_with_tempfile.called
def test_crazy_unicode():
    err = ErrorBundle()
    with open('tests/resources/spidermonkey_unicode.js', 'r') as f:
        scripting.test_js_file(err, "foo.js", f.read())
    assert not err.failed(), err.errors + err.warnings