This repository has been archived by the owner on Feb 1, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from mattbasta/jsm
JSM/Namespace Pollution/reference overwriting
- Loading branch information
Showing
11 changed files
with
220 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
from js_helper import _do_test | ||
from js_helper import _do_test_raw | ||
|
||
|
||
def test_no_dups(): | ||
"Tests that errors are not duplicated." | ||
"""Test that errors are not duplicated.""" | ||
|
||
assert _do_test_raw(""" | ||
eval("test"); | ||
""").message_count == 1 | ||
|
||
assert _do_test_raw(""" | ||
var x = eval(); | ||
""").message_count == 1 | ||
|
||
assert _do_test_raw(""" | ||
eval = 123; | ||
""").message_count == 1 | ||
|
||
err = _do_test("tests/resources/javascript/dups.js") | ||
assert err.message_count == 6 | ||
# 6 because prototypes are readonly in addition to accessing a member | ||
# of a dangerous object. | ||
assert _do_test_raw(""" | ||
eval.prototype = true; | ||
""").message_count == 2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from js_helper import _do_test_raw | ||
|
||
|
||
def test_jsm_global_overwrites(): | ||
""" | ||
JavaScript modules do not cause global scope conflicts, so we should not | ||
make errors if globals are overwritten. | ||
""" | ||
|
||
assert _do_test_raw(""" | ||
String.prototype.foo = "bar"; | ||
""").failed() | ||
|
||
assert not _do_test_raw(""" | ||
String.prototype.foo = "bar"; | ||
""", path="test.jsm").failed() | ||
|
||
|
||
def test_jsm_EXPORTED_SYMBOLS(): | ||
"""Test that EXPORTED_SYMBOLS is a trigger for JSM.""" | ||
|
||
assert not _do_test_raw(""" | ||
var EXPORTED_SYMBOLS = foo; | ||
String.prototype.foo = "bar"; | ||
""").failed() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from js_helper import _do_test_raw | ||
|
||
|
||
def test_pollution(): | ||
"""Make sure that the JS namespace pollution tests are done properly.""" | ||
|
||
assert not _do_test_raw(""" | ||
a = "foo"; | ||
b = "foo"; | ||
c = "foo"; | ||
""", ignore_pollution=False).failed() | ||
|
||
assert _do_test_raw(""" | ||
a = "foo"; | ||
b = "foo"; | ||
c = "foo"; | ||
d = "foo"; | ||
""", ignore_pollution=False).failed() | ||
|
||
|
||
def test_pollution_jsm(): | ||
""" | ||
Make sure that JSM files don't have to worry about namespace pollution. | ||
""" | ||
|
||
assert not _do_test_raw(""" | ||
a = "foo"; | ||
b = "foo"; | ||
c = "foo"; | ||
d = "foo"; | ||
""", path="foo.jsm", ignore_pollution=False).failed() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.