Bug 1618188 - remove XML backend for plugin and add-on blocklisting, r=mconley,perftest-reviewers,whimboo

This removes the obsolete backend. Notes on some of the less obvious changes
made as part of this patch:

- some of the gFoo style getters in Blocklist.jsm were only used by the XML
  version of the blocklist; I've removed them and tried to remove spurious
  settings of those properties in the remaining tests.
- some utility methods (e.g. distribution information getters) were also only
  used for the XML version (for the update URL).
- it's no longer necessary to test switching implementations.
- in browser/base/content/test/plugins/, we ran some tests from two manifests
  in order to run them with both blocklist backends. The simplest way of
  reducing this back down to one was to remove the remote-settings one. If I'd
  been more future-oriented when I created the duplication, perhaps I would
  have moved the XML version out into a different manifest instead, but I
  didn't, so now it looks like we're removing the modern one, whereas really
  we're going to be running the modern one as part of the "normal" tests and
  we're no longer running the "old" tests.
- removed all mentions I could see of extensions.blocklist.url which is no
  longer used for anything.
- per https://bugzilla.mozilla.org/show_bug.cgi?id=1016555#c23, updated
  references for the OneCRL timing and how it relates to blocklist updates.

Differential Revision: https://phabricator.services.mozilla.com/D64933

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gijs Kruitbosch 2020-03-09 12:02:17 +00:00
parent 03b081f658
commit f1a04bd343
80 changed files with 87 additions and 12341 deletions

View File

