Skip to content
This repository has been archived by the owner on Feb 1, 2019. It is now read-only.

Commit

Permalink
Update pref tests: flag proxy auto-config prefs, and don't flag exten…
Browse files Browse the repository at this point in the history
…sion sync prefs (bugs 1034298 and 1095899).
  • Loading branch information
kmaglione committed Jan 27, 2015
1 parent b4b8b42 commit 3c7ce14
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 38 deletions.
21 changes: 12 additions & 9 deletions validator/testcases/javascript/actions.py
Expand Up @@ -476,22 +476,25 @@ def _call_create_pref(a, t, e):
value = str(t(a[0]).get_literal_value())

from predefinedentities import BANNED_PREF_BRANCHES, BANNED_PREF_REGEXPS
for banned in BANNED_PREF_BRANCHES:
for banned, reason in BANNED_PREF_BRANCHES:
if value.startswith(banned):
return ("Extensions should not alter preferences in the '%s' "
"preference branch" % banned)
return reason or ("Extensions should not alter preferences in "
"the '%s' preference branch" % banned)

for banned in BANNED_PREF_REGEXPS:
if re.match(banned, value):
return ("Extensions should not alter preferences matching /%s/"
% banned)

if not value.startswith("extensions.") or value.rindex(".") < len("extensions."):
return ("Extensions should not alter preferences outside of the "
"'extensions.' preference branch. Please make sure that "
"all of your extension's preferences are prefixed with "
"'extensions.add-on-name.', where 'add-on-name' is a "
"distinct string unique to and indicative of your add-on.")
for branch in "extensions.", "services.sync.prefs.sync.extensions.":
if value.startswith(branch) and value.rindex(".") > len(branch):
return

return ("Extensions should not alter preferences outside of the "
"'extensions.' preference branch. Please make sure that "
"all of your extension's preferences are prefixed with "
"'extensions.add-on-name.', where 'add-on-name' is a "
"distinct string unique to and indicative of your add-on.")


def _readonly_top(t, r, rn):
Expand Down
65 changes: 39 additions & 26 deletions validator/testcases/javascript/predefinedentities.py
Expand Up @@ -19,32 +19,45 @@
"instead wherever possible",
}

BANNED_PREF_BRANCHES = [
u"browser.newtab.url",
u"browser.newtabpage.enabled",
u"browser.preferences.instantApply",
u"browser.search.defaultenginename",
u"browser.search.searchEnginesURL",
u"browser.startup.homepage",
u"capability.policy.",
u"extensions.alwaysUnpack",
u"extensions.blocklist.",
u"extensions.bootstrappedAddons",
u"extensions.checkCompatibility",
u"extensions.dss.",
u"extensions.getAddons.",
u"extensions.getMoreThemesURL",
u"extensions.installCache",
u"extensions.lastAppVersion",
u"extensions.pendingOperations",
u"extensions.update.",
u"general.useragent.",
u"keyword.URL",
u"keyword.enabled",
u"network.http.",
u"network.websocket.",
u"nglayout.debug.disable_xul_cache",
]
CUSTOMIZATION_PREF_MESSAGE = (
"Extensions must not alter user preferences such as the current home "
"page, new tab page, or search engine, without explicit user consent, "
"in which a user takes a non-default action. Such changes must also "
"be reverted when the extension is disabled or uninstalled.")

BANNED_PREF_BRANCHES = (
(u"browser.newtab.url", CUSTOMIZATION_PREF_MESSAGE),
(u"browser.newtabpage.enabled", CUSTOMIZATION_PREF_MESSAGE),
(u"browser.preferences.instantApply", None),
(u"browser.search.defaultenginename", CUSTOMIZATION_PREF_MESSAGE),
(u"browser.search.searchEnginesURL", CUSTOMIZATION_PREF_MESSAGE),
(u"browser.startup.homepage", CUSTOMIZATION_PREF_MESSAGE),
(u"capability.policy.", None),
(u"extensions.alwaysUnpack", None),
(u"extensions.blocklist.", None),
(u"extensions.bootstrappedAddons", None),
(u"extensions.checkCompatibility", None),
(u"extensions.dss.", None),
(u"extensions.getAddons.", None),
(u"extensions.getMoreThemesURL", None),
(u"extensions.installCache", None),
(u"extensions.lastAppVersion", None),
(u"extensions.pendingOperations", None),
(u"extensions.update.", None),
(u"general.useragent.", None),
(u"keyword.URL", CUSTOMIZATION_PREF_MESSAGE),
(u"keyword.enabled", CUSTOMIZATION_PREF_MESSAGE),
(u"network.proxy.autoconfig_url",
"As many add-ons have reason to change the proxy autoconfig URL, and "
"only one at a time may do so without conflict, extensions must "
"make proxy changes using other mechanisms. Installing a proxy "
"filter is the recommended alternative: "
"https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/"
"Reference/Interface/nsIProtocolProxyService#registerFilter()"),
(u"network.http.", None),
(u"network.websocket.", None),
(u"nglayout.debug.disable_xul_cache", None),
)

BANNED_PREF_REGEXPS = [
r"extensions\..*\.update\.(url|enabled|interval)",
Expand Down
6 changes: 3 additions & 3 deletions validator/testcases/regex.py
Expand Up @@ -291,12 +291,12 @@ def tests(self):
"Extensions should not alter preferences matching /%s/."
% pattern)

for branch in BANNED_PREF_BRANCHES:
for branch, reason in BANNED_PREF_BRANCHES:
yield self.get_test(
branch.replace(r".", r"\."),
"Potentially unsafe preference branch referenced",
"Extensions should not alter preferences in the `%s` "
"preference branch" % branch)
reason or ("Extensions should not alter preferences in "
"the `%s` preference branch" % branch))


REQUIRE_PATTERN = (r"""(?<!['"])require\s*\(\s*['"]"""
Expand Down

0 comments on commit 3c7ce14

Please sign in to comment.