forked from mozilla/amo-validator
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 mozilla#83 from kmaglione/pref-checks
Preference branch checks for bug 676815
- Loading branch information
Showing
8 changed files
with
193 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
var foo = "network.http"; | ||
var foo = "network.http."; |
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,60 @@ | ||
from js_helper import _do_test_raw | ||
|
||
def test_pref_innocuous_branch(): | ||
""" | ||
Tests that innocuous preferences created outside of the "extensions." branch | ||
from defaults/preferences/*.js files throw warnings, and that ones created | ||
in proper branches don't. | ||
""" | ||
|
||
assert _do_test_raw(""" | ||
pref("foo.bar", true); | ||
""", path="defaults/preferences/prefs.js").failed() | ||
|
||
assert _do_test_raw(""" | ||
user_pref("foo.bar", true); | ||
""", path="defaults/preferences/prefs.js").failed() | ||
|
||
assert _do_test_raw(""" | ||
pref("extensions.foo-bar", true); | ||
""", path="defaults/preferences/prefs.js").failed() | ||
|
||
assert not _do_test_raw(""" | ||
pref("extensions.foo-bar.baz", true); | ||
""", path="defaults/preferences/prefs.js").failed() | ||
|
||
def test_pref_dangerous_branch(): | ||
""" | ||
Test that preferences created in dangerous branches from | ||
defaults/preferences/*.js files throw warnings. | ||
""" | ||
|
||
assert _do_test_raw(""" | ||
pref("extensions.getAddons.get.url", "http://evil.com/"); | ||
""", path="defaults/preferences/prefs.js").failed() | ||
|
||
assert _do_test_raw(""" | ||
user_pref("extensions.getAddons.get.url", "http://evil.com/"); | ||
""", path="defaults/preferences/prefs.js").failed() | ||
|
||
|
||
def test_pref_complex_code(): | ||
""" | ||
Test that calls to functions other than pref() or user_pref() in default | ||
preference files throw warnings and that calls to pref() and user_pref() | ||
don't. | ||
""" | ||
|
||
assert not _do_test_raw(""" | ||
pref(); | ||
user_pref(); | ||
""", path="defaults/preferences/prefs.js").failed() | ||
|
||
assert _do_test_raw(""" | ||
foo(); | ||
""", path="defaults/preferences/prefs.js").failed() | ||
|
||
assert _do_test_raw(""" | ||
foo.bar(); | ||
""", path="defaults/preferences/prefs.js").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
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 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