@ -941,10 +941,6 @@ module.exports = {
"toolkit/mozapps/extensions/test/xpcshell/test_webextension.js",
"toolkit/mozapps/extensions/test/xpcshell/test_webextension_events.js",
"toolkit/mozapps/extensions/test/xpcshell/test_XPIStates.js",
"toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_gfx.js",
"toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_telemetry.js",
"toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklistchange.js",
"toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_overrideblocklist.js",
"toolkit/mozapps/installer/precompile_cache.js",
],
rules: {

File diff suppressed because it is too large Load Diff

View File

@ -7,9 +7,6 @@
with Files("**"):
BUG_COMPONENT = ("Firefox", "General")
with Files("blocklist.xml"):
BUG_COMPONENT = ("Toolkit", "Blocklist Implementation")
with Files("firefox.exe.manifest"):
BUG_COMPONENT = ("Core", "Widget: Win32")
with Files("module.ver"):

View File

@ -198,36 +198,6 @@ function popPrefs() {
return SpecialPowers.popPrefEnv();
}
function updateBlocklist(aCallback) {
var blocklistNotifier = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
var observer = function() {
Services.obs.removeObserver(observer, "blocklist-updated");
SimpleTest.executeSoon(aCallback);
};
Services.obs.addObserver(observer, "blocklist-updated");
blocklistNotifier.notify(null);
}
var _originalTestBlocklistURL = null;
function setAndUpdateBlocklist(aURL, aCallback) {
if (!_originalTestBlocklistURL) {
_originalTestBlocklistURL = Services.prefs.getCharPref(
"extensions.blocklist.url"
);
}
Services.prefs.setCharPref("extensions.blocklist.url", aURL);
updateBlocklist(aCallback);
}
function resetBlocklist() {
Services.prefs.setCharPref(
"extensions.blocklist.url",
_originalTestBlocklistURL
);
}
function promiseWindowClosed(win) {
let promise = BrowserTestUtils.domWindowClosed(win);
win.close();

View File

@ -1,7 +0,0 @@
<?xml version="1.0"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1336406310001">
<emItems>
</emItems>
<pluginItems>
</pluginItems>
</blocklist>

View File

@ -1,11 +0,0 @@
<?xml version="1.0"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1336406310000">
<emItems>
</emItems>
<pluginItems>
<pluginItem blockID="p9999">
<match name="filename" exp="libnptest\.so|nptest\.dll|Test\.plugin" />
<versionRange severity="2"></versionRange>
</pluginItem>
</pluginItems>
</blocklist>

View File

@ -1,12 +0,0 @@
<?xml version="1.0"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1336406310000">
<emItems>
</emItems>
<pluginItems>
<pluginItem blockID="p9999">
<match name="filename" exp="libnptest\.so|nptest\.dll|Test\.plugin" />
<versionRange severity="2"></versionRange>
<infoURL>http://test.url.com/</infoURL>
</pluginItem>
</pluginItems>
</blocklist>

View File

@ -1,11 +0,0 @@
<?xml version="1.0"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1336406310000">
<emItems>
</emItems>
<pluginItems>
<pluginItem blockID="p9999">
<match name="filename" exp="libnptest\.so|nptest\.dll|Test\.plugin" />
<versionRange severity="0" vulnerabilitystatus="2"></versionRange>
</pluginItem>
</pluginItems>
</blocklist>

View File

@ -1,11 +0,0 @@
<?xml version="1.0"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1336406310000">
<emItems>
</emItems>
<pluginItems>
<pluginItem blockID="p9999">
<match name="filename" exp="libnptest\.so|nptest\.dll|Test\.plugin" />
<versionRange severity="0" vulnerabilitystatus="1"></versionRange>
</pluginItem>
</pluginItems>
</blocklist>

View File

@ -1,60 +0,0 @@
# Note: this manifest duplicates all the `blocklist` tagged tests from
# browser.ini, because we can't share a list of tests between 2 manifests and
# set different prefs in both manifests, because runtests.py complains about
# the fact that the prefs aren't set in the common (included) manifest that
# has the list of tests. Bug 1551885 covers fixing this.
# If you need to add/skip/remove tests, you may want to do so in both
# manifests. Sorry!
[DEFAULT]
dupe-manifest =
prefs =
extensions.blocklist.useXML=false
plugin.load_flash_only=false
tags = blocklist rsblock
support-files =
blocklist_proxy.js
blockNoPlugins-plugins.json
blockPluginHard-plugins.json
blockPluginInfoURL-plugins.json
blockPluginVulnerableNoUpdate-plugins.json
blockPluginVulnerableUpdatable-plugins.json
browser_clearplugindata.html
browser_clearplugindata_noage.html
head.js
plugin_add_dynamically.html
plugin_alternate_content.html
plugin_big.html
plugin_bug749455.html
plugin_hidden_to_visible.html
plugin_iframe.html
plugin_outsideScrollArea.html
plugin_small.html
plugin_small_2.html
plugin_syncRemoved.html
plugin_test.html
plugin_test2.html
plugin_two_types.html
plugin_unknown.html
plugin_zoom.html
[browser_bug743421.js]
[browser_bug812562.js]
[browser_clearplugindata.js]
[browser_CTP_context_menu.js]
skip-if = fission || toolkit == "gtk" # Fails with Fission, and we're unlikely to spend time to fix it. fails intermittently on Linux (bug 909342)
[browser_CTP_crashreporting.js]
skip-if = !crashreporter || verify || os == 'win' # bug 1442837
[browser_CTP_drag_drop.js]
[browser_CTP_hide_overlay.js]
[browser_CTP_iframe.js]
skip-if = os == 'win' && !debug # Bug 1519868
[browser_CTP_nonplugins.js]
skip-if = verify
[browser_CTP_outsideScrollArea.js]
[browser_CTP_resize.js]
[browser_CTP_zoom.js]
[browser_blocking.js]
[browser_pluginnotification.js]
[browser_plugin_reloading.js]
[browser_blocklist_content.js]
skip-if = !e10s

View File

@ -1,22 +1,13 @@
# Note: the `blocklist` tagged tests are also in browser-rs-blocklist.ini,
# because we can't share a list of tests between 2 manifests and
# set different prefs in both manifests, because runtests.py complains about
# the fact that the prefs aren't set in the common (included) manifest that
# has the list of tests. Bug 1551885 covers fixing this.
# If you need to add/skip/remove tests, you may want to do so in both
# manifests. Sorry!
[DEFAULT]
dupe-manifest =
prefs =
extensions.blocklist.useXML=true
plugin.load_flash_only=false
support-files =
blocklist_proxy.js
blockNoPlugins.xml
blockPluginHard.xml
blockPluginInfoURL.xml
blockPluginVulnerableNoUpdate.xml
blockPluginVulnerableUpdatable.xml
blockNoPlugins-plugins.json
blockPluginHard-plugins.json
blockPluginInfoURL-plugins.json
blockPluginVulnerableNoUpdate-plugins.json
blockPluginVulnerableUpdatable-plugins.json
browser_clearplugindata.html
browser_clearplugindata_noage.html
empty_file.html

View File

@ -28,7 +28,6 @@ add_task(async function() {
gTestRoot + "blockNoPlugins",
gTestBrowser
);
resetBlocklist();
gBrowser.removeCurrentTab();
window.focus();
gTestBrowser = null;

View File

@ -18,7 +18,6 @@ add_task(async function() {
gTestRoot + "blockNoPlugins",
gTestBrowser
);
resetBlocklist();
gBrowser.removeCurrentTab();
window.focus();
gTestBrowser = null;

View File

@ -16,7 +16,6 @@ add_task(async function() {
gTestRoot + "blockNoPlugins",
gTestBrowser
);
resetBlocklist();
gBrowser.removeCurrentTab();
window.focus();
gTestBrowser = null;

View File

@ -16,7 +16,6 @@ add_task(async function() {
gTestRoot + "blockNoPlugins",
gTestBrowser
);
resetBlocklist();
gBrowser.removeCurrentTab();
window.focus();
gTestBrowser = null;

View File

@ -22,7 +22,6 @@ add_task(async function() {
gTestRoot + "blockNoPlugins",
gTestBrowser
);
resetBlocklist();
gTestBrowser = null;
gBrowser.removeCurrentTab();
window.focus();

View File

@ -22,7 +22,6 @@ add_task(async function() {
gTestRoot + "blockNoPlugins",
gTestBrowser
);
resetBlocklist();
gTestBrowser = null;
gBrowser.removeCurrentTab();
window.focus();

View File

@ -307,26 +307,11 @@ let JSONBlocklistWrapper = {
// An async helper that insures a new blocklist is loaded (in both
// processes if applicable).
var _originalTestBlocklistURL = null;
async function asyncSetAndUpdateBlocklist(aURL, aBrowser) {
let doTestRemote = aBrowser ? aBrowser.isRemoteBrowser : false;
if (!_originalTestBlocklistURL) {
_originalTestBlocklistURL = Services.prefs.getCharPref(
"extensions.blocklist.url"
);
}
let localPromise = TestUtils.topicObserved("plugin-blocklist-updated");
if (Services.prefs.getBoolPref("extensions.blocklist.useXML", true)) {
info("*** loading new blocklist: " + aURL + ".xml");
Services.prefs.setCharPref("extensions.blocklist.url", aURL + ".xml");
let blocklistNotifier = Cc[
"@mozilla.org/extensions/blocklist;1"
].getService(Ci.nsITimerCallback);
blocklistNotifier.notify(null);
} else {
info("*** loading blocklist using json: " + aURL);
await JSONBlocklistWrapper.loadBlocklistData(aURL);
}
info("*** loading blocklist: " + aURL);
await JSONBlocklistWrapper.loadBlocklistData(aURL);
info("*** waiting on local load");
await localPromise;
if (doTestRemote) {
@ -337,14 +322,6 @@ async function asyncSetAndUpdateBlocklist(aURL, aBrowser) {
info("*** blocklist loaded.");
}
// Reset back to the blocklist we had at the start of the test run.
function resetBlocklist() {
Services.prefs.setCharPref(
"extensions.blocklist.url",
_originalTestBlocklistURL
);
}
// Insure there's a popup notification present. This test does not indicate
// open state. aBrowser can be undefined.
function promisePopupNotification(aName, aBrowser) {

View File

@ -39,7 +39,6 @@ BROWSER_CHROME_MANIFESTS += [
'content/test/performance/io/browser.ini',
'content/test/performance/lowdpi/browser.ini',
'content/test/permissions/browser.ini',
'content/test/plugins/browser-rs-blocklist.ini',
'content/test/plugins/browser.ini',
'content/test/popupNotifications/browser.ini',
'content/test/popups/browser.ini',

View File

@ -146,7 +146,6 @@
@BINPATH@/@DLL_PREFIX@mozavutil@DLL_SUFFIX@
@BINPATH@/@DLL_PREFIX@mozavcodec@DLL_SUFFIX@
#endif
@RESPATH@/browser/blocklist.xml
#ifdef XP_WIN
#ifdef _AMD64_
@BINPATH@/@DLL_PREFIX@qipcap64@DLL_SUFFIX@

View File

@ -55,7 +55,6 @@ if CONFIG['MOZ_GPSD']:
JS_PREFERENCE_PP_FILES += [
'app/profile/firefox.js',
]
FINAL_TARGET_FILES += ['app/blocklist.xml']
FINAL_TARGET_FILES.defaults += ['app/permissions']
with Files("**"):

View File

@ -91,7 +91,6 @@
; [Base Browser Files]
@BINPATH@/application.ini
@BINPATH@/platform.ini
@BINPATH@/blocklist.xml
@BINPATH@/defaults/settings/blocklists/addons.json
@BINPATH@/defaults/settings/security-state/onecrl.json

View File

@ -2315,6 +2315,7 @@ pref("security.cert_pinning.process_headers_from_non_builtin_roots", false);
pref("security.cert_pinning.hpkp.enabled", false);
// Remote settings preferences
// Note: if you change this, make sure to also review security.onecrl.maximum_staleness_in_seconds
pref("services.settings.poll_interval", 86400); // 24H
pref("services.settings.server", "https://firefox.settings.services.mozilla.com/v1");
pref("services.settings.default_bucket", "main");
@ -2340,15 +2341,10 @@ pref("extensions.abuseReport.amoDetailsURL", "https://services.addons.mozilla.or
// Blocklist preferences
pref("extensions.blocklist.enabled", true);
// OneCRL freshness checking depends on this value, so if you change it,
// please also update security.onecrl.maximum_staleness_in_seconds.
pref("extensions.blocklist.interval", 86400);
// Whether to use the XML backend (true) or the remotesettings one (false).
pref("extensions.blocklist.useXML", false);
// Required blocklist freshness for OneCRL OCSP bypass
// (default is 1.25x extensions.blocklist.interval, or 30 hours)
// Required blocklist freshness for OneCRL OCSP bypass (default is 30 hours)
// Note that this needs to exceed the interval at which we update OneCRL data,
// configured in services.settings.poll_interval .
pref("security.onecrl.maximum_staleness_in_seconds", 108000);
pref("extensions.blocklist.url", "https://blocklists.settings.services.mozilla.com/v1/blocklist/3/%APP_ID%/%APP_VERSION%/%PRODUCT%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/%PING_COUNT%/%TOTAL_PING_COUNT%/%DAYS_SINCE_LAST_PING%/");
pref("extensions.blocklist.detailsURL", "https://blocked.cdn.mozilla.net/");
pref("extensions.blocklist.itemURL", "https://blocked.cdn.mozilla.net/%blockID%.html");
// Controls what level the blocklist switches from warning about items to forcibly

View File

@ -44,7 +44,6 @@ user_pref("dom.disable_window_move_resize", true);
user_pref("dom.push.connection.enabled", false);
user_pref("extensions.autoDisableScopes", 10);
user_pref("extensions.blocklist.enabled", false);
user_pref("extensions.blocklist.url", "http://127.0.0.1/extensions-dummy/blocklistURL");
user_pref("extensions.checkCompatibility", false);
user_pref("extensions.getAddons.get.url", "http://127.0.0.1/extensions-dummy/repositoryGetURL");
user_pref("extensions.getAddons.search.browseURL", "http://127.0.0.1/extensions-dummy/repositoryBrowseURL");

View File

@ -100,7 +100,6 @@ user_pref("dom.use_xbl_scopes_for_remote_xul", true);
user_pref("extensions.autoDisableScopes", 0);
user_pref("extensions.blocklist.detailsURL", "http://{server}/extensions-dummy/blocklistDetailsURL");
user_pref("extensions.blocklist.itemURL", "http://{server}/extensions-dummy/blocklistItemURL");
user_pref("extensions.blocklist.url", "http://{server}/extensions-dummy/blocklistURL");
// XPI extensions are required for test harnesses to load
user_pref("extensions.defaultProviders.enabled", true);
// Disable metadata caching for installed add-ons by default

View File

@ -1 +1 @@
{'deviceroot': '', 'dirs': {}, 'repository': 'https://hg.mozilla.org/releases/mozilla-release', 'buildid': '20131205075310', 'results_log': 'pathtoresults_log', 'symbols_path': None, 'bcontroller_config': 'pathtobcontroller', 'host': '', 'browser_name': 'Firefox', 'sourcestamp': '39faf812aaec', 'remote': False, 'child_process': 'plugin-container', 'browser_version': '26.0', 'extra_args': '', 'develop': True, 'preferences': {'browser.display.overlaynavbuttons': False, 'extensions.getAddons.get.url': 'http://127.0.0.1/extensions-dummy/repositoryGetURL', 'dom.max_chrome_script_run_time': 0, 'network.proxy.type': 1, 'extensions.update.background.url': 'http://127.0.0.1/extensions-dummy/updateBackgroundURL', 'network.proxy.http': 'localhost', 'plugins.update.url': 'http://127.0.0.1/plugins-dummy/updateCheckURL', 'dom.max_script_run_time': 0, 'extensions.update.enabled': False, 'browser.safebrowsing.keyURL': 'http://127.0.0.1/safebrowsing-dummy/newkey', 'media.navigator.permission.disabled': True, 'app.update.checkInstallTime': False, 'app.update.disabledForTesting': True, 'extensions.blocklist.url': 'http://127.0.0.1/extensions-dummy/blocklistURL', 'browser.EULA.override': True, 'extensions.checkCompatibility': False, 'talos.logfile': 'pathtofile', 'browser.safebrowsing.gethashURL': 'http://127.0.0.1/safebrowsing-dummy/gethash', 'extensions.hotfix.url': 'http://127.0.0.1/extensions-dummy/hotfixURL', 'dom.disable_window_move_resize': True, 'network.proxy.http_port': 80, 'browser.dom.window.dump.enabled': True, 'extensions.update.url': 'http://127.0.0.1/extensions-dummy/updateURL', 'browser.chrome.dynamictoolbar': False, 'browser.link.open_newwindow': 2, 'security.turn_off_all_security_so_that_viruses_can_take_over_this_computer': True, 'dom.disable_open_during_load': False, 'extensions.getAddons.search.browseURL': 'http://127.0.0.1/extensions-dummy/repositoryBrowseURL', 'browser.cache.disk.smart_size.enabled': False, 'hangmonitor.timeout': 0, 'dom.send_after_paint_to_content': True, 'security.fileuri.strict_origin_policy': False, 'media.capturestream_hints.enabled': True, 'extensions.update.notifyUser': False, 'extensions.blocklist.enabled': False, 'browser.bookmarks.max_backups': 0, 'browser.shell.checkDefaultBrowser': False, 'media.peerconnection.enabled': True, 'dom.disable_window_flip': True, 'security.enable_java': False, 'browser.warnOnQuit': False, 'media.navigator.enabled': True, 'browser.safebrowsing.updateURL': 'http://127.0.0.1/safebrowsing-dummy/update', 'dom.allow_scripts_to_close_windows': True, 'extensions.webservice.discoverURL': 'http://127.0.0.1/extensions-dummy/discoveryURL'}, 'test_timeout': 1200, 'title': 'qm-pxp01', 'error_filename': 'pathtoerrorfile', 'webserver': 'localhost:15707', 'browser_path':ffox_path, 'port': 20701, 'browser_log': 'browser_output.txt', 'process': 'firefox.exe', 'xperf_path': 'C:/Program Files/Microsoft Windows Performance Toolkit/xperf.exe', 'extensions': ['pathtopageloader'], 'fennecIDs': '', 'init_url': 'http://localhost:15707/getInfo.html', 'browser_wait': 5}
{'deviceroot': '', 'dirs': {}, 'repository': 'https://hg.mozilla.org/releases/mozilla-release', 'buildid': '20131205075310', 'results_log': 'pathtoresults_log', 'symbols_path': None, 'bcontroller_config': 'pathtobcontroller', 'host': '', 'browser_name': 'Firefox', 'sourcestamp': '39faf812aaec', 'remote': False, 'child_process': 'plugin-container', 'browser_version': '26.0', 'extra_args': '', 'develop': True, 'preferences': {'browser.display.overlaynavbuttons': False, 'extensions.getAddons.get.url': 'http://127.0.0.1/extensions-dummy/repositoryGetURL', 'dom.max_chrome_script_run_time': 0, 'network.proxy.type': 1, 'extensions.update.background.url': 'http://127.0.0.1/extensions-dummy/updateBackgroundURL', 'network.proxy.http': 'localhost', 'plugins.update.url': 'http://127.0.0.1/plugins-dummy/updateCheckURL', 'dom.max_script_run_time': 0, 'extensions.update.enabled': False, 'browser.safebrowsing.keyURL': 'http://127.0.0.1/safebrowsing-dummy/newkey', 'media.navigator.permission.disabled': True, 'app.update.checkInstallTime': False, 'app.update.disabledForTesting': True, 'browser.EULA.override': True, 'extensions.checkCompatibility': False, 'talos.logfile': 'pathtofile', 'browser.safebrowsing.gethashURL': 'http://127.0.0.1/safebrowsing-dummy/gethash', 'extensions.hotfix.url': 'http://127.0.0.1/extensions-dummy/hotfixURL', 'dom.disable_window_move_resize': True, 'network.proxy.http_port': 80, 'browser.dom.window.dump.enabled': True, 'extensions.update.url': 'http://127.0.0.1/extensions-dummy/updateURL', 'browser.chrome.dynamictoolbar': False, 'browser.link.open_newwindow': 2, 'security.turn_off_all_security_so_that_viruses_can_take_over_this_computer': True, 'dom.disable_open_during_load': False, 'extensions.getAddons.search.browseURL': 'http://127.0.0.1/extensions-dummy/repositoryBrowseURL', 'browser.cache.disk.smart_size.enabled': False, 'hangmonitor.timeout': 0, 'dom.send_after_paint_to_content': True, 'security.fileuri.strict_origin_policy': False, 'media.capturestream_hints.enabled': True, 'extensions.update.notifyUser': False, 'extensions.blocklist.enabled': False, 'browser.bookmarks.max_backups': 0, 'browser.shell.checkDefaultBrowser': False, 'media.peerconnection.enabled': True, 'dom.disable_window_flip': True, 'security.enable_java': False, 'browser.warnOnQuit': False, 'media.navigator.enabled': True, 'browser.safebrowsing.updateURL': 'http://127.0.0.1/safebrowsing-dummy/update', 'dom.allow_scripts_to_close_windows': True, 'extensions.webservice.discoverURL': 'http://127.0.0.1/extensions-dummy/discoveryURL'}, 'test_timeout': 1200, 'title': 'qm-pxp01', 'error_filename': 'pathtoerrorfile', 'webserver': 'localhost:15707', 'browser_path':ffox_path, 'port': 20701, 'browser_log': 'browser_output.txt', 'process': 'firefox.exe', 'xperf_path': 'C:/Program Files/Microsoft Windows Performance Toolkit/xperf.exe', 'extensions': ['pathtopageloader'], 'fennecIDs': '', 'init_url': 'http://localhost:15707/getInfo.html', 'browser_wait': 5}

View File

@ -4078,29 +4078,6 @@ networking:
release_channel_collection: opt-out
blocklist:
lastModified_xml:
bug_numbers:
- 1572711
- 1607744
description: >
Keep track of the lastupdate datetime from a successfully loaded xml blocklist,
set to "Invalid Date" or "Missing Date" when the timestamp is invalid or missing.
(based on the lastupdate attribute set on the XML document element,
converted from a milliseconds timestamp into a datetime string in UTC format).
expires: "77"
kind: string
release_channel_collection: opt-out
notification_emails:
- addons-dev-internal@mozilla.com
- lgreco@mozilla.com
- awagner@mozilla.com
products:
- 'firefox'
- 'fennec'
- 'thunderbird'
record_in_processes:
- main
lastModified_rs_addons:
bug_numbers:
- 1572711
@ -4144,27 +4121,6 @@ blocklist:
record_in_processes:
- main
useXML:
bug_numbers:
- 1572711
- 1607744
description: >
Keep track of the currently enabled blocklist engine (set to false if the
remote settings blocklist is the one enabled).
expires: "77"
kind: boolean
release_channel_collection: opt-out
notification_emails:
- addons-dev-internal@mozilla.com
- lgreco@mozilla.com
- awagner@mozilla.com
products:
- 'firefox'
- 'fennec'
- 'thunderbird'
record_in_processes:
- main
firstStartup:
statusCode:
bug_numbers:

View File

@ -264,7 +264,6 @@ const DEFAULT_ENVIRONMENT_PREFS = new Map([
["extensions.autoDisableScopes", { what: RECORD_PREF_VALUE }],
["extensions.enabledScopes", { what: RECORD_PREF_VALUE }],
["extensions.blocklist.enabled", { what: RECORD_PREF_VALUE }],
["extensions.blocklist.url", { what: RECORD_PREF_VALUE }],
["extensions.formautofill.addresses.enabled", { what: RECORD_PREF_VALUE }],
["extensions.formautofill.creditCards.enabled", { what: RECORD_PREF_VALUE }],
["extensions.strictCompatibility", { what: RECORD_PREF_VALUE }],

File diff suppressed because it is too large Load Diff

View File

@ -11,9 +11,6 @@ Classes = [
'jsm': 'resource://gre/modules/addonManager.js',
'constructor': 'BlocklistService',
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
'categories': ({'profile-after-change': 'nsBlocklistService'}
if buildconfig.substs['MOZ_BUILD_APP'] != 'browser'
else {}),
},
{
'cid': '{4399533d-08d1-458c-a87a-235f74451cfa}',

View File

@ -1,4 +1,3 @@
category update-timer nsBlocklistService @mozilla.org/extensions/blocklist;1,getService,blocklist-background-update-timer,extensions.blocklist.interval,86400
#ifndef MOZ_WIDGET_ANDROID
category update-timer addonManager @mozilla.org/addons/integration;1,getService,addon-background-update-timer,extensions.update.interval,86400
#endif

View File

@ -403,10 +403,6 @@ var AddonTestUtils = {
"extensions.update.background.url",
"http://127.0.0.1/updateBackgroundURL"
);
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://127.0.0.1/blocklistURL"
);
Services.prefs.setCharPref(
"services.settings.server",
"http://localhost/dummy-kinto/v1"
@ -418,19 +414,6 @@ var AddonTestUtils = {
// Ensure signature checks are enabled by default
Services.prefs.setBoolPref("xpinstall.signatures.required", true);
// Write out an empty blocklist.xml file to the profile to ensure nothing
// is blocklisted by default
var blockFile = OS.Path.join(this.profileDir.path, "blocklist.xml");
var data =
'<?xml version="1.0" encoding="UTF-8"?>\n' +
'<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">\n' +
"</blocklist>\n";
this.awaitPromise(
OS.File.writeAtomic(blockFile, new TextEncoder().encode(data))
);
// Make sure that a given path does not exist
function pathShouldntExist(file) {
if (file.exists()) {
@ -957,15 +940,6 @@ var AddonTestUtils = {
if (newVersion) {
this.appInfo.version = newVersion;
if (Cu.isModuleLoaded("resource://gre/modules/Blocklist.jsm")) {
let bsPassBlocklist = ChromeUtils.import(
"resource://gre/modules/Blocklist.jsm",
null
);
Object.defineProperty(bsPassBlocklist, "gAppVersion", {
value: newVersion,
});
}
}
// AddonListeners are removed when the addonManager is shutdown,
// ensure the Extension observer is added. We call uninit in

View File

@ -1,7 +0,0 @@
<?xml version="1.0"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1336406310001">
<emItems>
</emItems>
<pluginItems>
</pluginItems>
</blocklist>

View File

@ -1,11 +0,0 @@
<?xml version="1.0"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1336406310000">
<emItems>
</emItems>
<pluginItems>
<pluginItem blockID="p9999">
<match name="filename" exp="libnptest\.so|nptest\.dll|Test\.plugin" />
<versionRange severity="2"></versionRange>
</pluginItem>
</pluginItems>
</blocklist>

View File

@ -17,8 +17,6 @@ support-files =
head.js
plugin_test.html
redirect.sjs
blockNoPlugins.xml
blockPluginHard.xml
browser_updatessl.json
browser_updatessl.json^headers^
webapi_addon_listener.html

View File

@ -15,47 +15,24 @@ function updateBlocklist(aURL, aCallback) {
SimpleTest.executeSoon(aCallback);
};
Services.obs.addObserver(observer, "plugin-blocklist-updated");
if (Services.prefs.getBoolPref("extensions.blocklist.useXML", true)) {
info("Loading plugin data " + aURL + " using xml implementation.");
Services.prefs.setCharPref("extensions.blocklist.url", aURL);
var blocklistNotifier = Cc[
"@mozilla.org/extensions/blocklist;1"
].getService(Ci.nsITimerCallback);
blocklistNotifier.notify(null);
info("Loading plugin data " + aURL);
if (aURL.endsWith("blockNoPlugins")) {
AddonTestUtils.loadBlocklistRawData({ plugins: [] });
} else if (aURL.endsWith("blockPluginHard")) {
AddonTestUtils.loadBlocklistRawData({
plugins: [
{
matchFilename: "libnptest\\.so|nptest\\.dll|Test\\.plugin",
versionRange: [{ severity: "2" }],
blockID: "p9999",
},
],
});
} else {
info("Loading plugin data " + aURL + " using remote settings.");
if (aURL.endsWith("blockNoPlugins.xml")) {
AddonTestUtils.loadBlocklistRawData({ plugins: [] });
} else if (aURL.endsWith("blockPluginHard.xml")) {
AddonTestUtils.loadBlocklistRawData({
plugins: [
{
matchFilename: "libnptest\\.so|nptest\\.dll|Test\\.plugin",
versionRange: [{ severity: "2" }],
blockID: "p9999",
},
],
});
} else {
ok(false, "Should never be asked to update to unknown blocklist data.");
}
ok(false, "Should never be asked to update to unknown blocklist data.");
}
}
var _originalBlocklistURL = null;
function setAndUpdateBlocklist(aURL, aCallback) {
if (!_originalBlocklistURL) {
_originalBlocklistURL = Services.prefs.getCharPref(
"extensions.blocklist.url"
);
}
updateBlocklist(aURL, aCallback);
}
function resetBlocklist() {
Services.prefs.setCharPref("extensions.blocklist.url", _originalBlocklistURL);
}
function setPluginActivateState({ managerWindow, pluginId, activateState }) {
let pluginEl = get_addon_element(managerWindow, pluginId);
ok(pluginEl, `Got the about:addon entry for "${pluginId}"`);
@ -225,16 +202,12 @@ add_task(async function test_blocklisted_plugin_disabled() {
let pluginTag = getTestPluginTag();
pluginTag.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
await new Promise(resolve => {
setAndUpdateBlocklist(gHttpTestRoot + "blockNoPlugins.xml", resolve);
updateBlocklist(gHttpTestRoot + "blockNoPlugins", resolve);
});
resetBlocklist();
}
await SpecialPowers.pushPrefEnv({
set: [
["extensions.blocklist.suppressUI", true],
["extensions.blocklist.useXML", true],
],
set: [["extensions.blocklist.suppressUI", true]],
});
// Causes appDisabled to be set.
@ -242,18 +215,11 @@ add_task(async function test_blocklisted_plugin_disabled() {
// Ensure to reset the blocklist if this test exits earlier because
// of a failure.
registerCleanupFunction(ensurePluginEnabled);
setAndUpdateBlocklist(gHttpTestRoot + "blockPluginHard.xml", resolve);
updateBlocklist(gHttpTestRoot + "blockPluginHard", resolve);
});
await checkPlugins();
await SpecialPowers.pushPrefEnv({
set: [["extensions.blocklist.useXML", false]],
});
await checkPlugins();
// Clear the blocklist and all prefs on the stack.
await ensurePluginEnabled();
// Using flushPrefEnv instead of 2x popPrefEnv to work around bug 1557397.
await SpecialPowers.flushPrefEnv();
});

View File

@ -116,12 +116,10 @@ function checkOpenWindows(aWindowID) {
// Tools to disable and re-enable the background update and blocklist timers
// so that tests can protect themselves from unwanted timer events.
var gCatMan = Services.catMan;
// Default values from toolkit/mozapps/extensions/extensions.manifest, but disable*UpdateTimer()
// Default value from toolkit/mozapps/extensions/extensions.manifest, but disable*UpdateTimer()
// records the actual value so we can put it back in enable*UpdateTimer()
var backgroundUpdateConfig =
"@mozilla.org/addons/integration;1,getService,addon-background-update-timer,extensions.update.interval,86400";
var blocklistUpdateConfig =
"@mozilla.org/extensions/blocklist;1,getService,blocklist-background-update-timer,extensions.blocklist.interval,86400";
var UTIMER = "update-timer";
var AMANAGER = "addonManager";
@ -144,23 +142,6 @@ function enableBackgroundUpdateTimer() {
);
}
function disableBlocklistUpdateTimer() {
info("Disabling " + UTIMER + " " + BLOCKLIST);
blocklistUpdateConfig = gCatMan.getCategoryEntry(UTIMER, BLOCKLIST);
gCatMan.deleteCategoryEntry(UTIMER, BLOCKLIST, true);
}
function enableBlocklistUpdateTimer() {
info("Enabling " + UTIMER + " " + BLOCKLIST);
gCatMan.addCategoryEntry(
UTIMER,
BLOCKLIST,
blocklistUpdateConfig,
false,
true
);
}
registerCleanupFunction(function() {
// Restore prefs
for (let pref of gRestorePrefs) {

View File

@ -12,13 +12,9 @@ MOCHITEST_CHROME_MANIFESTS += ['mochitest/chrome.ini']
XPCSHELL_TESTS_MANIFESTS += [
'xpcshell/rs-blocklist/xpcshell.ini',
'xpcshell/xml-blocklist/xpcshell.ini',
'xpcshell/xpcshell-unpack.ini',
'xpcshell/xpcshell.ini',
]
with Files('xpcshell/rs-blocklist/**'):
BUG_COMPONENT = ('Toolkit', 'Blocklist Implementation')
with Files('xpcshell/xml-blocklist/**'):
BUG_COMPONENT = ('Toolkit', 'Blocklist Implementation')

View File

@ -1,6 +1,2 @@
// Appease eslint.
/* import-globals-from ../head_addons.js */
{
let { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
Services.prefs.setBoolPref("extensions.blocklist.useXML", false);
}

View File

@ -37,39 +37,6 @@ add_task(async function test_setup() {
await AddonTestUtils.promiseStartupManager();
});
add_task(async function test_blocklist_useXML_scalar() {
// In this folder, `useXML` is already set, and set to false, ie we're using remote settings,
// Blocklist.jsm module is loaded explicitly here to ensure that BlocklistTelemetry
// has been able to record its initial value and it is watching for changes of the pref.
ChromeUtils.import("resource://gre/modules/Blocklist.jsm");
assertTelemetryScalars({
"blocklist.useXML": false,
"blocklist.lastModified_rs_addons": undefined,
"blocklist.lastModified_rs_plugins": undefined,
});
// Switch to XML:
Services.prefs.setBoolPref("extensions.blocklist.useXML", true);
// The useXML scalar should be updated, the lastModified_rs_* scalars should
// still be empty.
assertTelemetryScalars({
"blocklist.useXML": true,
"blocklist.lastModified_rs_addons": undefined,
"blocklist.lastModified_rs_plugins": undefined,
});
// Switch back to RemoteSettings:
Services.prefs.setBoolPref("extensions.blocklist.useXML", false);
assertTelemetryScalars({
"blocklist.useXML": false,
"blocklist.lastModified_rs_addons": undefined,
"blocklist.lastModified_rs_plugins": undefined,
});
});
add_task(async function test_blocklist_lastModified_rs_scalars() {
const now = Date.now();
@ -120,7 +87,6 @@ add_task(async function test_blocklist_lastModified_rs_scalars() {
]);
assertTelemetryScalars({
"blocklist.useXML": false,
"blocklist.lastModified_rs_addons": undefined,
"blocklist.lastModified_rs_plugins": lastEntryTimesUTC.plugins,
});
@ -134,7 +100,6 @@ add_task(async function test_blocklist_lastModified_rs_scalars() {
]);
assertTelemetryScalars({
"blocklist.useXML": false,
"blocklist.lastModified_rs_addons": lastEntryTimesUTC.addons,
"blocklist.lastModified_rs_plugins": lastEntryTimesUTC.plugins,
});

View File

@ -611,11 +611,6 @@ add_task(async function update_schema_2() {
await changeXPIDBVersion(100);
gAppInfo.version = "2";
let bsPassBlocklist = ChromeUtils.import(
"resource://gre/modules/Blocklist.jsm",
null
);
Object.defineProperty(bsPassBlocklist, "gAppVersion", { value: "2" });
await promiseStartupManager();
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
@ -646,11 +641,6 @@ add_task(async function update_schema_3() {
await promiseShutdownManager();
await changeXPIDBVersion(100);
gAppInfo.version = "2.5";
let bsPassBlocklist = ChromeUtils.import(
"resource://gre/modules/Blocklist.jsm",
null
);
Object.defineProperty(bsPassBlocklist, "gAppVersion", { value: "2.5" });
await promiseStartupManager();
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
@ -696,11 +686,6 @@ add_task(async function update_schema_5() {
await changeXPIDBVersion(100);
gAppInfo.version = "1";
let bsPassBlocklist = ChromeUtils.import(
"resource://gre/modules/Blocklist.jsm",
null
);
Object.defineProperty(bsPassBlocklist, "gAppVersion", { value: "1" });
await promiseStartupManager();
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);

View File

@ -1,57 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const PREF_BLOCKLIST_URL = "extensions.blocklist.url";
add_task(async function test_switch_blocklist_implementations() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
// In this folder, `useXML` is already set, and set to false, ie we're using remote settings.
Services.prefs.setCharPref(
PREF_BLOCKLIST_URL,
"http://localhost/blocklist.xml"
);
let { Blocklist } = ChromeUtils.import(
"resource://gre/modules/Blocklist.jsm"
);
await Blocklist.loadBlocklistAsync();
// Observe request:
let sentRequest = TestUtils.topicObserved(
"http-on-modify-request",
function check(subject, data) {
let httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
info("Got request for: " + httpChannel.URI.spec);
return httpChannel.URI.spec.startsWith("http://localhost/blocklist.xml");
}
);
// Switch to XML:
Services.prefs.setBoolPref("extensions.blocklist.useXML", true);
// Check we're updating:
await sentRequest;
ok(true, "We got an update request for the XML list when switching");
// Now do the same for the remote settings list:
let { Utils } = ChromeUtils.import("resource://services-settings/Utils.jsm");
// Mock the 'get latest changes' endpoint so we don't need a network request for it:
Utils.fetchLatestChanges = () =>
Promise.resolve({ changes: [{ last_modified: Date.now() }] });
let requestPromises = ["addons", "plugins", "gfx"].map(slug => {
return TestUtils.topicObserved("http-on-modify-request", function check(
subject,
data
) {
let httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
info("Got request for: " + httpChannel.URI.spec);
return httpChannel.URI.spec.includes(
"buckets/blocklists/collections/" + slug
);
});
});
Services.prefs.setBoolPref("extensions.blocklist.useXML", false);
await Promise.all(requestPromises);
ok(
true,
"We got update requests for all the remote settings lists when switching."
);
});

View File

@ -60,4 +60,3 @@ skip-if = true
fail-if = os == "android"
[test_pluginInfoURL.js]
[test_softblocked.js]
[test_switchImplementations.js]

View File

@ -1,6 +0,0 @@
// Appease eslint.
/* import-globals-from ../head_addons.js */
{
let { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
Services.prefs.setBoolPref("extensions.blocklist.useXML", true);
}

View File

@ -1,384 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
const Cm = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
var testserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
testserver.registerDirectory("/data/", do_get_file("../data"));
var ADDONS = [
{
id: "test_bug449027_1@tests.mozilla.org",
name: "Bug 449027 Addon Test 1",
version: "5",
start: false,
appBlocks: false,
toolkitBlocks: false,
},
{
id: "test_bug449027_2@tests.mozilla.org",
name: "Bug 449027 Addon Test 2",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: false,
},
{
id: "test_bug449027_3@tests.mozilla.org",
name: "Bug 449027 Addon Test 3",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: false,
},
{
id: "test_bug449027_4@tests.mozilla.org",
name: "Bug 449027 Addon Test 4",
version: "5",
start: false,
appBlocks: false,
toolkitBlocks: false,
},
{
id: "test_bug449027_5@tests.mozilla.org",
name: "Bug 449027 Addon Test 5",
version: "5",
start: false,
appBlocks: false,
toolkitBlocks: false,
},
{
id: "test_bug449027_6@tests.mozilla.org",
name: "Bug 449027 Addon Test 6",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: false,
},
{
id: "test_bug449027_7@tests.mozilla.org",
name: "Bug 449027 Addon Test 7",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: false,
},
{
id: "test_bug449027_8@tests.mozilla.org",
name: "Bug 449027 Addon Test 8",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: false,
},
{
id: "test_bug449027_9@tests.mozilla.org",
name: "Bug 449027 Addon Test 9",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: false,
},
{
id: "test_bug449027_10@tests.mozilla.org",
name: "Bug 449027 Addon Test 10",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: false,
},
{
id: "test_bug449027_11@tests.mozilla.org",
name: "Bug 449027 Addon Test 11",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: false,
},
{
id: "test_bug449027_12@tests.mozilla.org",
name: "Bug 449027 Addon Test 12",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: false,
},
{
id: "test_bug449027_13@tests.mozilla.org",
name: "Bug 449027 Addon Test 13",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: false,
},
{
id: "test_bug449027_14@tests.mozilla.org",
name: "Bug 449027 Addon Test 14",
version: "5",
start: false,
appBlocks: false,
toolkitBlocks: false,
},
{
id: "test_bug449027_15@tests.mozilla.org",
name: "Bug 449027 Addon Test 15",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: true,
},
{
id: "test_bug449027_16@tests.mozilla.org",
name: "Bug 449027 Addon Test 16",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: true,
},
{
id: "test_bug449027_17@tests.mozilla.org",
name: "Bug 449027 Addon Test 17",
version: "5",
start: false,
appBlocks: false,
toolkitBlocks: false,
},
{
id: "test_bug449027_18@tests.mozilla.org",
name: "Bug 449027 Addon Test 18",
version: "5",
start: false,
appBlocks: false,
toolkitBlocks: false,
},
{
id: "test_bug449027_19@tests.mozilla.org",
name: "Bug 449027 Addon Test 19",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: true,
},
{
id: "test_bug449027_20@tests.mozilla.org",
name: "Bug 449027 Addon Test 20",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: true,
},
{
id: "test_bug449027_21@tests.mozilla.org",
name: "Bug 449027 Addon Test 21",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: true,
},
{
id: "test_bug449027_22@tests.mozilla.org",
name: "Bug 449027 Addon Test 22",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: true,
},
{
id: "test_bug449027_23@tests.mozilla.org",
name: "Bug 449027 Addon Test 23",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: true,
},
{
id: "test_bug449027_24@tests.mozilla.org",
name: "Bug 449027 Addon Test 24",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: true,
},
{
id: "test_bug449027_25@tests.mozilla.org",
name: "Bug 449027 Addon Test 25",
version: "5",
start: false,
appBlocks: true,
toolkitBlocks: true,
},
];
class MockPlugin extends MockPluginTag {
constructor(name, version, start, appBlocks, toolkitBlocks) {
super({ name, version });
this.start = start;
this.appBlocks = appBlocks;
this.toolkitBlocks = toolkitBlocks;
}
}
var PLUGINS = [
new MockPlugin("test_bug449027_1", "5", false, false, false),
new MockPlugin("test_bug449027_2", "5", false, true, false),
new MockPlugin("test_bug449027_3", "5", false, true, false),
new MockPlugin("test_bug449027_4", "5", false, false, false),
new MockPlugin("test_bug449027_5", "5", false, false, false),
new MockPlugin("test_bug449027_6", "5", false, true, false),
new MockPlugin("test_bug449027_7", "5", false, true, false),
new MockPlugin("test_bug449027_8", "5", false, true, false),
new MockPlugin("test_bug449027_9", "5", false, true, false),
new MockPlugin("test_bug449027_10", "5", false, true, false),
new MockPlugin("test_bug449027_11", "5", false, true, false),
new MockPlugin("test_bug449027_12", "5", false, true, false),
new MockPlugin("test_bug449027_13", "5", false, true, false),
new MockPlugin("test_bug449027_14", "5", false, false, false),
new MockPlugin("test_bug449027_15", "5", false, true, true),
new MockPlugin("test_bug449027_16", "5", false, true, true),
new MockPlugin("test_bug449027_17", "5", false, false, false),
new MockPlugin("test_bug449027_18", "5", false, false, false),
new MockPlugin("test_bug449027_19", "5", false, true, true),
new MockPlugin("test_bug449027_20", "5", false, true, true),
new MockPlugin("test_bug449027_21", "5", false, true, true),
new MockPlugin("test_bug449027_22", "5", false, true, true),
new MockPlugin("test_bug449027_23", "5", false, true, true),
new MockPlugin("test_bug449027_24", "5", false, true, true),
new MockPlugin("test_bug449027_25", "5", false, true, true),
];
var gNewBlocks = [];
mockPluginHost(PLUGINS);
var BlocklistPrompt = {
get wrappedJSObject() {
return this;
},
prompt(list) {
gNewBlocks = list.map(item => `${item.name} ${item.version}`);
},
QueryInterface: ChromeUtils.generateQI([]),
};
async function loadBlocklist(file) {
let blocklistUpdated = TestUtils.topicObserved("addon-blocklist-updated");
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://example.com/data/" + file
);
Blocklist.notify();
await blocklistUpdated;
}
let factory = XPCOMUtils.generateSingletonFactory(function() {
return BlocklistPrompt;
});
Cm.registerFactory(
Components.ID("{26d32654-30c7-485d-b983-b4d2568aebba}"),
"Blocklist Prompt",
"@mozilla.org/addons/blocklist-prompt;1",
factory
);
function createAddon(addon) {
return promiseInstallWebExtension({
manifest: {
name: addon.name,
version: addon.version,
applications: { gecko: { id: addon.id } },
},
});
}
/**
* Checks that items are blocklisted correctly according to the current test.
* If a lastTest is provided checks that the notification dialog got passed
* the newly blocked items compared to the previous test.
*/
async function checkState(test, lastTest, callback) {
let addons = await AddonManager.getAddonsByIDs(ADDONS.map(a => a.id));
const bls = Ci.nsIBlocklistService;
await TestUtils.waitForCondition(() =>
ADDONS.every(
(addon, i) =>
addon[test] == (addons[i].blocklistState == bls.STATE_BLOCKED)
)
).catch(() => {
/* ignore exceptions; the following test will fail anyway. */
});
for (let [i, addon] of ADDONS.entries()) {
var blocked =
addons[i].blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED;
equal(
blocked,
addon[test],
`Blocklist state should match expected for extension ${addon.id}, test ${test}`
);
}
for (let plugin of PLUGINS) {
equal(
await plugin.isBlocklisted(),
plugin[test],
`Blocklist state should match expected for plugin ${plugin.name}, test ${test}`
);
}
if (lastTest) {
var expected = 0;
for (let plugin of PLUGINS) {
if (plugin[test] && !plugin[lastTest]) {
ok(
gNewBlocks.includes(`${plugin.name} ${plugin.version}`),
`Plugin ${plugin.name} should have been listed in the blocklist notification for test ${test}`
);
expected++;
}
}
Assert.equal(expected, gNewBlocks.length);
}
}
add_task(async function test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
await promiseStartupManager();
for (let addon of ADDONS) {
await createAddon(addon);
}
let addons = await AddonManager.getAddonsByIDs(ADDONS.map(a => a.id));
for (var i = 0; i < ADDONS.length; i++) {
ok(addons[i], `Addon ${i + 1} should have been correctly installed`);
}
await checkState("start");
});
/**
* Load the toolkit based blocks
*/
add_task(async function test_pt2() {
await loadBlocklist("test_bug449027_toolkit.xml");
await checkState("toolkitBlocks", "start");
});
/**
* Load the application based blocks
*/
add_task(async function test_pt3() {
await loadBlocklist("test_bug449027_app.xml");
await checkState("appBlocks", "toolkitBlocks");
});

View File

@ -1,147 +0,0 @@
XPCOMUtils.defineLazyGlobalGetters(this, ["DOMParser"]);
const gParser = new DOMParser();
const EVENT_NAME = "blocklist-data-gfxItems";
const SAMPLE_GFX_RECORD = {
driverVersionComparator: "LESS_THAN_OR_EQUAL",
driverVersion: "8.17.12.5896",
vendor: "0x10de",
blockID: "g36",
feature: "DIRECT3D_9_LAYERS",
devices: ["0x0a6c", "geforce"],
featureStatus: "BLOCKED_DRIVER_VERSION",
last_modified: 1458035931837,
os: "WINNT 6.1",
id: "3f947f16-37c2-4e96-d356-78b26363729b",
versionRange: { minVersion: 0, maxVersion: "*" },
};
let jsmInternalObj = ChromeUtils.import(
"resource://gre/modules/Blocklist.jsm",
null
);
function getBlocklist() {
jsmInternalObj.BlocklistXML._clear();
return jsmInternalObj.BlocklistXML;
}
async function updateBlocklistWithInput(input) {
let blocklist = getBlocklist();
let promiseObserved = TestUtils.topicObserved(EVENT_NAME);
blocklist._loadBlocklistFromXML(gParser.parseFromString(input, "text/xml"));
let [, received] = await promiseObserved;
return [blocklist, received];
}
add_task(async function test_sends_serialized_data() {
const blocklist = getBlocklist();
blocklist._gfxEntries = [SAMPLE_GFX_RECORD];
const expected =
"blockID:g36\tdevices:0x0a6c,geforce\tdriverVersion:8.17.12.5896\t" +
"driverVersionComparator:LESS_THAN_OR_EQUAL\tfeature:DIRECT3D_9_LAYERS\t" +
"featureStatus:BLOCKED_DRIVER_VERSION\tos:WINNT 6.1\tvendor:0x10de\t" +
"versionRange:0,*";
let promiseObserved = TestUtils.topicObserved(EVENT_NAME);
blocklist._notifyObserversBlocklistGFX();
let [, received] = await promiseObserved;
equal(received, expected);
});
add_task(async function test_parsing_fails_if_devices_contains_comma() {
const input =
'<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">' +
"<gfxItems>" +
" <gfxBlacklistEntry>" +
" <devices>" +
" <device>0x2,582</device>" +
" <device>0x2782</device>" +
" </devices>" +
" </gfxBlacklistEntry>" +
"</gfxItems>" +
"</blocklist>";
let [blocklist] = await updateBlocklistWithInput(input);
equal(blocklist._gfxEntries[0].devices.length, 1);
equal(blocklist._gfxEntries[0].devices[0], "0x2782");
});
add_task(async function test_empty_values_are_ignored() {
const input =
'<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">' +
"<gfxItems>" +
" <gfxBlacklistEntry>" +
" <os></os>" +
" </gfxBlacklistEntry>" +
"</gfxItems>" +
"</blocklist>";
let [, received] = await updateBlocklistWithInput(input);
ok(received.indexOf("os" < 0));
});
add_task(async function test_empty_devices_are_ignored() {
const input =
'<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">' +
"<gfxItems>" +
" <gfxBlacklistEntry>" +
" <devices></devices>" +
" </gfxBlacklistEntry>" +
"</gfxItems>" +
"</blocklist>";
let [, received] = await updateBlocklistWithInput(input);
ok(received.indexOf("devices" < 0));
});
add_task(async function test_version_range_default_values() {
const input =
'<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">' +
"<gfxItems>" +
" <gfxBlacklistEntry>" +
' <versionRange minVersion="13.0b2" maxVersion="42.0"/>' +
" </gfxBlacklistEntry>" +
" <gfxBlacklistEntry>" +
' <versionRange maxVersion="2.0"/>' +
" </gfxBlacklistEntry>" +
" <gfxBlacklistEntry>" +
' <versionRange minVersion="1.0"/>' +
" </gfxBlacklistEntry>" +
" <gfxBlacklistEntry>" +
' <versionRange minVersion=" "/>' +
" </gfxBlacklistEntry>" +
" <gfxBlacklistEntry>" +
" <versionRange/>" +
" </gfxBlacklistEntry>" +
"</gfxItems>" +
"</blocklist>";
let [blocklist] = await updateBlocklistWithInput(input);
equal(blocklist._gfxEntries[0].versionRange.minVersion, "13.0b2");
equal(blocklist._gfxEntries[0].versionRange.maxVersion, "42.0");
equal(blocklist._gfxEntries[1].versionRange.minVersion, "0");
equal(blocklist._gfxEntries[1].versionRange.maxVersion, "2.0");
equal(blocklist._gfxEntries[2].versionRange.minVersion, "1.0");
equal(blocklist._gfxEntries[2].versionRange.maxVersion, "*");
equal(blocklist._gfxEntries[3].versionRange.minVersion, "0");
equal(blocklist._gfxEntries[3].versionRange.maxVersion, "*");
equal(blocklist._gfxEntries[4].versionRange.minVersion, "0");
equal(blocklist._gfxEntries[4].versionRange.maxVersion, "*");
});
add_task(async function test_blockid_attribute() {
const input =
'<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">' +
"<gfxItems>" +
' <gfxBlacklistEntry blockID="g60">' +
" <vendor> 0x10de </vendor>" +
" </gfxBlacklistEntry>" +
" <gfxBlacklistEntry>" +
" <feature> DIRECT3D_9_LAYERS </feature>" +
" </gfxBlacklistEntry>" +
"</gfxItems>" +
"</blocklist>";
let [blocklist] = await updateBlocklistWithInput(input);
equal(blocklist._gfxEntries[0].blockID, "g60");
ok(!blocklist._gfxEntries[1].hasOwnProperty("blockID"));
});

View File

@ -1,131 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Tests blocking of extensions by ID, name, creator, homepageURL, updateURL
// and RegExps for each. See bug 897735.
const URI_EXTENSION_BLOCKLIST_DIALOG =
"chrome://mozapps/content/extensions/blocklist.xhtml";
var testserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = testserver.identity.primaryPort;
testserver.registerDirectory("/data/", do_get_file("../data"));
const profileDir = gProfD.clone();
profileDir.append("extensions");
// Don't need the full interface, attempts to call other methods will just
// throw which is just fine
var WindowWatcher = {
openWindow(parent, url, name, features, args) {
// Should be called to list the newly blocklisted items
Assert.equal(url, URI_EXTENSION_BLOCKLIST_DIALOG);
// Simulate auto-disabling any softblocks
var list = args.wrappedJSObject.list;
list.forEach(function(aItem) {
if (!aItem.blocked) {
aItem.disable = true;
}
});
// run the code after the blocklist is closed
Services.obs.notifyObservers(null, "addon-blocklist-closed");
},
QueryInterface: ChromeUtils.generateQI(["nsIWindowWatcher"]),
};
MockRegistrar.register(
"@mozilla.org/embedcomp/window-watcher;1",
WindowWatcher
);
function load_blocklist(aFile) {
return new Promise(resolve => {
Services.obs.addObserver(function observer() {
Services.obs.removeObserver(observer, "addon-blocklist-updated");
resolve();
}, "addon-blocklist-updated");
Services.prefs.setCharPref(
"extensions.blocklist.url",
`http://localhost:${gPort}/data/${aFile}`
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
});
}
add_task(async function setup() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
await promiseStartupManager();
// Should get blocked by name
await promiseInstallWebExtension({
manifest: {
name: "Mozilla Corp.",
version: "1.0",
applications: { gecko: { id: "block1@tests.mozilla.org" } },
},
});
// Should get blocked by all the attributes.
await promiseInstallWebExtension({
manifest: {
name: "Moz-addon",
version: "1.0",
homepage_url: "https://www.extension.dangerous.com/",
applications: {
gecko: {
id: "block2@tests.mozilla.org",
update_url: "https://www.extension.dangerous.com/update.json",
},
},
},
});
// Fails to get blocked because of a different ID even though other
// attributes match against a blocklist entry.
await promiseInstallWebExtension({
manifest: {
name: "Moz-addon",
version: "1.0",
homepage_url: "https://www.extension.dangerous.com/",
applications: {
gecko: {
id: "block3@tests.mozilla.org",
update_url: "https://www.extension.dangerous.com/update.json",
},
},
},
});
let [a1, a2, a3] = await AddonManager.getAddonsByIDs([
"block1@tests.mozilla.org",
"block2@tests.mozilla.org",
"block3@tests.mozilla.org",
]);
Assert.equal(a1.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
Assert.equal(a2.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
Assert.equal(a3.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
});
add_task(async function test_blocks() {
await load_blocklist("test_blocklist_metadata_filters_1.xml");
let [a1, a2, a3] = await AddonManager.getAddonsByIDs([
"block1@tests.mozilla.org",
"block2@tests.mozilla.org",
"block3@tests.mozilla.org",
]);
Assert.equal(a1.blocklistState, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
Assert.equal(a2.blocklistState, Ci.nsIBlocklistService.STATE_BLOCKED);
Assert.equal(a3.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
});

View File

@ -1,203 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
var testserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = testserver.identity.primaryPort;
testserver.registerDirectory("/data/", do_get_file("../data"));
const profileDir = gProfD.clone();
profileDir.append("extensions");
const ADDONS = [
{
id: "test_bug393285_1@tests.mozilla.org",
name: "extension 1",
version: "1.0",
// No info in blocklist, shouldn't be blocked
notBlocklisted: [["1", "1.9"], [null, null]],
},
{
id: "test_bug393285_2@tests.mozilla.org",
name: "extension 2",
version: "1.0",
// Should always be blocked
blocklisted: [["1", "1.9"], [null, null]],
},
{
id: "test_bug393285_3a@tests.mozilla.org",
name: "extension 3a",
version: "1.0",
// Only version 1 should be blocked
blocklisted: [["1", "1.9"], [null, null]],
},
{
id: "test_bug393285_3b@tests.mozilla.org",
name: "extension 3b",
version: "2.0",
// Only version 1 should be blocked
notBlocklisted: [["1", "1.9"]],
},
{
id: "test_bug393285_4@tests.mozilla.org",
name: "extension 4",
version: "1.0",
// Should be blocked for app version 1
blocklisted: [["1", "1.9"], [null, null]],
notBlocklisted: [["2", "1.9"]],
},
{
id: "test_bug393285_5@tests.mozilla.org",
name: "extension 5",
version: "1.0",
// Not blocklisted because we are a different OS
notBlocklisted: [["2", "1.9"]],
},
{
id: "test_bug393285_6@tests.mozilla.org",
name: "extension 6",
version: "1.0",
// Blocklisted based on OS
blocklisted: [["2", "1.9"]],
},
{
id: "test_bug393285_7@tests.mozilla.org",
name: "extension 7",
version: "1.0",
// Blocklisted based on OS
blocklisted: [["2", "1.9"]],
},
{
id: "test_bug393285_8@tests.mozilla.org",
name: "extension 8",
version: "1.0",
// Not blocklisted because we are a different ABI
notBlocklisted: [["2", "1.9"]],
},
{
id: "test_bug393285_9@tests.mozilla.org",
name: "extension 9",
version: "1.0",
// Blocklisted based on ABI
blocklisted: [["2", "1.9"]],
},
{
id: "test_bug393285_10@tests.mozilla.org",
name: "extension 10",
version: "1.0",
// Blocklisted based on ABI
blocklisted: [["2", "1.9"]],
},
{
id: "test_bug393285_11@tests.mozilla.org",
name: "extension 11",
version: "1.0",
// Doesn't match both os and abi so not blocked
notBlocklisted: [["2", "1.9"]],
},
{
id: "test_bug393285_12@tests.mozilla.org",
name: "extension 12",
version: "1.0",
// Doesn't match both os and abi so not blocked
notBlocklisted: [["2", "1.9"]],
},
{
id: "test_bug393285_13@tests.mozilla.org",
name: "extension 13",
version: "1.0",
// Doesn't match both os and abi so not blocked
notBlocklisted: [["2", "1.9"]],
},
{
id: "test_bug393285_14@tests.mozilla.org",
name: "extension 14",
version: "1.0",
// Matches both os and abi so blocked
blocklisted: [["2", "1.9"]],
},
];
const ADDON_IDS = ADDONS.map(a => a.id);
async function loadBlocklist(file) {
let blocklistUpdated = TestUtils.topicObserved("addon-blocklist-updated");
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://example.com/data/" + file
);
Blocklist.notify();
return blocklistUpdated;
}
add_task(async function setup() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
await promiseStartupManager();
for (let addon of ADDONS) {
await promiseInstallWebExtension({
manifest: {
name: addon.name,
version: addon.version,
applications: { gecko: { id: addon.id } },
},
});
}
let addons = await getAddons(ADDON_IDS);
for (let id of ADDON_IDS) {
equal(
addons.get(id).blocklistState,
Ci.nsIBlocklistService.STATE_NOT_BLOCKED,
`Add-on ${id} should not initially be blocked`
);
}
});
add_task(async function test_1() {
await loadBlocklist("test_bug393285.xml");
let addons = await getAddons(ADDON_IDS);
async function isBlocklisted(addon, appVer, toolkitVer) {
let state = await Blocklist.getAddonBlocklistState(
addon,
appVer,
toolkitVer
);
return state != Services.blocklist.STATE_NOT_BLOCKED;
}
for (let addon of ADDONS) {
let { id } = addon;
for (let blocklisted of addon.blocklisted || []) {
ok(
await isBlocklisted(addons.get(id), ...blocklisted),
`Add-on ${id} should be blocklisted in app/platform version ${blocklisted}`
);
}
for (let notBlocklisted of addon.notBlocklisted || []) {
ok(
!(await isBlocklisted(addons.get(id), ...notBlocklisted)),
`Add-on ${id} should not be blocklisted in app/platform version ${notBlocklisted}`
);
}
}
});

View File

@ -1,46 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const nsIBLS = Ci.nsIBlocklistService;
// Finds the test nsIPluginTag
function get_test_plugintag() {
var host = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
var tags = host.getPluginTags();
for (let tag of tags) {
if (tag.name == "Test Plug-in") {
return tag;
}
}
return null;
}
add_task(async function checkFlashOnlyPluginState() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
copyBlocklistToProfile(do_get_file("../data/test_bug514327_2.xml"));
Services.prefs.setBoolPref("plugin.load_flash_only", false);
// plugin.load_flash_only is only respected if xpc::IsInAutomation is true.
// This is not the case by default in xpcshell tests, unless the following
// pref is also set. Fixing this generically is bug 1598804
Services.prefs.setBoolPref(
"security.turn_off_all_security_so_that_viruses_can_take_over_this_computer",
true
);
var plugin = get_test_plugintag();
if (!plugin) {
do_throw("Plugin tag not found");
}
// run the code after the blocklist is closed
Services.obs.notifyObservers(null, "addon-blocklist-closed");
await new Promise(executeSoon);
// should be marked as outdated by the blocklist
Assert.equal(
await Blocklist.getPluginBlocklistState(plugin, "1", "1.9"),
nsIBLS.STATE_OUTDATED
);
});

View File

@ -1,121 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const Cm = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
const nsIBLS = Ci.nsIBlocklistService;
var gBlocklist = null;
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gTestserver.registerDirectory("/data/", do_get_file("../data"));
var PLUGINS = [
{
// Tests a plugin whose state goes from not-blocked, to outdated
name: "test_bug514327_outdated",
version: "5",
disabled: false,
blocklisted: false,
},
{
// Used to trigger the blocklist dialog, which indicates the blocklist has updated
name: "test_bug514327_1",
version: "5",
disabled: false,
blocklisted: false,
},
{
// Used to trigger the blocklist dialog, which indicates the blocklist has updated
name: "test_bug514327_2",
version: "5",
disabled: false,
blocklisted: false,
},
].map(opts => new MockPluginTag(opts, opts.enabledState));
mockPluginHost(PLUGINS);
var BlocklistPrompt = {
get wrappedJSObject() {
return this;
},
prompt(list) {
// Should only include one item
Assert.equal(list.length, 1);
// And that item should be the blocked plugin, not the outdated one
var item = list[0];
Assert.ok(item.item instanceof Ci.nsIPluginTag);
Assert.notEqual(item.name, "test_bug514327_outdated");
},
QueryInterface: ChromeUtils.generateQI([]),
};
async function loadBlocklist(file) {
let blocklistUpdated = TestUtils.topicObserved("plugin-blocklist-updated");
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://example.com/data/" + file
);
Blocklist.notify();
await blocklistUpdated;
}
let factory = XPCOMUtils.generateSingletonFactory(function() {
return BlocklistPrompt;
});
Cm.registerFactory(
Components.ID("{26d32654-30c7-485d-b983-b4d2568aebba}"),
"Blocklist Prompt",
"@mozilla.org/addons/blocklist-prompt;1",
factory
);
add_task(async function setup() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
// initialize the blocklist with no entries
copyBlocklistToProfile(do_get_file("../data/test_bug514327_3_empty.xml"));
await promiseStartupManager();
gBlocklist = Services.blocklist;
// The blocklist service defers plugin request until the Blocklist
// module loads. Make sure it loads, or we'll wait forever.
executeSoon(() => {
void Blocklist;
});
// should NOT be marked as outdated by the blocklist
Assert.equal(
await gBlocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9"),
nsIBLS.STATE_NOT_BLOCKED
);
});
add_task(async function test_part_1() {
// update blocklist with data that marks the plugin as outdated
await loadBlocklist("test_bug514327_3_outdated_1.xml");
// plugin should now be marked as outdated
Assert.equal(
await gBlocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9"),
nsIBLS.STATE_OUTDATED
);
});
add_task(async function test_part_2() {
// update blocklist with data that marks the plugin as outdated
await loadBlocklist("test_bug514327_3_outdated_2.xml");
// plugin should still be marked as outdated
Assert.equal(
await gBlocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9"),
nsIBLS.STATE_OUTDATED
);
});

View File

@ -1,73 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var PLUGINS = [
{
// Normal blocklisted plugin, before an invalid regexp
name: "test_bug468528_1",
version: "5",
disabled: false,
blocklisted: false,
},
{
// Normal blocklisted plugin, with an invalid regexp
name: "test_bug468528_2",
version: "5",
disabled: false,
blocklisted: false,
},
{
// Normal blocklisted plugin, after an invalid regexp
name: "test_bug468528_3",
version: "5",
disabled: false,
blocklisted: false,
},
{
// Non-blocklisted plugin
name: "test_bug468528_4",
version: "5",
disabled: false,
blocklisted: false,
},
];
add_task(async function checkBlocklistForRegexes() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
// We cannot force the blocklist to update so just copy our test list to the profile
copyBlocklistToProfile(do_get_file("../data/test_bug468528.xml"));
var { blocklist } = Services;
// The blocklist service defers plugin request until the Blocklist
// module loads. Make sure it loads, or we'll wait forever.
executeSoon(() => {
void Blocklist;
});
// blocked (sanity check)
Assert.equal(
await blocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9"),
blocklist.STATE_BLOCKED
);
// not blocked - won't match due to invalid regexp
Assert.equal(
await blocklist.getPluginBlocklistState(PLUGINS[1], "1", "1.9"),
blocklist.STATE_NOT_BLOCKED
);
// blocked - the invalid regexp for the previous item shouldn't affect this one
Assert.equal(
await blocklist.getPluginBlocklistState(PLUGINS[2], "1", "1.9"),
blocklist.STATE_BLOCKED
);
// not blocked - the previous invalid regexp shouldn't act as a wildcard
Assert.equal(
await blocklist.getPluginBlocklistState(PLUGINS[3], "1", "1.9"),
blocklist.STATE_NOT_BLOCKED
);
});

View File

@ -1,73 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var PLUGINS = [
{
// blocklisted - default severity
name: "test_bug514327_1",
version: "5",
disabled: false,
blocklisted: false,
},
{
// outdated - severity of "0"
name: "test_bug514327_2",
version: "5",
disabled: false,
blocklisted: false,
},
{
// outdated - severity of "0"
name: "test_bug514327_3",
version: "5",
disabled: false,
blocklisted: false,
},
{
// not blocklisted, not outdated
name: "test_bug514327_4",
version: "5",
disabled: false,
blocklisted: false,
outdated: false,
},
];
add_task(async function checkBlocklistSeverities() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
copyBlocklistToProfile(do_get_file("../data/test_bug514327_1.xml"));
var { blocklist } = Services;
// The blocklist service defers plugin request until the Blocklist
// module loads. Make sure it loads, or we'll wait forever.
executeSoon(() => {
void Blocklist;
});
// blocked (sanity check)
Assert.equal(
await blocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9"),
blocklist.STATE_BLOCKED
);
// outdated
Assert.equal(
await blocklist.getPluginBlocklistState(PLUGINS[1], "1", "1.9"),
blocklist.STATE_OUTDATED
);
// outdated
Assert.equal(
await blocklist.getPluginBlocklistState(PLUGINS[2], "1", "1.9"),
blocklist.STATE_OUTDATED
);
// not blocked
Assert.equal(
await blocklist.getPluginBlocklistState(PLUGINS[3], "1", "1.9"),
blocklist.STATE_NOT_BLOCKED
);
});

View File

@ -1,121 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Tests resetting of preferences in blocklist entry when an add-on is blocked.
// See bug 802434.
const URI_EXTENSION_BLOCKLIST_DIALOG =
"chrome://mozapps/content/extensions/blocklist.xhtml";
var testserver = createHttpServer({ hosts: ["example.com"] });
gPort = testserver.identity.primaryPort;
testserver.registerDirectory("/data/", do_get_file("../data"));
// A window watcher to handle the blocklist UI.
// Don't need the full interface, attempts to call other methods will just
// throw which is just fine
var WindowWatcher = {
openWindow(parent, url, name, features, args) {
// Should be called to list the newly blocklisted items
Assert.equal(url, URI_EXTENSION_BLOCKLIST_DIALOG);
// Simulate auto-disabling any softblocks
var list = args.wrappedJSObject.list;
list.forEach(function(aItem) {
if (!aItem.blocked) {
aItem.disable = true;
}
});
// run the code after the blocklist is closed
Services.obs.notifyObservers(null, "addon-blocklist-closed");
},
QueryInterface: ChromeUtils.generateQI(["nsIWindowWatcher"]),
};
MockRegistrar.register(
"@mozilla.org/embedcomp/window-watcher;1",
WindowWatcher
);
function load_blocklist(aFile) {
return new Promise(resolve => {
Services.obs.addObserver(function observer() {
Services.obs.removeObserver(observer, "addon-blocklist-updated");
resolve();
}, "addon-blocklist-updated");
Services.prefs.setCharPref(
"extensions.blocklist.url",
`http://localhost:${gPort}/data/${aFile}`
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
});
}
add_task(async function setup() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
await promiseStartupManager();
// Add 2 extensions
await promiseInstallWebExtension({
manifest: {
name: "Blocked add-on-1 with to-be-reset prefs",
version: "1.0",
applications: { gecko: { id: "block1@tests.mozilla.org" } },
},
});
await promiseInstallWebExtension({
manifest: {
name: "Blocked add-on-2 with to-be-reset prefs",
version: "1.0",
applications: { gecko: { id: "block2@tests.mozilla.org" } },
},
});
// Pre-set the preferences that we expect to get reset.
Services.prefs.setIntPref("test.blocklist.pref1", 15);
Services.prefs.setIntPref("test.blocklist.pref2", 15);
Services.prefs.setBoolPref("test.blocklist.pref3", true);
Services.prefs.setBoolPref("test.blocklist.pref4", true);
// Before blocklist is loaded.
let [a1, a2] = await AddonManager.getAddonsByIDs([
"block1@tests.mozilla.org",
"block2@tests.mozilla.org",
]);
Assert.equal(a1.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
Assert.equal(a2.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
Assert.equal(Services.prefs.getIntPref("test.blocklist.pref1"), 15);
Assert.equal(Services.prefs.getIntPref("test.blocklist.pref2"), 15);
Assert.equal(Services.prefs.getBoolPref("test.blocklist.pref3"), true);
Assert.equal(Services.prefs.getBoolPref("test.blocklist.pref4"), true);
});
add_task(async function test_blocks() {
await load_blocklist("test_blocklist_prefs_1.xml");
// Blocklist changes should have applied and the prefs must be reset.
let [a1, a2] = await AddonManager.getAddonsByIDs([
"block1@tests.mozilla.org",
"block2@tests.mozilla.org",
]);
Assert.notEqual(a1, null);
Assert.equal(a1.blocklistState, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
Assert.notEqual(a2, null);
Assert.equal(a2.blocklistState, Ci.nsIBlocklistService.STATE_BLOCKED);
// All these prefs must be reset to defaults.
Assert.equal(Services.prefs.prefHasUserValue("test.blocklist.pref1"), false);
Assert.equal(Services.prefs.prefHasUserValue("test.blocklist.pref2"), false);
Assert.equal(Services.prefs.prefHasUserValue("test.blocklist.pref3"), false);
Assert.equal(Services.prefs.prefHasUserValue("test.blocklist.pref4"), false);
});

View File

@ -1,620 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
const URI_EXTENSION_BLOCKLIST_DIALOG =
"chrome://mozapps/content/extensions/blocklist.xhtml";
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gTestserver.registerDirectory("/data/", do_get_file("../data"));
// Workaround for Bug 658720 - URL formatter can leak during xpcshell tests
const PREF_BLOCKLIST_ITEM_URL = "extensions.blocklist.itemURL";
Services.prefs.setCharPref(
PREF_BLOCKLIST_ITEM_URL,
"http://example.com/blocklist/%blockID%"
);
async function getAddonBlocklistURL(addon) {
let entry = await Blocklist.getAddonBlocklistEntry(addon);
return entry && entry.url;
}
var ADDONS = [
{
// Tests how the blocklist affects a disabled add-on
id: "test_bug455906_1@tests.mozilla.org",
name: "Bug 455906 Addon Test 1",
version: "5",
appVersion: "3",
},
{
// Tests how the blocklist affects an enabled add-on
id: "test_bug455906_2@tests.mozilla.org",
name: "Bug 455906 Addon Test 2",
version: "5",
appVersion: "3",
},
{
// Tests how the blocklist affects an enabled add-on, to be disabled by the notification
id: "test_bug455906_3@tests.mozilla.org",
name: "Bug 455906 Addon Test 3",
version: "5",
appVersion: "3",
},
{
// Tests how the blocklist affects a disabled add-on that was already warned about
id: "test_bug455906_4@tests.mozilla.org",
name: "Bug 455906 Addon Test 4",
version: "5",
appVersion: "3",
},
{
// Tests how the blocklist affects an enabled add-on that was already warned about
id: "test_bug455906_5@tests.mozilla.org",
name: "Bug 455906 Addon Test 5",
version: "5",
appVersion: "3",
},
{
// Tests how the blocklist affects an already blocked add-on
id: "test_bug455906_6@tests.mozilla.org",
name: "Bug 455906 Addon Test 6",
version: "5",
appVersion: "3",
},
{
// Tests how the blocklist affects an incompatible add-on
id: "test_bug455906_7@tests.mozilla.org",
name: "Bug 455906 Addon Test 7",
version: "5",
appVersion: "2",
},
{
// Spare add-on used to ensure we get a notification when switching lists
id: "dummy_bug455906_1@tests.mozilla.org",
name: "Dummy Addon 1",
version: "5",
appVersion: "3",
},
{
// Spare add-on used to ensure we get a notification when switching lists
id: "dummy_bug455906_2@tests.mozilla.org",
name: "Dummy Addon 2",
version: "5",
appVersion: "3",
},
];
// Copy the initial blocklist into the profile to check add-ons start in the
// right state.
// Make sure to do this before we touch the plugin service, since that
// will force a blocklist load.
copyBlocklistToProfile(do_get_file("../data/bug455906_start.xml"));
var PLUGINS = [
// Tests how the blocklist affects a disabled plugin
new MockPluginTag(
{ name: "test_bug455906_1", version: "5" },
Ci.nsIPluginTag.STATE_DISABLED
),
// Tests how the blocklist affects an enabled plugin
new MockPluginTag(
{ name: "test_bug455906_2", version: "5" },
Ci.nsIPluginTag.STATE_ENABLED
),
// Tests how the blocklist affects an enabled plugin, to be disabled by the notification
new MockPluginTag(
{ name: "test_bug455906_3", version: "5" },
Ci.nsIPluginTag.STATE_ENABLED
),
// Tests how the blocklist affects a disabled plugin that was already warned about
new MockPluginTag(
{ name: "test_bug455906_4", version: "5" },
Ci.nsIPluginTag.STATE_DISABLED
),
// Tests how the blocklist affects an enabled plugin that was already warned about
new MockPluginTag(
{ name: "test_bug455906_5", version: "5" },
Ci.nsIPluginTag.STATE_ENABLED
),
// Tests how the blocklist affects an already blocked plugin
new MockPluginTag(
{ name: "test_bug455906_6", version: "5" },
Ci.nsIPluginTag.STATE_ENABLED
),
];
var gNotificationCheck = null;
mockPluginHost(PLUGINS);
// Don't need the full interface, attempts to call other methods will just
// throw which is just fine
var WindowWatcher = {
openWindow(parent, url, name, features, windowArguments) {
// Should be called to list the newly blocklisted items
equal(url, URI_EXTENSION_BLOCKLIST_DIALOG);
if (gNotificationCheck) {
gNotificationCheck(windowArguments.wrappedJSObject);
}
// run the code after the blocklist is closed
Services.obs.notifyObservers(null, "addon-blocklist-closed");
},
QueryInterface: ChromeUtils.generateQI(["nsIWindowWatcher"]),
};
MockRegistrar.register(
"@mozilla.org/embedcomp/window-watcher;1",
WindowWatcher
);
function createAddon(addon) {
return promiseInstallWebExtension({
manifest: {
name: addon.name,
version: addon.version,
applications: {
gecko: {
id: addon.id,
strict_min_version: addon.appVersion,
strict_max_version: addon.appVersion,
},
},
},
});
}
async function loadBlocklist(file, callback) {
let blocklistUpdated = TestUtils.topicObserved("plugin-blocklist-updated");
gNotificationCheck = callback;
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://example.com/data/" + file
);
Blocklist.notify();
await blocklistUpdated;
}
async function check_plugin_state(plugin) {
let blocklistState = await Blocklist.getPluginBlocklistState(plugin);
return `${plugin.disabled},${blocklistState ==
Services.blocklist.STATE_BLOCKED}`;
}
function create_blocklistURL(blockID) {
let url = Services.urlFormatter.formatURLPref(PREF_BLOCKLIST_ITEM_URL);
url = url.replace(/%blockID%/g, blockID);
return url;
}
// Before every main test this is the state the add-ons are meant to be in
async function checkInitialState() {
let addons = await AddonManager.getAddonsByIDs(ADDONS.map(a => a.id));
checkAddonState(addons[0], {
userDisabled: true,
softDisabled: false,
appDisabled: false,
});
checkAddonState(addons[1], {
userDisabled: false,
softDisabled: false,
appDisabled: false,
});
checkAddonState(addons[2], {
userDisabled: false,
softDisabled: false,
appDisabled: false,
});
checkAddonState(addons[3], {
userDisabled: true,
softDisabled: true,
appDisabled: false,
});
checkAddonState(addons[4], {
userDisabled: false,
softDisabled: false,
appDisabled: false,
});
checkAddonState(addons[5], {
userDisabled: false,
softDisabled: false,
appDisabled: true,
});
checkAddonState(addons[6], {
userDisabled: false,
softDisabled: false,
appDisabled: true,
});
equal(await check_plugin_state(PLUGINS[0]), "true,false");
equal(await check_plugin_state(PLUGINS[1]), "false,false");
equal(await check_plugin_state(PLUGINS[2]), "false,false");
equal(await check_plugin_state(PLUGINS[3]), "true,false");
equal(await check_plugin_state(PLUGINS[4]), "false,false");
equal(await check_plugin_state(PLUGINS[5]), "false,true");
}
function checkAddonState(addon, state) {
return checkAddon(addon.id, addon, state);
}
add_task(async function setup() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "3");
await promiseStartupManager();
for (let addon of ADDONS) {
await createAddon(addon);
}
});
add_task(async function test_1() {
// Tests the add-ons were installed and the initial blocklist applied as expected
let addons = await AddonManager.getAddonsByIDs(ADDONS.map(a => a.id));
for (var i = 0; i < ADDONS.length; i++) {
ok(addons[i], `Addon ${i + 1} should be installed correctly`);
}
checkAddonState(addons[0], {
userDisabled: false,
softDisabled: false,
appDisabled: false,
});
checkAddonState(addons[1], {
userDisabled: false,
softDisabled: false,
appDisabled: false,
});
checkAddonState(addons[2], {
userDisabled: false,
softDisabled: false,
appDisabled: false,
});
// Warn add-ons should be soft disabled automatically
checkAddonState(addons[3], {
userDisabled: true,
softDisabled: true,
appDisabled: false,
});
checkAddonState(addons[4], {
userDisabled: true,
softDisabled: true,
appDisabled: false,
});
// Blocked and incompatible should be app disabled only
checkAddonState(addons[5], {
userDisabled: false,
softDisabled: false,
appDisabled: true,
});
checkAddonState(addons[6], {
userDisabled: false,
softDisabled: false,
appDisabled: true,
});
// We've overridden the plugin host so we cannot tell what that would have
// initialised the plugins as
// Put the add-ons into the base state
await addons[0].disable();
await addons[4].enable();
await promiseRestartManager();
await checkInitialState();
await loadBlocklist("bug455906_warn.xml", args => {
dump("Checking notification pt 2\n");
equal(args.list.length, 4);
for (let addon of args.list) {
if (addon.item instanceof Ci.nsIPluginTag) {
switch (addon.item.name) {
case "test_bug455906_2":
ok(!addon.blocked);
break;
case "test_bug455906_3":
ok(!addon.blocked);
addon.disable = true;
break;
default:
do_throw("Unknown addon: " + addon.item.name);
}
} else {
switch (addon.item.id) {
case "test_bug455906_2@tests.mozilla.org":
ok(!addon.blocked);
break;
case "test_bug455906_3@tests.mozilla.org":
ok(!addon.blocked);
addon.disable = true;
break;
default:
do_throw("Unknown addon: " + addon.item.id);
}
}
}
});
await promiseRestartManager();
dump("Checking results pt 2\n");
addons = await AddonManager.getAddonsByIDs(ADDONS.map(a => a.id));
// Should have disabled this add-on as requested
checkAddonState(addons[2], {
userDisabled: true,
softDisabled: true,
appDisabled: false,
});
equal(await check_plugin_state(PLUGINS[2]), "true,false");
// The blocked add-on should have changed to soft disabled
checkAddonState(addons[5], {
userDisabled: true,
softDisabled: true,
appDisabled: false,
});
checkAddonState(addons[6], {
userDisabled: true,
softDisabled: true,
appDisabled: true,
});
equal(await check_plugin_state(PLUGINS[5]), "true,false");
// These should have been unchanged
checkAddonState(addons[0], {
userDisabled: true,
softDisabled: false,
appDisabled: false,
});
checkAddonState(addons[1], {
userDisabled: false,
softDisabled: false,
appDisabled: false,
});
checkAddonState(addons[3], {
userDisabled: true,
softDisabled: true,
appDisabled: false,
});
checkAddonState(addons[4], {
userDisabled: false,
softDisabled: false,
appDisabled: false,
});
equal(await check_plugin_state(PLUGINS[0]), "true,false");
equal(await check_plugin_state(PLUGINS[1]), "false,false");
equal(await check_plugin_state(PLUGINS[3]), "true,false");
equal(await check_plugin_state(PLUGINS[4]), "false,false");
// Back to starting state
await addons[2].enable();
await addons[5].enable();
PLUGINS[2].enabledState = Ci.nsIPluginTag.STATE_ENABLED;
PLUGINS[5].enabledState = Ci.nsIPluginTag.STATE_ENABLED;
await promiseRestartManager();
await loadBlocklist("bug455906_start.xml");
});
add_task(async function test_pt3() {
await promiseRestartManager();
await checkInitialState();
await loadBlocklist("bug455906_block.xml", args => {
dump("Checking notification pt 3\n");
equal(args.list.length, 3);
for (let addon of args.list) {
if (addon.item instanceof Ci.nsIPluginTag) {
switch (addon.item.name) {
case "test_bug455906_2":
ok(addon.blocked);
break;
case "test_bug455906_3":
ok(addon.blocked);
break;
case "test_bug455906_5":
ok(addon.blocked);
break;
default:
do_throw("Unknown addon: " + addon.item.name);
}
} else {
switch (addon.item.id) {
case "test_bug455906_2@tests.mozilla.org":
ok(addon.blocked);
break;
case "test_bug455906_3@tests.mozilla.org":
ok(addon.blocked);
break;
case "test_bug455906_5@tests.mozilla.org":
ok(addon.blocked);
break;
default:
do_throw("Unknown addon: " + addon.item.id);
}
}
}
});
await promiseRestartManager();
dump("Checking results pt 3\n");
let addons = await AddonManager.getAddonsByIDs(ADDONS.map(a => a.id));
// All should have gained the blocklist state, user disabled as previously
checkAddonState(addons[0], {
userDisabled: true,
softDisabled: false,
appDisabled: true,
});
checkAddonState(addons[1], {
userDisabled: false,
softDisabled: false,
appDisabled: true,
});
checkAddonState(addons[2], {
userDisabled: false,
softDisabled: false,
appDisabled: true,
});
checkAddonState(addons[4], {
userDisabled: false,
softDisabled: false,
appDisabled: true,
});
equal(await check_plugin_state(PLUGINS[0]), "true,true");
equal(await check_plugin_state(PLUGINS[1]), "false,true");
equal(await check_plugin_state(PLUGINS[2]), "false,true");
equal(await check_plugin_state(PLUGINS[3]), "true,true");
equal(await check_plugin_state(PLUGINS[4]), "false,true");
// Should have gained the blocklist state but no longer be soft disabled
checkAddonState(addons[3], {
userDisabled: false,
softDisabled: false,
appDisabled: true,
});
// Check blockIDs are correct
equal(
await getAddonBlocklistURL(addons[0]),
create_blocklistURL(addons[0].id)
);
equal(
await getAddonBlocklistURL(addons[1]),
create_blocklistURL(addons[1].id)
);
equal(
await getAddonBlocklistURL(addons[2]),
create_blocklistURL(addons[2].id)
);
equal(
await getAddonBlocklistURL(addons[3]),
create_blocklistURL(addons[3].id)
);
equal(
await getAddonBlocklistURL(addons[4]),
create_blocklistURL(addons[4].id)
);
// All plugins have the same blockID on the test
equal(
await Blocklist.getPluginBlockURL(PLUGINS[0]),
create_blocklistURL("test_bug455906_plugin")
);
equal(
await Blocklist.getPluginBlockURL(PLUGINS[1]),
create_blocklistURL("test_bug455906_plugin")
);
equal(
await Blocklist.getPluginBlockURL(PLUGINS[2]),
create_blocklistURL("test_bug455906_plugin")
);
equal(
await Blocklist.getPluginBlockURL(PLUGINS[3]),
create_blocklistURL("test_bug455906_plugin")
);
equal(
await Blocklist.getPluginBlockURL(PLUGINS[4]),
create_blocklistURL("test_bug455906_plugin")
);
// Shouldn't be changed
checkAddonState(addons[5], {
userDisabled: false,
softDisabled: false,
appDisabled: true,
});
checkAddonState(addons[6], {
userDisabled: false,
softDisabled: false,
appDisabled: true,
});
equal(await check_plugin_state(PLUGINS[5]), "false,true");
// Back to starting state
await loadBlocklist("bug455906_start.xml");
});
add_task(async function test_pt4() {
let addon = await AddonManager.getAddonByID(ADDONS[4].id);
await addon.enable();
PLUGINS[4].enabledState = Ci.nsIPluginTag.STATE_ENABLED;
await promiseRestartManager();
await checkInitialState();
await loadBlocklist("bug455906_empty.xml", args => {
dump("Checking notification pt 4\n");
// Should be just the dummy add-on to force this notification
equal(args.list.length, 1);
equal(false, args.list[0].item instanceof Ci.nsIPluginTag);
equal(args.list[0].item.id, "dummy_bug455906_2@tests.mozilla.org");
});
await promiseRestartManager();
dump("Checking results pt 4\n");
let addons = await AddonManager.getAddonsByIDs(ADDONS.map(a => a.id));
// This should have become unblocked
checkAddonState(addons[5], {
userDisabled: false,
softDisabled: false,
appDisabled: false,
});
equal(await check_plugin_state(PLUGINS[5]), "false,false");
// Should get re-enabled
checkAddonState(addons[3], {
userDisabled: false,
softDisabled: false,
appDisabled: false,
});
// No change for anything else
checkAddonState(addons[0], {
userDisabled: true,
softDisabled: false,
appDisabled: false,
});
checkAddonState(addons[1], {
userDisabled: false,
softDisabled: false,
appDisabled: false,
});
checkAddonState(addons[2], {
userDisabled: false,
softDisabled: false,
appDisabled: false,
});
checkAddonState(addons[4], {
userDisabled: false,
softDisabled: false,
appDisabled: false,
});
checkAddonState(addons[6], {
userDisabled: false,
softDisabled: false,
appDisabled: true,
});
equal(await check_plugin_state(PLUGINS[0]), "true,false");
equal(await check_plugin_state(PLUGINS[1]), "false,false");
equal(await check_plugin_state(PLUGINS[2]), "false,false");
equal(await check_plugin_state(PLUGINS[3]), "true,false");
equal(await check_plugin_state(PLUGINS[4]), "false,false");
});

View File

@ -1,329 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { Blocklist } = ChromeUtils.import(
"resource://gre/modules/Blocklist.jsm"
);
const { TelemetryController } = ChromeUtils.import(
"resource://gre/modules/TelemetryController.jsm"
);
const { TelemetryTestUtils } = ChromeUtils.import(
"resource://testing-common/TelemetryTestUtils.jsm"
);
const PREF_BLOCKLIST_URL = "extensions.blocklist.url";
AddonTestUtils.init(this);
AddonTestUtils.createAppInfo(
"xpcshell@tests.mozilla.org",
"XPCShell",
"1",
"49"
);
const serverTime = new Date();
const lastUpdateTimestamp = serverTime.getTime() - 2000;
const lastUpdateUTCString = new Date(lastUpdateTimestamp).toUTCString();
let blocklistHandler;
const server = AddonTestUtils.createHttpServer({
hosts: ["example.com"],
});
server.registerPathHandler("/blocklist.xml", (request, response) => {
if (blocklistHandler) {
const handler = blocklistHandler;
blocklistHandler = null;
handler(request, response);
} else {
response.setStatusLine(
request.httpVersion,
501,
"test blocklist handler undefined"
);
response.write("");
}
});
function promiseConsoleMessage(regexp) {
return new Promise(resolve => {
const listener = entry => {
if (regexp.test(entry.message)) {
Services.console.unregisterListener(listener);
resolve(entry);
}
};
Services.console.registerListener(listener);
});
}
async function promiseBlocklistUpdateWithError({
serverBlocklistHandler,
expectedConsoleMessage,
}) {
let onceConsoleMessageLogged = promiseConsoleMessage(expectedConsoleMessage);
blocklistHandler = serverBlocklistHandler;
Blocklist.notify();
await onceConsoleMessageLogged;
}
async function promiseBlocklistUpdateSuccessful({ serverBlocklistHandler }) {
const promiseBlocklistLoaded = TestUtils.topicObserved(
"addon-blocklist-updated"
);
blocklistHandler = serverBlocklistHandler;
Blocklist.notify();
await promiseBlocklistLoaded;
}
function createBlocklistHandler({ lastupdate }) {
return (request, response) => {
response.setStatusLine(
request.httpVersion,
200,
"test successfull blocklist update"
);
response.setHeader("Last-Modified", serverTime.toUTCString());
response.write(`<?xml version='1.0' encoding='UTF-8'?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist"
lastupdate="${lastupdate}">
</blocklist>
`);
};
}
async function assertTelemetryOnBlocklistUpdateError({
serverBlocklistHandler,
expectedConsoleMessage,
expectedTelemetryEvents,
}) {
blocklistHandler = serverBlocklistHandler;
let onceConsoleMessageLogged = promiseConsoleMessage(expectedConsoleMessage);
await Blocklist.notify();
await onceConsoleMessageLogged;
TelemetryTestUtils.assertEvents(expectedTelemetryEvents, {
category: "addonsManager",
method: "blocklistUpdateError",
});
}
add_task(async function test_setup() {
Services.prefs.setCharPref(
PREF_BLOCKLIST_URL,
"http://example.com/blocklist.xml"
);
// Ensure the telemetry event category is enabled.
await AddonTestUtils.promiseStartupManager();
// Ensure that the telemetry event definition is loaded.
await TelemetryController.testSetup();
});
add_task(async function test_lastModifed_xml_on_blocklist_updates() {
Services.telemetry.clearScalars();
info(
"Verify lastModified_xml scalar is updated after a successfull blocklist update"
);
await promiseBlocklistUpdateSuccessful({
serverBlocklistHandler: createBlocklistHandler({
lastupdate: lastUpdateTimestamp,
}),
});
let scalars = TelemetryTestUtils.getProcessScalars("parent");
equal(
scalars["blocklist.lastModified_xml"],
lastUpdateUTCString,
"Got the expected value set on the telemetry scalar"
);
info(
"Verify lastModified_xml scalar is updated after a blocklist update failure"
);
await promiseBlocklistUpdateWithError({
serverBlocklistHandler(request, response) {
response.setStatusLine(
request.httpVersion,
501,
"test failed blocklist update"
);
response.write("");
},
expectedConsoleMessage: /^Blocklist::onXMLLoad: there was an error/,
});
scalars = TelemetryTestUtils.getProcessScalars("parent");
equal(
scalars["blocklist.lastModified_xml"],
lastUpdateUTCString,
"Expect the telemetry scalar to be unchanged after a failed blocklist update"
);
});
add_task(async function test_lastModifed_xml_on_blocklist_loaded_from_disk() {
Services.telemetry.clearScalars();
const { BlocklistXML } = ChromeUtils.import(
"resource://gre/modules/Blocklist.jsm",
null
);
// Force the blocklist to be read from file again.
BlocklistXML._clear();
await BlocklistXML.loadBlocklistAsync();
let scalars = TelemetryTestUtils.getProcessScalars("parent");
equal(
scalars["blocklist.lastModified_xml"],
lastUpdateUTCString,
"Got the expect the telemetry scalar value"
);
});
add_task(async function test_lastModified_xml_invalid_lastupdate_attribute() {
Services.telemetry.clearScalars();
await promiseBlocklistUpdateSuccessful({
serverBlocklistHandler: createBlocklistHandler({
lastupdate: "not a timestamp",
}),
});
let scalars = TelemetryTestUtils.getProcessScalars("parent");
equal(
scalars["blocklist.lastModified_xml"],
"Invalid Date",
"Expect the telemetry scalar to be unchanged"
);
});
add_task(async function test_lastModified_xml_on_empty_lastupdate_attribute() {
Services.telemetry.clearScalars();
await promiseBlocklistUpdateSuccessful({
serverBlocklistHandler: createBlocklistHandler({
lastupdate: "",
}),
});
let scalars = TelemetryTestUtils.getProcessScalars("parent");
equal(
scalars["blocklist.lastModified_xml"],
"Missing Date",
"Expect the telemetry scalar to be unchanged"
);
});
add_task(async function test_blocklist_telemetry_event() {
Services.telemetry.clearEvents();
info("Verify telemetry event recorded on unexpected HTTP status code");
await assertTelemetryOnBlocklistUpdateError({
serverBlocklistHandler: (request, response) => {
response.setStatusLine(
request.httpVersion,
501,
"unexpected status code"
);
response.write("");
},
expectedConsoleMessage: /^Blocklist::onXMLLoad: there was an error/,
expectedTelemetryEvents: [
{
category: "addonsManager",
method: "blocklistUpdateError",
object: "xml",
value: "UNEXPECTED_STATUS_CODE",
extra: { status_code: "501" },
},
],
});
info("Verify telemetry event recorded on XML parse error");
await assertTelemetryOnBlocklistUpdateError({
serverBlocklistHandler: (request, response) => {
response.setStatusLine(request.httpVersion, 200, "OK");
response.write("");
},
expectedConsoleMessage: /^Blocklist::onXMLLoad: there was an error during load, we got invalid XML/,
expectedTelemetryEvents: [
{
category: "addonsManager",
method: "blocklistUpdateError",
object: "xml",
value: "INVALID_XML_ERROR",
},
],
});
info("Verify telemetry event recorded on XHR load error");
Services.prefs.setCharPref(
PREF_BLOCKLIST_URL,
// Use the wrong schema to trigger a XHR load error.
"https://example.com/blocklist.xml"
);
await assertTelemetryOnBlocklistUpdateError({
expectedConsoleMessage: /^Blocklist:onError/,
expectedTelemetryEvents: [
{
category: "addonsManager",
method: "blocklistUpdateError",
object: "xml",
value: "DOWNLOAD_ERROR",
extra: { status_code: "0" },
},
],
});
info(
"Verify telemetry event recorded on errors creating the blocklist server url error"
);
Services.prefs.setCharPref(PREF_BLOCKLIST_URL, "an invalid url");
await assertTelemetryOnBlocklistUpdateError({
expectedConsoleMessage: /^Blocklist::notify: There was an error creating the blocklist URI/,
expectedTelemetryEvents: [
{
category: "addonsManager",
method: "blocklistUpdateError",
object: "xml",
value: "INVALID_BLOCKLIST_URL",
},
],
});
info(
"Verify telemetry event recorded on missing blocklist server url preference"
);
// Replace the BlocklistXML._getBlocklistServerURL method to trigger a
// "missing blocklist url pref" scenario (clearing the pref is not enough because
// the url from the default pref value just takes its place).
const { BlocklistXML } = ChromeUtils.import(
"resource://gre/modules/Blocklist.jsm",
null
);
const _getBlocklistServerURL = BlocklistXML._getBlocklistServerURL;
BlocklistXML._getBlocklistServerURL = () => {
BlocklistXML._getBlocklistServerURL = _getBlocklistServerURL;
throw new Error("Fake missing blocklist url pref");
};
await assertTelemetryOnBlocklistUpdateError({
expectedConsoleMessage: /^Blocklist::notify: The extensions.blocklist.url preference is missing!/,
expectedTelemetryEvents: [
{
category: "addonsManager",
method: "blocklistUpdateError",
object: "xml",
value: "MISSING_BLOCKLIST_SERVER_URL",
},
],
});
});

View File

@ -1,113 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
const PREF_BLOCKLIST_URL = "extensions.blocklist.url";
const PREF_BLOCKLIST_ENABLED = "extensions.blocklist.enabled";
const PREF_APP_DISTRIBUTION = "distribution.id";
const PREF_APP_DISTRIBUTION_VERSION = "distribution.version";
const PREF_APP_UPDATE_CHANNEL = "app.update.channel";
// Get the HTTP server.
var testserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
async function updateBlocklist(file) {
let blocklistUpdated = TestUtils.topicObserved("addon-blocklist-updated");
Blocklist.notify();
return blocklistUpdated;
}
add_task(async function setup() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
await promiseStartupManager();
});
add_task(async function test_blocklist_disabled() {
testserver.registerPathHandler("/1", () => {
ok(
false,
"Should not have attempted to retrieve the blocklist when it is disabled"
);
});
// This should have no effect as the blocklist is disabled
Services.prefs.setCharPref(PREF_BLOCKLIST_URL, "http://example.com/1");
Services.prefs.setBoolPref(PREF_BLOCKLIST_ENABLED, false);
// No await here. We're not expecting it to resolve until the
// blocklist is re-enabled.
updateBlocklist();
});
add_task(async function test_blocklist_disabled() {
var ABI = "noarch-spidermonkey";
let osVersion;
try {
osVersion =
Services.sysinfo.getProperty("name") +
" " +
Services.sysinfo.getProperty("version");
if (osVersion) {
osVersion +=
" (" + Services.sysinfo.getProperty("secondaryLibrary") + ")";
}
} catch (e) {}
const EXPECTED = {
app_id: "xpcshell@tests.mozilla.org",
app_version: 1,
product: "XPCShell",
version: 1,
build_id: gAppInfo.appBuildID,
build_target: "XPCShell_" + ABI,
locale: "locale",
channel: "updatechannel",
os_version: osVersion,
platform_version: "1.9",
distribution: "distribution",
distribution_version: "distribution-version",
};
const PARAMS = Object.keys(EXPECTED)
.map(key => `${key}=%${key.toUpperCase()}%`)
.join("&");
let gotRequest = new Promise(resolve => {
testserver.registerPathHandler("/2", (request, response) => {
let params = new URLSearchParams(request.queryString);
for (let [key, val] of Object.entries(EXPECTED)) {
equal(
String(params.get(key)),
val,
`Expected value for ${key} parameter`
);
}
resolve();
});
});
// Some values have to be on the default branch to work
var defaults = Services.prefs
.QueryInterface(Ci.nsIPrefService)
.getDefaultBranch(null);
defaults.setCharPref(PREF_APP_UPDATE_CHANNEL, EXPECTED.channel);
defaults.setCharPref(PREF_APP_DISTRIBUTION, EXPECTED.distribution);
defaults.setCharPref(
PREF_APP_DISTRIBUTION_VERSION,
EXPECTED.distribution_version
);
Services.locale.requestedLocales = [EXPECTED.locale];
// This should correctly escape everything
Services.prefs.setCharPref(
PREF_BLOCKLIST_URL,
"http://example.com/2?" + PARAMS
);
Services.prefs.setBoolPref(PREF_BLOCKLIST_ENABLED, true);
await updateBlocklist();
await gotRequest;
});

View File

@ -1,133 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
const PREF_BLOCKLIST_LASTUPDATETIME =
"app.update.lastUpdateTime.blocklist-background-update-timer";
const PREF_BLOCKLIST_PINGCOUNTTOTAL = "extensions.blocklist.pingCountTotal";
const PREF_BLOCKLIST_PINGCOUNTVERSION = "extensions.blocklist.pingCountVersion";
const SECONDS_IN_DAY = 60 * 60 * 24;
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
let resolveQuery;
gTestserver.registerPathHandler("/", function pathHandler(metadata, response) {
resolveQuery(metadata.queryString);
});
async function checkQuery(expected) {
let promise = new Promise(resolve => {
resolveQuery = resolve;
});
Blocklist.notify();
equal(await promise, expected, "Got expected blocklist query string");
}
add_task(async function setup() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
gTestserver = new HttpServer();
gTestserver.start(-1);
gPort = gTestserver.identity.primaryPort;
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://example.com/?%PING_COUNT%&%TOTAL_PING_COUNT%&%DAYS_SINCE_LAST_PING%"
);
});
function getNowInSeconds() {
return Math.round(Date.now() / 1000);
}
add_task(async function test1() {
await checkQuery("1&1&new");
});
add_task(async function test2() {
await checkQuery("invalid&invalid&invalid");
});
add_task(async function test3() {
Services.prefs.setIntPref(
PREF_BLOCKLIST_LASTUPDATETIME,
getNowInSeconds() - SECONDS_IN_DAY
);
await checkQuery("2&2&1");
});
add_task(async function test4() {
Services.prefs.setIntPref(PREF_BLOCKLIST_PINGCOUNTVERSION, -1);
Services.prefs.setIntPref(
PREF_BLOCKLIST_LASTUPDATETIME,
getNowInSeconds() - SECONDS_IN_DAY * 2
);
await checkQuery("1&3&2");
});
add_task(async function test5() {
Services.prefs.setIntPref(PREF_BLOCKLIST_LASTUPDATETIME, getNowInSeconds());
await checkQuery("invalid&invalid&0");
});
add_task(async function test6() {
Services.prefs.setIntPref(
PREF_BLOCKLIST_LASTUPDATETIME,
getNowInSeconds() - SECONDS_IN_DAY * 3
);
await checkQuery("2&4&3");
});
add_task(async function test7() {
Services.prefs.setIntPref(PREF_BLOCKLIST_PINGCOUNTVERSION, 2147483647);
Services.prefs.setIntPref(
PREF_BLOCKLIST_LASTUPDATETIME,
getNowInSeconds() - SECONDS_IN_DAY * 4
);
await checkQuery("2147483647&5&4");
});
add_task(async function test8() {
Services.prefs.setIntPref(
PREF_BLOCKLIST_LASTUPDATETIME,
getNowInSeconds() - SECONDS_IN_DAY * 5
);
await checkQuery("1&6&5");
});
add_task(async function test9() {
Services.prefs.setIntPref(PREF_BLOCKLIST_PINGCOUNTTOTAL, 2147483647);
Services.prefs.setIntPref(
PREF_BLOCKLIST_LASTUPDATETIME,
getNowInSeconds() - SECONDS_IN_DAY * 6
);
await checkQuery("2&2147483647&6");
});
add_task(async function test10() {
Services.prefs.setIntPref(
PREF_BLOCKLIST_LASTUPDATETIME,
getNowInSeconds() - SECONDS_IN_DAY * 7
);
await checkQuery("3&1&7");
});
add_task(async function test11() {
Services.prefs.setIntPref(PREF_BLOCKLIST_PINGCOUNTVERSION, -1);
Services.prefs.setIntPref(
PREF_BLOCKLIST_LASTUPDATETIME,
getNowInSeconds() - SECONDS_IN_DAY * 8
);
await checkQuery("1&2&8");
});
add_task(async function test12() {
Services.prefs.setIntPref(
PREF_BLOCKLIST_LASTUPDATETIME,
getNowInSeconds() - SECONDS_IN_DAY * 9
);
await checkQuery("2&3&9");
});

View File

@ -1,90 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
// Test whether a machine which differs only on device ID, but otherwise
// exactly matches the blacklist entry, is not blocked.
// Uses test_gfxBlacklist.xml
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = gTestserver.identity.primaryPort;
gTestserver.registerDirectory("/data/", do_get_file("../data"));
function load_blocklist(file) {
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://localhost:" + gPort + "/data/" + file
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
}
// Performs the initial setup
async function run_test() {
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
do_test_finished();
return;
}
gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
gfxInfo.fireTestProcess();
// Set the vendor/device ID, etc, to match the test file.
switch (Services.appinfo.OS) {
case "WINNT":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x9876");
gfxInfo.spoofDriverVersion("8.52.322.2201");
// Windows 7
gfxInfo.spoofOSVersion(0x60001);
break;
case "Linux":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x9876");
break;
case "Darwin":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x9876");
gfxInfo.spoofOSVersion(0x1090);
break;
case "Android":
gfxInfo.spoofVendorID("abcd");
gfxInfo.spoofDeviceID("aabb");
gfxInfo.spoofDriverVersion("5");
break;
}
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
await promiseStartupManager();
function checkBlacklist() {
var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_CANVAS2D_ACCELERATION
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
do_test_finished();
}
Services.obs.addObserver(function(aSubject, aTopic, aData) {
// If we wait until after we go through the event loop, gfxInfo is sure to
// have processed the gfxItems event.
executeSoon(checkBlacklist);
}, "blocklist-data-gfxItems");
load_blocklist("test_gfxBlacklist.xml");
}

View File

@ -1,84 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
// Test whether a new-enough driver bypasses the blacklist, even if the rest of
// the attributes match the blacklist entry.
// Uses test_gfxBlacklist.xml
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = gTestserver.identity.primaryPort;
gTestserver.registerDirectory("/data/", do_get_file("../data"));
function load_blocklist(file) {
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://localhost:" + gPort + "/data/" + file
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
}
// Performs the initial setup
async function run_test() {
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
do_test_finished();
return;
}
gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
gfxInfo.fireTestProcess();
// Set the vendor/device ID, etc, to match the test file.
switch (Services.appinfo.OS) {
case "WINNT":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
gfxInfo.spoofDriverVersion("8.52.322.2202");
// Windows 7
gfxInfo.spoofOSVersion(0x60001);
break;
case "Linux":
// We don't support driver versions on Linux.
do_test_finished();
return;
case "Darwin":
// We don't support driver versions on Darwin.
do_test_finished();
return;
case "Android":
gfxInfo.spoofVendorID("abcd");
gfxInfo.spoofDeviceID("wxyz");
gfxInfo.spoofDriverVersion("6");
break;
}
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
await promiseStartupManager();
function checkBlacklist() {
var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
do_test_finished();
}
Services.obs.addObserver(function(aSubject, aTopic, aData) {
// If we wait until after we go through the event loop, gfxInfo is sure to
// have processed the gfxItems event.
executeSoon(checkBlacklist);
}, "blocklist-data-gfxItems");
load_blocklist("test_gfxBlacklist.xml");
}

View File

@ -1,125 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
// Test whether a machine which is newer than the equal
// blacklist entry is allowed.
// Uses test_gfxBlacklist.xml
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = gTestserver.identity.primaryPort;
gTestserver.registerDirectory("/data/", do_get_file("../data"));
function load_blocklist(file) {
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://localhost:" + gPort + "/data/" + file
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
}
// Performs the initial setup
async function run_test() {
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
do_test_finished();
return;
}
gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
gfxInfo.fireTestProcess();
// Set the vendor/device ID, etc, to match the test file.
switch (Services.appinfo.OS) {
case "WINNT":
gfxInfo.spoofVendorID("0xdcdc");
gfxInfo.spoofDeviceID("0x1234");
gfxInfo.spoofDriverVersion("8.52.322.1112");
// Windows 7
gfxInfo.spoofOSVersion(0x60001);
break;
case "Linux":
// We don't support driver versions on Linux.
do_test_finished();
return;
case "Darwin":
// We don't support driver versions on OS X.
do_test_finished();
return;
case "Android":
gfxInfo.spoofVendorID("dcdc");
gfxInfo.spoofDeviceID("uiop");
gfxInfo.spoofDriverVersion("6");
break;
}
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "15.0", "8");
await promiseStartupManager();
function checkBlacklist() {
var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
// Make sure unrelated features aren't affected
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_11_LAYERS);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_OPENGL_LAYERS);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_11_ANGLE);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_HARDWARE_VIDEO_DECODING
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_WEBRTC_HW_ACCELERATION_H264
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_WEBRTC_HW_ACCELERATION_DECODE
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_WEBRTC_HW_ACCELERATION_ENCODE
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBGL_MSAA);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBGL_ANGLE);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_CANVAS2D_ACCELERATION
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
do_test_finished();
}
Services.obs.addObserver(function(aSubject, aTopic, aData) {
// If we wait until after we go through the event loop, gfxInfo is sure to
// have processed the gfxItems event.
executeSoon(checkBlacklist);
}, "blocklist-data-gfxItems");
load_blocklist("test_gfxBlacklist.xml");
}

View File

@ -1,86 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
// Test whether a machine which is older than the equal
// blacklist entry is correctly allowed.
// Uses test_gfxBlacklist.xml
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = gTestserver.identity.primaryPort;
gTestserver.registerDirectory("/data/", do_get_file("../data"));
function load_blocklist(file) {
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://localhost:" + gPort + "/data/" + file
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
}
// Performs the initial setup
async function run_test() {
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
do_test_finished();
return;
}
gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
gfxInfo.fireTestProcess();
// Set the vendor/device ID, etc, to match the test file.
switch (Services.appinfo.OS) {
case "WINNT":
gfxInfo.spoofVendorID("0xdcdc");
gfxInfo.spoofDeviceID("0x1234");
gfxInfo.spoofDriverVersion("8.52.322.1110");
// Windows 7
gfxInfo.spoofOSVersion(0x60001);
break;
case "Linux":
// We don't support driver versions on Linux.
do_test_finished();
return;
case "Darwin":
// We don't support driver versions on Darwin.
do_test_finished();
return;
case "Android":
gfxInfo.spoofVendorID("dcdc");
gfxInfo.spoofDeviceID("uiop");
gfxInfo.spoofDriverVersion("4");
break;
}
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
await promiseStartupManager();
function checkBlacklist() {
var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
// Make sure unrelated features aren't affected
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
do_test_finished();
}
Services.obs.addObserver(function(aSubject, aTopic, aData) {
// If we wait until after we go through the event loop, gfxInfo is sure to
// have processed the gfxItems event.
executeSoon(checkBlacklist);
}, "blocklist-data-gfxItems");
load_blocklist("test_gfxBlacklist.xml");
}

View File

@ -1,85 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
// Test whether a machine which exactly matches the equal
// blacklist entry is successfully blocked.
// Uses test_gfxBlacklist.xml
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = gTestserver.identity.primaryPort;
gTestserver.registerDirectory("/data/", do_get_file("../data"));
function load_blocklist(file) {
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://localhost:" + gPort + "/data/" + file
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
}
// Performs the initial setup
async function run_test() {
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
do_test_finished();
return;
}
gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
gfxInfo.fireTestProcess();
// Set the vendor/device ID, etc, to match the test file.
switch (Services.appinfo.OS) {
case "WINNT":
gfxInfo.spoofVendorID("0xdcdc");
gfxInfo.spoofDeviceID("0x1234");
gfxInfo.spoofDriverVersion("8.52.322.1111");
// Windows 7
gfxInfo.spoofOSVersion(0x60001);
break;
case "Linux":
// We don't support driver versions on Linux.
do_test_finished();
return;
case "Darwin":
// We don't support driver versions on Darwin.
do_test_finished();
return;
case "Android":
gfxInfo.spoofVendorID("dcdc");
gfxInfo.spoofDeviceID("uiop");
gfxInfo.spoofDriverVersion("5");
break;
}
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
await promiseStartupManager();
function checkBlacklist() {
var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
// Make sure unrelated features aren't affected
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
do_test_finished();
}
Services.obs.addObserver(function(aSubject, aTopic, aData) {
// If we wait until after we go through the event loop, gfxInfo is sure to
// have processed the gfxItems event.
executeSoon(checkBlacklist);
}, "blocklist-data-gfxItems");
load_blocklist("test_gfxBlacklist.xml");
}

View File

@ -1,85 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
// Test whether a machine which is lower than the greater-than-or-equal
// blacklist entry is allowed.
// Uses test_gfxBlacklist.xml
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = gTestserver.identity.primaryPort;
gTestserver.registerDirectory("/data/", do_get_file("../data"));
function load_blocklist(file) {
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://localhost:" + gPort + "/data/" + file
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
}
// Performs the initial setup
async function run_test() {
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
do_test_finished();
return;
}
gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
gfxInfo.fireTestProcess();
// Set the vendor/device ID, etc, to match the test file.
switch (Services.appinfo.OS) {
case "WINNT":
gfxInfo.spoofVendorID("0xabab");
gfxInfo.spoofDeviceID("0x1234");
gfxInfo.spoofDriverVersion("8.52.322.2201");
// Windows 7
gfxInfo.spoofOSVersion(0x60001);
break;
case "Linux":
// We don't support driver versions on Linux.
do_test_finished();
return;
case "Darwin":
// We don't support driver versions on Darwin.
do_test_finished();
return;
case "Android":
gfxInfo.spoofVendorID("abab");
gfxInfo.spoofDeviceID("ghjk");
gfxInfo.spoofDriverVersion("6");
break;
}
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
await promiseStartupManager();
function checkBlacklist() {
var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
// Make sure unrelated features aren't affected
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
do_test_finished();
}
Services.obs.addObserver(function(aSubject, aTopic, aData) {
// If we wait until after we go through the event loop, gfxInfo is sure to
// have processed the gfxItems event.
executeSoon(checkBlacklist);
}, "blocklist-data-gfxItems");
load_blocklist("test_gfxBlacklist.xml");
}

View File

@ -1,85 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
// Test whether a machine which exactly matches the greater-than-or-equal
// blacklist entry is successfully blocked.
// Uses test_gfxBlacklist.xml
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = gTestserver.identity.primaryPort;
gTestserver.registerDirectory("/data/", do_get_file("../data"));
function load_blocklist(file) {
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://localhost:" + gPort + "/data/" + file
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
}
// Performs the initial setup
async function run_test() {
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
do_test_finished();
return;
}
gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
gfxInfo.fireTestProcess();
// Set the vendor/device ID, etc, to match the test file.
switch (Services.appinfo.OS) {
case "WINNT":
gfxInfo.spoofVendorID("0xabab");
gfxInfo.spoofDeviceID("0x1234");
gfxInfo.spoofDriverVersion("8.52.322.2202");
// Windows 7
gfxInfo.spoofOSVersion(0x60001);
break;
case "Linux":
// We don't support driver versions on Linux.
do_test_finished();
return;
case "Darwin":
// We don't support driver versions on Darwin.
do_test_finished();
return;
case "Android":
gfxInfo.spoofVendorID("abab");
gfxInfo.spoofDeviceID("ghjk");
gfxInfo.spoofDriverVersion("7");
break;
}
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
await promiseStartupManager();
function checkBlacklist() {
var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
// Make sure unrelated features aren't affected
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
do_test_finished();
}
Services.obs.addObserver(function(aSubject, aTopic, aData) {
// If we wait until after we go through the event loop, gfxInfo is sure to
// have processed the gfxItems event.
executeSoon(checkBlacklist);
}, "blocklist-data-gfxItems");
load_blocklist("test_gfxBlacklist.xml");
}

View File

@ -1,83 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
// Test whether a machine which exactly matches the blacklist entry is
// successfully blocked.
// Uses test_gfxBlacklist.xml
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = gTestserver.identity.primaryPort;
gTestserver.registerDirectory("/data/", do_get_file("../data"));
function load_blocklist(file) {
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://localhost:" + gPort + "/data/" + file
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
}
// Performs the initial setup
async function run_test() {
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
do_test_finished();
return;
}
gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
gfxInfo.fireTestProcess();
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x6666");
// Spoof the OS version so it matches the test file.
switch (Services.appinfo.OS) {
case "WINNT":
// Windows 7
gfxInfo.spoofOSVersion(0x60001);
break;
case "Linux":
break;
case "Darwin":
gfxInfo.spoofOSVersion(0x1090);
break;
case "Android":
break;
}
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
await promiseStartupManager();
function checkBlacklist() {
var driverVersion = gfxInfo.adapterDriverVersion;
if (driverVersion) {
var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DEVICE);
// Make sure unrelated features aren't affected
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
}
do_test_finished();
}
Services.obs.addObserver(function(aSubject, aTopic, aData) {
// If we wait until after we go through the event loop, gfxInfo is sure to
// have processed the gfxItems event.
executeSoon(checkBlacklist);
}, "blocklist-data-gfxItems");
load_blocklist("test_gfxBlacklist.xml");
}

View File

@ -1,86 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
// Test whether a machine which exactly matches the blacklist entry is
// successfully blocked.
// Uses test_gfxBlacklist.xml
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = gTestserver.identity.primaryPort;
gTestserver.registerDirectory("/data/", do_get_file("../data"));
function load_blocklist(file) {
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://localhost:" + gPort + "/data/" + file
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
}
// Performs the initial setup
async function run_test() {
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
do_test_finished();
return;
}
gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
gfxInfo.fireTestProcess();
// Set the vendor/device ID, etc, to match the test file.
switch (Services.appinfo.OS) {
case "WINNT":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
gfxInfo.spoofDriverVersion("8.52.322.2201");
// Windows 7
gfxInfo.spoofOSVersion(0x60001);
break;
case "Linux":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
break;
case "Darwin":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
gfxInfo.spoofOSVersion(0x1090);
break;
case "Android":
gfxInfo.spoofVendorID("abcd");
gfxInfo.spoofDeviceID("asdf");
gfxInfo.spoofDriverVersion("5");
break;
}
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
await promiseStartupManager();
function checkBlacklist() {
var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
// Make sure unrelated features aren't affected
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
do_test_finished();
}
Services.obs.addObserver(function(aSubject, aTopic, aData) {
// If we wait until after we go through the event loop, gfxInfo is sure to
// have processed the gfxItems event.
executeSoon(checkBlacklist);
}, "blocklist-data-gfxItems");
load_blocklist("test_gfxBlacklist.xml");
}

View File

@ -1,84 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
// Test whether a machine which differs only on OS version, but otherwise
// exactly matches the blacklist entry, is not blocked.
// Uses test_gfxBlacklist.xml
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = gTestserver.identity.primaryPort;
gTestserver.registerDirectory("/data/", do_get_file("../data"));
function load_blocklist(file) {
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://localhost:" + gPort + "/data/" + file
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
}
// Performs the initial setup
async function run_test() {
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
do_test_finished();
return;
}
gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
// Set the vendor/device ID, etc, to match the test file.
switch (Services.appinfo.OS) {
case "WINNT":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
gfxInfo.spoofDriverVersion("8.52.322.2201");
// Windows Vista
gfxInfo.spoofOSVersion(0x60000);
break;
case "Linux":
// We don't have any OS versions on Linux, just "Linux".
do_test_finished();
return;
case "Darwin":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
gfxInfo.spoofOSVersion(0x1080);
break;
case "Android":
// On Android, the driver version is used as the OS version (because
// there's so many of them).
do_test_finished();
return;
}
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
await promiseStartupManager();
function checkBlacklist() {
var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
do_test_finished();
}
Services.obs.addObserver(function(aSubject, aTopic, aData) {
// If we wait until after we go through the event loop, gfxInfo is sure to
// have processed the gfxItems event.
executeSoon(checkBlacklist);
}, "blocklist-data-gfxItems");
load_blocklist("test_gfxBlacklist.xml");
}

View File

@ -1,87 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
// Test whether new OS versions are matched properly.
// Uses test_gfxBlacklist_OS.xml
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = gTestserver.identity.primaryPort;
gTestserver.registerDirectory("/data/", do_get_file("../data"));
function load_blocklist(file) {
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://localhost:" + gPort + "/data/" + file
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
}
// Performs the initial setup
async function run_test() {
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
do_test_finished();
return;
}
gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
gfxInfo.fireTestProcess();
// Set the vendor/device ID, etc, to match the test file.
gfxInfo.spoofDriverVersion("8.52.322.2201");
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
// Spoof the version of the OS appropriately to test the test file.
switch (Services.appinfo.OS) {
case "WINNT":
// Windows 8
gfxInfo.spoofOSVersion(0x60002);
break;
case "Linux":
// We don't have any OS versions on Linux, just "Linux".
do_test_finished();
return;
case "Darwin":
// Mountain Lion
gfxInfo.spoofOSVersion(0x1090);
break;
case "Android":
// On Android, the driver version is used as the OS version (because
// there's so many of them).
do_test_finished();
return;
}
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
await promiseStartupManager();
function checkBlacklist() {
if (Services.appinfo.OS == "WINNT") {
var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
} else if (Services.appinfo.OS == "Darwin") {
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_OPENGL_LAYERS);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
}
do_test_finished();
}
Services.obs.addObserver(function(aSubject, aTopic, aData) {
// If we wait until after we go through the event loop, gfxInfo is sure to
// have processed the gfxItems event.
executeSoon(checkBlacklist);
}, "blocklist-data-gfxItems");
load_blocklist("test_gfxBlacklist_OSVersion.xml");
}

View File

@ -1,87 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
// Test whether blocklists specifying new OSeswcorrectly don't block if driver
// versions are appropriately up-to-date.
// Uses test_gfxBlacklist_OS.xml
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = gTestserver.identity.primaryPort;
gTestserver.registerDirectory("/data/", do_get_file("../data"));
function load_blocklist(file) {
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://localhost:" + gPort + "/data/" + file
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
}
// Performs the initial setup
async function run_test() {
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
do_test_finished();
return;
}
gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
gfxInfo.fireTestProcess();
// Set the vendor/device ID, etc, to match the test file.
gfxInfo.spoofDriverVersion("8.52.322.2202");
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
// Spoof the version of the OS appropriately to test the test file.
switch (Services.appinfo.OS) {
case "WINNT":
// Windows 8
gfxInfo.spoofOSVersion(0x60002);
break;
case "Linux":
// We don't have any OS versions on Linux, just "Linux".
do_test_finished();
return;
case "Darwin":
gfxInfo.spoofOSVersion(0x1080);
break;
case "Android":
// On Android, the driver version is used as the OS version (because
// there's so many of them).
do_test_finished();
return;
}
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
await promiseStartupManager();
function checkBlacklist() {
if (Services.appinfo.OS == "WINNT") {
var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
} else if (Services.appinfo.OS == "Darwin") {
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_OPENGL_LAYERS);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
}
do_test_finished();
}
Services.obs.addObserver(function(aSubject, aTopic, aData) {
// If we wait until after we go through the event loop, gfxInfo is sure to
// have processed the gfxItems event.
executeSoon(checkBlacklist);
}, "blocklist-data-gfxItems");
load_blocklist("test_gfxBlacklist_OSVersion.xml");
}

View File

@ -1,88 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
// Test whether old OS versions are not matched when the blacklist contains
// only new OS versions.
// Uses test_gfxBlacklist_OS.xml
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = gTestserver.identity.primaryPort;
gTestserver.registerDirectory("/data/", do_get_file("../data"));
function load_blocklist(file) {
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://localhost:" + gPort + "/data/" + file
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
}
// Performs the initial setup
async function run_test() {
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
do_test_finished();
return;
}
gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
gfxInfo.fireTestProcess();
// Set the vendor/device ID, etc, to match the test file.
gfxInfo.spoofDriverVersion("8.52.322.2201");
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
// Spoof the version of the OS appropriately to test the test file.
switch (Services.appinfo.OS) {
case "WINNT":
// Windows 7
gfxInfo.spoofOSVersion(0x60001);
break;
case "Linux":
// We don't have any OS versions on Linux, just "Linux".
do_test_finished();
return;
case "Darwin":
// Lion
gfxInfo.spoofOSVersion(0x1080);
break;
case "Android":
// On Android, the driver version is used as the OS version (because
// there's so many of them).
do_test_finished();
return;
}
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
await promiseStartupManager();
function checkBlacklist() {
if (Services.appinfo.OS == "WINNT") {
var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
} else if (Services.appinfo.OS == "Darwin") {
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_OPENGL_LAYERS);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
}
do_test_finished();
}
Services.obs.addObserver(function(aSubject, aTopic, aData) {
// If we wait until after we go through the event loop, gfxInfo is sure to
// have processed the gfxItems event.
executeSoon(checkBlacklist);
}, "blocklist-data-gfxItems");
load_blocklist("test_gfxBlacklist_OSVersion.xml");
}

View File

@ -1,85 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
// Test whether a machine which differs only on vendor, but otherwise
// exactly matches the blacklist entry, is not blocked.
// Uses test_gfxBlacklist.xml
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = gTestserver.identity.primaryPort;
gTestserver.registerDirectory("/data/", do_get_file("../data"));
function load_blocklist(file) {
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://localhost:" + gPort + "/data/" + file
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
}
// Performs the initial setup
async function run_test() {
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
do_test_finished();
return;
}
gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
gfxInfo.fireTestProcess();
// Set the vendor/device ID, etc, to match the test file.
switch (Services.appinfo.OS) {
case "WINNT":
gfxInfo.spoofVendorID("0xdcba");
gfxInfo.spoofDeviceID("0x1234");
gfxInfo.spoofDriverVersion("8.52.322.2201");
// Windows 7
gfxInfo.spoofOSVersion(0x60001);
break;
case "Linux":
gfxInfo.spoofVendorID("0xdcba");
gfxInfo.spoofDeviceID("0x1234");
break;
case "Darwin":
gfxInfo.spoofVendorID("0xdcba");
gfxInfo.spoofDeviceID("0x1234");
gfxInfo.spoofOSVersion(0x1090);
break;
case "Android":
gfxInfo.spoofVendorID("dcba");
gfxInfo.spoofDeviceID("asdf");
gfxInfo.spoofDriverVersion("5");
break;
}
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
await promiseStartupManager();
function checkBlacklist() {
var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
do_test_finished();
}
Services.obs.addObserver(function(aSubject, aTopic, aData) {
// If we wait until after we go through the event loop, gfxInfo is sure to
// have processed the gfxItems event.
executeSoon(checkBlacklist);
}, "blocklist-data-gfxItems");
load_blocklist("test_gfxBlacklist.xml");
}

View File

@ -1,186 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Test whether a machine which exactly matches the blacklist entry is
// successfully blocked.
// Uses test_gfxBlacklist_AllOS.xml
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = gTestserver.identity.primaryPort;
gTestserver.registerDirectory("/data/", do_get_file("../data"));
function load_blocklist(file) {
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://localhost:" + gPort + "/data/" + file
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
}
// Performs the initial setup
async function run_test() {
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
do_test_finished();
return;
}
gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
gfxInfo.fireTestProcess();
// Set the vendor/device ID, etc, to match the test file.
switch (Services.appinfo.OS) {
case "WINNT":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
gfxInfo.spoofDriverVersion("8.52.322.2201");
// Windows 7
gfxInfo.spoofOSVersion(0x60001);
break;
case "Linux":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
break;
case "Darwin":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
gfxInfo.spoofOSVersion(0x1090);
break;
case "Android":
gfxInfo.spoofVendorID("abcd");
gfxInfo.spoofDeviceID("asdf");
gfxInfo.spoofDriverVersion("5");
break;
}
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "15.0", "8");
await promiseStartupManager();
function checkBlacklist() {
var failureId = {};
var status;
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_DIRECT2D,
failureId
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
Assert.equal(failureId.value, "FEATURE_FAILURE_DL_BLACKLIST_g1");
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS,
failureId
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
Assert.equal(failureId.value, "FEATURE_FAILURE_DL_BLACKLIST_g2");
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_DIRECT3D_10_LAYERS,
failureId
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
Assert.equal(failureId.value, "");
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_DIRECT3D_10_1_LAYERS,
failureId
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
Assert.equal(failureId.value, "");
// These four pass on Linux independent of the blocklist XML file as the
// try machines don't have support.
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_OPENGL_LAYERS);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_WEBGL_OPENGL,
failureId
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
Assert.equal(failureId.value, "FEATURE_FAILURE_DL_BLACKLIST_g11");
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_WEBGL_ANGLE,
failureId
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
Assert.equal(failureId.value, "FEATURE_FAILURE_DL_BLACKLIST_NO_ID");
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBGL2, failureId);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
Assert.equal(failureId.value, "FEATURE_FAILURE_DL_BLACKLIST_NO_ID");
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_WEBGL_MSAA,
failureId
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_STAGEFRIGHT,
failureId
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_WEBRTC_HW_ACCELERATION_H264,
failureId
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_WEBRTC_HW_ACCELERATION_ENCODE,
failureId
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_WEBRTC_HW_ACCELERATION_DECODE,
failureId
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_DIRECT3D_11_LAYERS,
failureId
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_HARDWARE_VIDEO_DECODING,
failureId
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_DIRECT3D_11_ANGLE,
failureId
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
status = gfxInfo.getFeatureStatus(
Ci.nsIGfxInfo.FEATURE_DX_INTEROP2,
failureId
);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
do_test_finished();
}
Services.obs.addObserver(function(aSubject, aTopic, aData) {
// If we wait until after we go through the event loop, gfxInfo is sure to
// have processed the gfxItems event.
executeSoon(checkBlacklist);
}, "blocklist-data-gfxItems");
load_blocklist("test_gfxBlacklist_AllOS.xml");
}

