Skip to content

Commit

Permalink
More refactoring for JS engine
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbasta committed Sep 11, 2012
1 parent e8e61f5 commit 882b73c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions jsmain.py
Expand Up @@ -52,6 +52,7 @@ def do_exit(wrapper, arguments, traverser):

while True:
line = raw_input("js> ")
trav._debug_level = 0
if line == "enable bootstrap\n":
err.save_resource("em:bootstrap", True)
continue
Expand Down
17 changes: 10 additions & 7 deletions tests/test_js_content_scripts.py
Expand Up @@ -8,12 +8,16 @@ def test_pagemod_noop():
Test that invalid conditions do not throw exceptions or messages when the
PageMod function is used improperly.
"""
assert not _do_test_raw("foo.PageMod();").failed()
assert not _do_test_raw("foo.PageMod(null);").failed()
assert not _do_test_raw("foo.PageMod({});").failed()
assert not _do_test_raw("foo.PageMod(window);").failed()
assert not _do_test_raw("foo.PageMod({contentScript: null});").failed()
assert not _do_test_raw("foo.PageMod({contentScript: 4});").failed()

def wrap(script):
assert not _do_test_raw(script).failed()

yield wrap, "foo.PageMod();"
yield wrap, "foo.PageMod(null);"
yield wrap, "foo.PageMod({});"
yield wrap, "foo.PageMod(window);"
yield wrap, "foo.PageMod({contentScript: null});"
yield wrap, "foo.PageMod({contentScript: 4});"


def test_pagemod_pass():
Expand All @@ -39,4 +43,3 @@ def test_pagemod_fail():
assert _do_test_raw("""
foo.PageMod({contentScript: "ev" + "al();"});
""").failed()

7 changes: 3 additions & 4 deletions tests/test_packagelayout.py
@@ -1,3 +1,5 @@
from itertools import repeat

import validator.testcases.packagelayout as packagelayout
from validator.errorbundler import ErrorBundle
from helper import _do_test, MockXPI
Expand Down Expand Up @@ -30,10 +32,7 @@ def test_java_jar_detection():
"""

classes = ("c%d.class" % i for i in xrange(1000))
def strings(): # Look at how functional this is. How functional!
while 1:
yield ""
mock_xpi = MockXPI(dict(zip(classes, strings())))
mock_xpi = MockXPI(dict(zip(classes, repeat(""))))
err = ErrorBundle(None, True)
packagelayout.test_blacklisted_files(err, mock_xpi)

Expand Down

0 comments on commit 882b73c

Please sign in to comment.