Bug 1549548 - update browser tests for plugin blocking, r=mconley

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

--HG--
rename : browser/base/content/test/plugins/browser.ini => browser/base/content/test/plugins/browser-rs-blocklist.ini
extra : moz-landing-system : lando
This commit is contained in:
Gijs Kruitbosch 2019-05-22 14:48:04 +00:00
Родитель 278b63fd0a
Коммит b49196046b
22 изменённых файлов: 283 добавлений и 92 удалений

Просмотреть файл

@ -0,0 +1 @@
[]

Просмотреть файл

@ -0,0 +1,11 @@
[
{
"matchFilename": "libnptest\\.so|nptest\\.dll|Test\\.plugin",
"versionRange": [
{
"severity": "2"
}
],
"blockID": "p9999"
}
]

Просмотреть файл

@ -0,0 +1,12 @@
[
{
"matchFilename": "libnptest\\.so|nptest\\.dll|Test\\.plugin",
"versionRange": [
{
"severity": "2"
}
],
"blockID": "p9999",
"infoURL": "http://test.url.com/"
}
]

Просмотреть файл

@ -0,0 +1,12 @@
[
{
"matchFilename": "libnptest\\.so|nptest\\.dll|Test\\.plugin",
"versionRange": [
{
"severity": "0",
"vulnerabilityStatus": "2"
}
],
"blockID": "p9999"
}
]

Просмотреть файл

@ -0,0 +1,12 @@
[
{
"matchFilename": "libnptest\\.so|nptest\\.dll|Test\\.plugin",
"versionRange": [
{
"severity": "0",
"vulnerabilityStatus": "1"
}
],
"blockID": "p9999"
}
]

Просмотреть файл

@ -0,0 +1,59 @@
# 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
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_bug820497.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 = toolkit == "gtk3" # 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

Просмотреть файл

@ -1,4 +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
support-files =
blocklist_proxy.js
blockNoPlugins.xml
@ -20,8 +29,6 @@ support-files =
plugin_bug787619.html
plugin_bug797677.html
plugin_bug820497.html
plugin_clickToPlayAllow.html
plugin_clickToPlayDeny.html
plugin_favorfallback.html
plugin_hidden_to_visible.html
plugin_iframe.html
@ -34,7 +41,6 @@ support-files =
plugin_syncRemoved.html
plugin_test.html
plugin_test2.html
plugin_test3.html
plugin_two_types.html
plugin_unknown.html
plugin_crashCommentAndURL.html

Просмотреть файл