View File

@ -1,121 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Test whether the blacklist successfully adds and removes the prefs that store
// its decisions when the remote blacklist is changed.
// Uses test_gfxBlacklist.xml and test_gfxBlacklist2.xml
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = gTestserver.identity.primaryPort;
gTestserver.registerDirectory("/data/", do_get_file("../data"));
function load_blocklist(file) {
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://localhost:" + gPort + "/data/" + file
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
}
// Performs the initial setup
async function run_test() {
try {
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
} catch (e) {
do_test_finished();
return;
}
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
do_test_finished();
return;
}
gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
gfxInfo.fireTestProcess();
// Set the vendor/device ID, etc, to match the test file.
switch (Services.appinfo.OS) {
case "WINNT":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
gfxInfo.spoofDriverVersion("8.52.322.2201");
// Windows 7
gfxInfo.spoofOSVersion(0x60001);
break;
case "Linux":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
break;
case "Darwin":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
gfxInfo.spoofOSVersion(0x1090);
break;
case "Android":
gfxInfo.spoofVendorID("abcd");
gfxInfo.spoofDeviceID("asdf");
gfxInfo.spoofDriverVersion("5");
break;
}
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
await promiseStartupManager();
function blacklistAdded(aSubject, aTopic, aData) {
// If we wait until after we go through the event loop, gfxInfo is sure to
// have processed the gfxItems event.
executeSoon(ensureBlacklistSet);
}
function ensureBlacklistSet() {
var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
// Make sure unrelated features aren't affected
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
Assert.equal(
Services.prefs.getIntPref("gfx.blacklist.direct2d"),
Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION
);
Services.obs.removeObserver(blacklistAdded, "blocklist-data-gfxItems");
Services.obs.addObserver(blacklistRemoved, "blocklist-data-gfxItems");
load_blocklist("test_gfxBlacklist2.xml");
}
function blacklistRemoved(aSubject, aTopic, aData) {
// If we wait until after we go through the event loop, gfxInfo is sure to
// have processed the gfxItems event.
executeSoon(ensureBlacklistUnset);
}
function ensureBlacklistUnset() {
var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
// Make sure unrelated features aren't affected
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
var exists = false;
try {
Services.prefs.getIntPref("gfx.blacklist.direct2d");
exists = true;
} catch (e) {}
Assert.ok(!exists);
do_test_finished();
}
Services.obs.addObserver(blacklistAdded, "blocklist-data-gfxItems");
load_blocklist("test_gfxBlacklist.xml");
}

View File

@ -1,201 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
const KEY_PROFILEDIR = "ProfD";
const KEY_APPDIR = "XCurProcD";
const FILE_BLOCKLIST = "blocklist.xml";
const PREF_BLOCKLIST_ENABLED = "extensions.blocklist.enabled";
const OLD = do_get_file("../data/test_overrideblocklist/old.xml");
const NEW = do_get_file("../data/test_overrideblocklist/new.xml");
const ANCIENT = do_get_file("../data/test_overrideblocklist/ancient.xml");
const gAppDir = FileUtils.getFile(KEY_APPDIR, []);
var oldAddon = {
id: "old@tests.mozilla.org",
version: 1,
};
var newAddon = {
id: "new@tests.mozilla.org",
version: 1,
};
var ancientAddon = {
id: "ancient@tests.mozilla.org",
version: 1,
};
var invalidAddon = {
id: "invalid@tests.mozilla.org",
version: 1,
};
function incrementAppVersion() {
gAppInfo.version = "" + (parseInt(gAppInfo.version) + 1);
}
function clearBlocklists() {
let blocklist = FileUtils.getFile(KEY_APPDIR, [FILE_BLOCKLIST]);
if (blocklist.exists()) {
blocklist.remove(true);
}
blocklist = FileUtils.getFile(KEY_PROFILEDIR, [FILE_BLOCKLIST]);
if (blocklist.exists()) {
blocklist.remove(true);
}
}
let jsmInternalObj = ChromeUtils.import(
"resource://gre/modules/Blocklist.jsm",
null
);
async function reloadBlocklist() {
Services.prefs.setBoolPref(PREF_BLOCKLIST_ENABLED, false);
Services.prefs.setBoolPref(PREF_BLOCKLIST_ENABLED, true);
await jsmInternalObj.BlocklistXML._lastUpdate;
}
function copyToApp(file) {
file.clone().copyTo(gAppDir, FILE_BLOCKLIST);
}
function copyToProfile(file) {
file = file.clone();
file.copyTo(gProfD, FILE_BLOCKLIST);
}
function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
let appBlocklist = FileUtils.getFile(KEY_APPDIR, [FILE_BLOCKLIST]);
if (appBlocklist.exists()) {
try {
appBlocklist.moveTo(gAppDir, "blocklist.old");
} catch (e) {
todo(false, "Aborting test due to unmovable blocklist file: " + e);
return;
}
registerCleanupFunction(function() {
clearBlocklists();
appBlocklist.moveTo(gAppDir, FILE_BLOCKLIST);
});
}
run_next_test();
}
async function isBlocklisted(addon, appVer, toolkitVer) {
let state = await Blocklist.getAddonBlocklistState(addon, appVer, toolkitVer);
return state != Services.blocklist.STATE_NOT_BLOCKED;
}
// On first run whataver is in the app dir should get copied to the profile
add_test(async function test_copy() {
clearBlocklists();
copyToApp(OLD);
incrementAppVersion();
await promiseStartupManager();
await reloadBlocklist();
Assert.ok(!(await isBlocklisted(invalidAddon)));
Assert.ok(!(await isBlocklisted(ancientAddon)));
Assert.ok(await isBlocklisted(oldAddon));
Assert.ok(!(await isBlocklisted(newAddon)));
await promiseShutdownManager();
run_next_test();
});
// An ancient blocklist should be ignored
add_test(async function test_ancient() {
clearBlocklists();
copyToApp(ANCIENT);
copyToProfile(OLD);
incrementAppVersion();
await promiseStartupManager();
await reloadBlocklist();
Assert.ok(!(await isBlocklisted(invalidAddon)));
Assert.ok(!(await isBlocklisted(ancientAddon)));
Assert.ok(await isBlocklisted(oldAddon));
Assert.ok(!(await isBlocklisted(newAddon)));
await promiseShutdownManager();
run_next_test();
});
// A new blocklist should override an old blocklist
add_test(async function test_override() {
clearBlocklists();
copyToApp(NEW);
copyToProfile(OLD);
incrementAppVersion();
await promiseStartupManager();
await reloadBlocklist();
Assert.ok(!(await isBlocklisted(invalidAddon)));
Assert.ok(!(await isBlocklisted(ancientAddon)));
Assert.ok(!(await isBlocklisted(oldAddon)));
Assert.ok(await isBlocklisted(newAddon));
await promiseShutdownManager();
run_next_test();
});
// An old blocklist shouldn't override a new blocklist
add_test(async function test_retain() {
clearBlocklists();
copyToApp(OLD);
copyToProfile(NEW);
incrementAppVersion();
await promiseStartupManager();
await reloadBlocklist();
Assert.ok(!(await isBlocklisted(invalidAddon)));
Assert.ok(!(await isBlocklisted(ancientAddon)));
Assert.ok(!(await isBlocklisted(oldAddon)));
Assert.ok(await isBlocklisted(newAddon));
await promiseShutdownManager();
run_next_test();
});
// A missing blocklist in the profile should still load an app-shipped blocklist
add_test(async function test_missing() {
clearBlocklists();
copyToApp(OLD);
copyToProfile(NEW);
incrementAppVersion();
await promiseStartupManager();
await promiseShutdownManager();
let blocklist = FileUtils.getFile(KEY_PROFILEDIR, [FILE_BLOCKLIST]);
blocklist.remove(true);
await promiseStartupManager();
await reloadBlocklist();
Assert.ok(!(await isBlocklisted(invalidAddon)));
Assert.ok(!(await isBlocklisted(ancientAddon)));
Assert.ok(await isBlocklisted(oldAddon));
Assert.ok(!(await isBlocklisted(newAddon)));
await promiseShutdownManager();
run_next_test();
});