@ -13,7 +13,7 @@ add_task(async function() {
updateAllTestPlugins(Ci.nsIPluginTag.STATE_ENABLED);
Services.prefs.clearUserPref("plugins.click_to_play");
Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins", gTestBrowser);
resetBlocklist();
gBrowser.removeCurrentTab();
window.focus();
@ -38,7 +38,7 @@ add_task(async function() {
add_task(async function() {
// enable hard blocklisting of test
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginVulnerableUpdatable.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginVulnerableUpdatable", gTestBrowser);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
@ -104,7 +104,7 @@ add_task(async function() {
add_task(async function() {
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginVulnerableNoUpdate.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginVulnerableNoUpdate", gTestBrowser);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
@ -203,7 +203,7 @@ add_task(async function() {
// Test that "always allow"-ing a plugin will not allow it when it becomes
// blocklisted.
add_task(async function() {
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins", gTestBrowser);
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
@ -229,7 +229,7 @@ add_task(async function() {
pluginInfo = await promiseForPluginInfo("test");
ok(pluginInfo.activated, "Test 24a, Plugin should be active.");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginVulnerableUpdatable.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginVulnerableUpdatable", gTestBrowser);
});
// the plugin is now blocklisted, so it should not automatically load
@ -257,7 +257,7 @@ add_task(async function() {
clearAllPluginPermissions();
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins", gTestBrowser);
});
// Plugin sync removal test. Note this test produces a notification drop down since
@ -283,7 +283,7 @@ add_task(async function() {
add_task(async function() {
clearAllPluginPermissions();
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginInfoURL.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginInfoURL", gTestBrowser);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");

Просмотреть файл

@ -9,7 +9,7 @@ add_task(async function() {
Services.prefs.clearUserPref("plugins.click_to_play");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins", gTestBrowser);
resetBlocklist();
gBrowser.removeCurrentTab();
window.focus();
@ -34,7 +34,7 @@ add_task(async function() {
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins", gTestBrowser);
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
@ -48,7 +48,7 @@ add_task(async function() {
// Load a fresh page, load a new plugin blocklist, then load the same page again.
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html>GO!</html>");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginHard.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginHard", gTestBrowser);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
@ -65,7 +65,7 @@ add_task(async function() {
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html>GO!</html>");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins", gTestBrowser);
// Hack the planet! Load our blocklist shim, so we can mess with blocklist
// return results in the content process. Active until we close our tab.
@ -87,7 +87,7 @@ add_task(async function() {
// Load a fresh page, load a new plugin blocklist, then load the same page again.
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html>GO!</html>");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginHard.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginHard", gTestBrowser);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
@ -98,5 +98,5 @@ add_task(async function() {
Assert.ok(!test.activated, "task 4a: test plugin shouldn't activate!");
});
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins", gTestBrowser);
});

Просмотреть файл

@ -7,7 +7,7 @@ add_task(async function() {
Services.prefs.clearUserPref("plugins.click_to_play");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins", gTestBrowser);
resetBlocklist();
gBrowser.removeCurrentTab();
window.focus();
@ -29,7 +29,7 @@ add_task(async function() {
// Prime the blocklist service, the remote service doesn't launch on startup.
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html></html>");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins", gTestBrowser);
});
// Tests that navigation within the page and the window.history API doesn't break click-to-play state.

Просмотреть файл

@ -6,7 +6,7 @@ add_task(async function() {
clearAllPluginPermissions();
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins", gTestBrowser);
resetBlocklist();
Services.prefs.clearUserPref("plugins.click_to_play");
gBrowser.removeCurrentTab();
@ -26,7 +26,7 @@ add_task(async function() {
// Tests that the going back will reshow the notification for click-to-play
// blocklisted plugins
add_task(async function() {
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginVulnerableUpdatable.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginVulnerableUpdatable", gTestBrowser);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");

Просмотреть файл

@ -13,7 +13,7 @@ add_task(async function() {
Services.prefs.clearUserPref("plugins.click_to_play");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins", gTestBrowser);
resetBlocklist();
gTestBrowser = null;
gBrowser.removeCurrentTab();
@ -33,7 +33,7 @@ add_task(async function() {
// Prime the blocklist service, the remote service doesn't launch on startup.
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html></html>");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins", gTestBrowser);
});
// Tests that a click-to-play plugin retains its activated state upon reloading

Просмотреть файл

@ -13,7 +13,7 @@ add_task(async function() {
Services.prefs.clearUserPref("plugins.click_to_play");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins", gTestBrowser);
resetBlocklist();
gTestBrowser = null;
gBrowser.removeCurrentTab();
@ -33,7 +33,7 @@ add_task(async function() {
// Prime the blocklist service, the remote service doesn't launch on startup.
await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html></html>");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins", gTestBrowser);
});
// Tests a page with an unknown plugin in it.
@ -216,7 +216,7 @@ add_task(async function() {
add_task(async function() {
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins", gTestBrowser);
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
@ -441,7 +441,7 @@ add_task(async function() {
// Plugin sync removal test. Note this test produces a notification drop down since
// the plugin we add has zero dims.
add_task(async function() {
add_task(async function blockPluginSyncRemoved() {
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_syncRemoved.html");
@ -459,21 +459,24 @@ add_task(async function() {
// Tests a page with a blocked plugin in it and make sure the infoURL property
// the blocklist file gets used.
add_task(async function() {
add_task(async function blockPluginInfoURL() {
clearAllPluginPermissions();
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginInfoURL.xml", gTestBrowser);
await asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginInfoURL", gTestBrowser);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
info("Waiting for plugin bindings");
await promiseUpdatePluginBindings(gTestBrowser);
let notification = PopupNotifications.getNotification("click-to-play-plugins");
info("Waiting for notification to be shown");
// Since the plugin notification is dismissed by default, reshow it.
await promiseForNotificationShown(notification);
info("Waiting for plugin info");
let pluginInfo = await promiseForPluginInfo("test");
is(pluginInfo.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_BLOCKLISTED,
"Test 26, plugin fallback type should be PLUGIN_BLOCKLISTED");

Просмотреть файл

@ -5,6 +5,10 @@ ChromeUtils.defineModuleGetter(this, "PlacesUtils",
ChromeUtils.defineModuleGetter(this, "PromiseUtils",
"resource://gre/modules/PromiseUtils.jsm");
XPCOMUtils.defineLazyServiceGetters(this, {
uuidGen: ["@mozilla.org/uuid-generator;1", "nsIUUIDGenerator"],
});
// Various tests in this directory may define gTestBrowser, to use as the
// default browser under test in some of the functions below.
/* global gTestBrowser */
@ -192,22 +196,112 @@ function clearAllPluginPermissions() {
}
}
// Ported from AddonTestUtils.jsm
let JSONBlocklistWrapper = {
/**
* Load the data from the specified files into the *real* blocklist providers.
* Loads using loadBlocklistRawData, which will treat this as an update.
*
* @param {nsIFile} dir
* The directory in which the files live.
* @param {string} prefix
* a prefix for the files which ought to be loaded.
* This method will suffix -extensions.json and -plugins.json
* to the prefix it is given, and attempt to load both.
* Insofar as either exists, their data will be dumped into
* the respective store, and the respective update handlers
* will be called.
*/
async loadBlocklistData(url) {
const fullURL = `${url}-plugins.json`;
let jsonObj;
try {
jsonObj = await (await fetch(fullURL)).json();
} catch (ex) {
ok(false, ex);
}
info(`Loaded ${fullURL}`);
return this.loadBlocklistRawData({plugins: jsonObj});
},
/**
* Load the following data into the *real* blocklist providers.
* While `overrideBlocklist` replaces the blocklist entirely with a mock
* that returns dummy data, this method instead loads data into the actual
* blocklist, fires update methods as would happen if this data came from
* an actual blocklist update, etc.
*
* @param {object} data
* An object that can optionally have `extensions` and/or `plugins`
* properties, each being an array of blocklist items.
* This code only uses plugin blocks, that can look something like:
*
* {
* "matchFilename": "libnptest\\.so|nptest\\.dll|Test\\.plugin",
* "versionRange": [
* {
* "severity": "0",
* "vulnerabilityStatus": "1"
* }
* ],
* "blockID": "p9999"
* }
*
*/
async loadBlocklistRawData(data) {
const bsPass = ChromeUtils.import("resource://gre/modules/Blocklist.jsm", null);
const blocklistMapping = {
"extensions": bsPass.ExtensionBlocklistRS,
"plugins": bsPass.PluginBlocklistRS,
};
for (const [dataProp, blocklistObj] of Object.entries(blocklistMapping)) {
let newData = data[dataProp];
if (!newData) {
continue;
}
if (!Array.isArray(newData)) {
throw new Error("Expected an array of new items to put in the " + dataProp + " blocklist!");
}
for (let item of newData) {
if (!item.id) {
item.id = uuidGen.generateUUID().number.slice(1, -1);
}
if (!item.last_modified) {
item.last_modified = Date.now();
}
}
await blocklistObj._ensureInitialized();
let collection = await blocklistObj._client.openCollection();
await collection.clear();
await collection.loadDump(newData);
// We manually call _onUpdate... which is evil, but at the moment kinto doesn't have
// a better abstraction unless you want to mock your own http server to do the update.
await blocklistObj._onUpdate();
}
},
};
// An async helper that insures a new blocklist is loaded (in both
// processes if applicable).
var _originalTestBlocklistURL = null;
async function asyncSetAndUpdateBlocklist(aURL, aBrowser) {
// FIXME: this needs to also work with the remote settings blocklist,
// https://bugzilla.mozilla.org/show_bug.cgi?id=1549548
info("*** loading new blocklist: " + aURL);
let doTestRemote = aBrowser ? aBrowser.isRemoteBrowser : false;
if (!_originalTestBlocklistURL) {
_originalTestBlocklistURL = Services.prefs.getCharPref("extensions.blocklist.url");
}
Services.prefs.setCharPref("extensions.blocklist.url", aURL);
let localPromise = TestUtils.topicObserved("plugin-blocklist-updated");
let blocklistNotifier = Cc["@mozilla.org/extensions/blocklist;1"]
.getService(Ci.nsITimerCallback);
blocklistNotifier.notify(null);
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("*** waiting on local load");
await localPromise;
if (doTestRemote) {

Просмотреть файл

@ -1,9 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="test" style="width: 200px; height: 200px" type="application/x-test">
</body>
</html>

Просмотреть файл

@ -1,9 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="test" style="width: 200px; height: 200px" type="application/x-test">
</body>
</html>

Просмотреть файл

@ -1,9 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="test" style="width: 0px; height: 0px" type="application/x-test">
</body>
</html>

Просмотреть файл

@ -38,6 +38,7 @@ BROWSER_CHROME_MANIFESTS += [
'content/test/performance/legacyurlbar/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',

Просмотреть файл

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

Просмотреть файл

@ -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>

Просмотреть файл

@ -1,8 +1,6 @@
[DEFAULT]
skip-if = os == 'android'
support-files =
blockNoPlugins.xml
blockPluginHard.xml
bug418986-1.js
cpows_child.js
cpows_parent.xul

Просмотреть файл

@ -1,25 +1,40 @@
const gHttpTestRoot = "http://127.0.0.1:8888/" + RELATIVE_DIR + "/";
const {AddonTestUtils} = ChromeUtils.import("resource://testing-common/AddonTestUtils.jsm");
function updateBlocklist(aCallback) {
var blocklistNotifier = Cc["@mozilla.org/extensions/blocklist;1"]
.getService(Ci.nsITimerCallback);
function updateBlocklist(aURL, aCallback) {
var observer = function() {
Services.obs.removeObserver(observer, "plugin-blocklist-updated");
SimpleTest.executeSoon(aCallback);
};
Services.obs.addObserver(observer, "plugin-blocklist-updated");
blocklistNotifier.notify(null);
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);
} 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.");
}
}
}
var _originalBlocklistURL = null;
function setAndUpdateBlocklist(aURL, aCallback) {
// FIXME needs to change blocklist differently.
// Tracked in https://bugzilla.mozilla.org/show_bug.cgi?id=1549548 .
if (!_originalBlocklistURL) {
_originalBlocklistURL = Services.prefs.getCharPref("extensions.blocklist.url");
}
Services.prefs.setCharPref("extensions.blocklist.url", aURL);
updateBlocklist(aCallback);
updateBlocklist(aURL, aCallback);
}
function resetBlocklist(aCallback) {
@ -39,6 +54,7 @@ add_task(async function() {
SpecialPowers.pushPrefEnv({"set": [
["plugins.click_to_play", true],
["extensions.blocklist.suppressUI", true],
["extensions.blocklist.useXML", true],
]});
registerCleanupFunction(async function() {
let pluginTag = getTestPluginTag();
@ -48,9 +64,18 @@ add_task(async function() {
});
resetBlocklist();
});
let pluginTag = getTestPluginTag();
pluginTag.enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY;
await checkPlugins();
pluginTag.enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY;
SpecialPowers.pushPrefEnv({set: [
["extensions.blocklist.useXML", false],
]});
await checkPlugins();
});
async function checkPlugins() {
let managerWindow = await open_manager("addons://list/plugin");
let plugins = await AddonManager.getAddonsByTypes(["plugin"]);
@ -177,4 +202,6 @@ add_task(async function() {
is(menu.disabled, true, "part13: detail state menu should be disabled");
managerWindow.close();
});
await new Promise(resolve =>
setAndUpdateBlocklist(gHttpTestRoot + "blockNoPlugins.xml", resolve));
}