View File

@ -1,235 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const nsIBLS = Ci.nsIBlocklistService;
var gNotifier = null;
var gPluginHost = null;
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gTestserver.registerDirectory("/data/", do_get_file("../data"));
var PLUGINS = [
{
// severity=0, vulnerabilitystatus=0 -> outdated
name: "test_plugin_0",
version: "5",
disabled: false,
blocklisted: false,
},
{
// severity=0, vulnerabilitystatus=1 -> update available
name: "test_plugin_1",
version: "5",
disabled: false,
blocklisted: false,
},
{
// severity=0, vulnerabilitystatus=2 -> no update
name: "test_plugin_2",
version: "5",
disabled: false,
blocklisted: false,
},
{
// no severity field -> severity=3 by default -> hardblock
name: "test_plugin_3",
version: "5",
disabled: false,
blocklisted: false,
},
{
// severity=1, vulnerabilitystatus=2 -> softblock
name: "test_plugin_4",
version: "5",
disabled: false,
blocklisted: false,
},
{
// not in the blocklist -> not blocked
name: "test_plugin_5",
version: "5",
disabled: false,
blocklisted: false,
},
];
async function updateBlocklist(blocklistURL) {
if (blocklistURL) {
Services.prefs.setCharPref("extensions.blocklist.url", blocklistURL);
}
let blocklistUpdated = TestUtils.topicObserved("plugin-blocklist-updated");
gNotifier.notify(null);
return blocklistUpdated;
}
add_task(async function setup() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
Services.prefs.setCharPref(
"extensions.blocklist.url",
"http://example.com/data/test_pluginBlocklistCtp.xml"
);
// plugin.load_flash_only is only respected if xpc::IsInAutomation is true.
// This is not the case by default in xpcshell tests, unless the following
// pref is also set. Fixing this generically is bug 1598804
Services.prefs.setBoolPref(
"security.turn_off_all_security_so_that_viruses_can_take_over_this_computer",
true
);
Services.prefs.setBoolPref("plugin.load_flash_only", false);
await promiseStartupManager();
gPluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
gNotifier = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
registerCleanupFunction(function() {
Services.prefs.clearUserPref("extensions.blocklist.url");
Services.prefs.clearUserPref("extensions.blocklist.enabled");
});
});
add_task(async function basic() {
await updateBlocklist();
var { blocklist } = Services;
Assert.equal(
await blocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9"),
nsIBLS.STATE_OUTDATED
);
Assert.equal(
await blocklist.getPluginBlocklistState(PLUGINS[1], "1", "1.9"),
nsIBLS.STATE_VULNERABLE_UPDATE_AVAILABLE
);
Assert.equal(
await blocklist.getPluginBlocklistState(PLUGINS[2], "1", "1.9"),
nsIBLS.STATE_VULNERABLE_NO_UPDATE
);
Assert.equal(
await blocklist.getPluginBlocklistState(PLUGINS[3], "1", "1.9"),
nsIBLS.STATE_BLOCKED
);
Assert.equal(
await blocklist.getPluginBlocklistState(PLUGINS[4], "1", "1.9"),
nsIBLS.STATE_SOFTBLOCKED
);
Assert.equal(
await blocklist.getPluginBlocklistState(PLUGINS[5], "1", "1.9"),
nsIBLS.STATE_NOT_BLOCKED
);
});
function get_test_plugin() {
for (var plugin of gPluginHost.getPluginTags()) {
if (plugin.name == "Test Plug-in") {
return plugin;
}
}
Assert.ok(false);
return null;
}
// At this time, the blocklist does not have an entry for the test plugin,
// so it shouldn't be click-to-play.
add_task(async function test_is_not_clicktoplay() {
var plugin = get_test_plugin();
var blocklistState = await Blocklist.getPluginBlocklistState(
plugin,
"1",
"1.9"
);
Assert.notEqual(
blocklistState,
Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE
);
Assert.notEqual(
blocklistState,
Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE
);
});
// Here, we've updated the blocklist to have a block for the test plugin,
// so it should be click-to-play.
add_task(async function test_is_clicktoplay() {
await updateBlocklist(
"http://example.com/data/test_pluginBlocklistCtpUndo.xml"
);
var plugin = get_test_plugin();
var blocklistState = await Blocklist.getPluginBlocklistState(
plugin,
"1",
"1.9"
);
Assert.equal(
blocklistState,
Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE
);
});
// But now we've removed that entry from the blocklist (really we've gone back
// to the old one), so the plugin shouldn't be click-to-play any more.
add_task(async function test_is_not_clicktoplay2() {
await updateBlocklist("http://example.com/data/test_pluginBlocklistCtp.xml");
var plugin = get_test_plugin();
var blocklistState = await Blocklist.getPluginBlocklistState(
plugin,
"1",
"1.9"
);
Assert.notEqual(
blocklistState,
Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE
);
Assert.notEqual(
blocklistState,
Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE
);
});
// Test that disabling the blocklist when a plugin is ctp-blocklisted will
// result in the plugin not being click-to-play.
add_task(async function test_disable_blocklist() {
await updateBlocklist(
"http://example.com/data/test_pluginBlocklistCtpUndo.xml"
);
var plugin = get_test_plugin();
var blocklistState = await Blocklist.getPluginBlocklistState(
plugin,
"1",
"1.9"
);
Assert.equal(
blocklistState,
Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE
);
Services.prefs.setBoolPref("extensions.blocklist.enabled", false);
blocklistState = await Blocklist.getPluginBlocklistState(plugin, "1", "1.9");
Assert.notEqual(
blocklistState,
Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE
);
Assert.notEqual(
blocklistState,
Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE
);
// it should still be possible to make a plugin click-to-play
// by setting that plugin's enabled state to click-to-play
let previousEnabledState = plugin.enabledState;
plugin.enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY;
Assert.equal(
gPluginHost.getStateForType("application/x-test"),
Ci.nsIPluginTag.STATE_CLICKTOPLAY
);
// clean up plugin state
plugin.enabledState = previousEnabledState;
});

View File

@ -1,99 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/**
* MockPlugin mimics the behaviour of a plugin.
*/
function MockPlugin(name, version, enabledState) {
this.name = name;
this.version = version;
this.enabledState = enabledState;
}
MockPlugin.prototype = {
get disabled() {
return this.enabledState == Ci.nsIPluginTag.STATE_DISABLED;
},
};
// The mocked blocked plugin used to test the blocklist.
const PLUGINS = [
new MockPlugin("test_with_infoURL", "5", Ci.nsIPluginTag.STATE_ENABLED),
new MockPlugin("test_with_altInfoURL", "5", Ci.nsIPluginTag.STATE_ENABLED),
new MockPlugin("test_no_infoURL", "5", Ci.nsIPluginTag.STATE_ENABLED),
new MockPlugin("test_newVersion", "1", Ci.nsIPluginTag.STATE_ENABLED),
new MockPlugin("test_newVersion", "3", Ci.nsIPluginTag.STATE_ENABLED),
];
/**
* The entry point of the unit tests, which is also responsible of
* copying the blocklist file to the profile folder.
*/
add_task(async function setup() {
copyBlocklistToProfile(do_get_file("../data/pluginInfoURL_block.xml"));
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
await promiseStartupManager();
});
/**
* Test that the blocklist service correctly loads and returns the infoURL for
* a plugin that matches the first entry in the blocklist.
*/
add_task(async function test_infoURL() {
// The testInfoURL must match the value within the
// <infoURL> tag in pluginInfoURL_block.xml.
let testInfoURL = "http://test.url.com/";
Assert.strictEqual(
await Blocklist.getPluginBlockURL(PLUGINS[0]),
testInfoURL,
"Should be the provided url when an infoURL tag is available"
);
});
/**
* Test that the blocklist service correctly loads and returns the infoURL for
* a plugin that partially matches an earlier entry in the blocklist.
*/
add_task(async function test_altInfoURL() {
let altTestInfoURL = "http://alt.test.url.com/";
Assert.strictEqual(
await Blocklist.getPluginBlockURL(PLUGINS[1]),
altTestInfoURL,
"Should be the alternative infoURL"
);
});
/**
* Test that the blocklist service correctly returns the fallback value
* if the infoURL tag is missing in the blocklist.xml file.
*/
add_task(async function test_infoURL_missing() {
let fallback_URL =
Services.prefs.getStringPref("extensions.blocklist.detailsURL") +
"test_plugin_noInfoURL.html";
Assert.strictEqual(
await Blocklist.getPluginBlockURL(PLUGINS[2]),
fallback_URL,
"Should be using fallback when no infoURL tag is available."
);
});
add_task(async function test_intoURL_newVersion() {
let testInfoURL = "http://test.url2.com/";
Assert.strictEqual(
await Blocklist.getPluginBlockURL(PLUGINS[3]),
testInfoURL,
"Old plugin should match"
);
Assert.strictEqual(
await Blocklist.getPluginBlockURL(PLUGINS[4]),
null,
"New plugin should not match"
);
});

View File

@ -1,70 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
const testserver = createHttpServer();
gPort = testserver.identity.primaryPort;
testserver.registerDirectory("/data/", do_get_file("../data"));
function load_blocklist(aFile) {
return new Promise((resolve, reject) => {
Services.obs.addObserver(function observer() {
Services.obs.removeObserver(observer, "addon-blocklist-updated");
resolve();
}, "addon-blocklist-updated");
Services.prefs.setCharPref(
"extensions.blocklist.url",
`http://localhost:${gPort}/data/${aFile}`
);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(
Ci.nsITimerCallback
);
blocklist.notify(null);
});
}
// Tests that an appDisabled add-on that becomes softBlocked remains disabled
// when becoming appEnabled
add_task(async function test_softblock() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
await promiseStartupManager();
await promiseInstallWebExtension({
manifest: {
name: "Softblocked add-on",
version: "1.0",
applications: {
gecko: {
id: "softblock1@tests.mozilla.org",
strict_min_version: "2",
strict_max_version: "3",
},
},
},
});
let s1 = await promiseAddonByID("softblock1@tests.mozilla.org");
// Make sure to mark it as previously enabled.
await s1.enable();
Assert.ok(!s1.softDisabled);
Assert.ok(s1.appDisabled);
Assert.ok(!s1.isActive);
await load_blocklist("test_softblocked1.xml");
Assert.ok(s1.softDisabled);
Assert.ok(s1.appDisabled);
Assert.ok(!s1.isActive);
AddonTestUtils.appInfo.platformVersion = "2";
await promiseRestartManager("2");
s1 = await promiseAddonByID("softblock1@tests.mozilla.org");
Assert.ok(s1.softDisabled);
Assert.ok(!s1.appDisabled);
Assert.ok(!s1.isActive);
});

View File

@ -1,47 +0,0 @@
[DEFAULT]
# AddonTestUtils undefined on Android
skip-if = toolkit == 'android'
tags = addons blocklist
head = head.js ../head_addons.js
firefox-appdir = browser
support-files =
../data/**
[test_blocklist_appversion.js]
[test_blocklist_gfx.js]
[test_blocklist_metadata_filters.js]
[test_blocklist_osabi.js]
[test_blocklist_plugin_flashonly.js]
[test_blocklist_plugin_outdated.js]
[test_blocklist_plugin_severities.js]
[test_blocklist_prefs.js]
[test_blocklist_severities.js]
[test_blocklist_telemetry.js]
[test_blocklist_url_parameters.js]
[test_blocklist_url_ping_count.js]
[test_blocklistchange.js]
# Times out during parallel runs on desktop
requesttimeoutfactor = 2
[test_gfxBlacklist_Device.js]
[test_gfxBlacklist_DriverNew.js]
[test_gfxBlacklist_Equal_DriverNew.js]
[test_gfxBlacklist_Equal_DriverOld.js]
[test_gfxBlacklist_Equal_OK.js]
[test_gfxBlacklist_GTE_DriverOld.js]
[test_gfxBlacklist_GTE_OK.js]
[test_gfxBlacklist_No_Comparison.js]
[test_gfxBlacklist_OK.js]
[test_gfxBlacklist_OS.js]
[test_gfxBlacklist_OSVersion_match.js]
[test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js]
[test_gfxBlacklist_OSVersion_mismatch_OSVersion.js]
[test_gfxBlacklist_Vendor.js]
[test_gfxBlacklist_Version.js]
[test_gfxBlacklist_prefs.js]
# Bug 1248787 - consistently fails
skip-if = true
[test_overrideblocklist.js]
run-sequentially = Uses global XCurProcD dir.
[test_pluginBlocklistCtp.js]
[test_pluginInfoURL.js]
[test_softblocked.js]

View File

@ -7,7 +7,6 @@ license:
# These paths need to be triaged.
- build/pgo/js-input
- build/workspace-hack/src/lib.rs
- browser/app/blocklist.xml
- tools/crashreporter/system-symbols/mac/parse_pbzx.py
# License not super clear
- browser/branding/