mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 789620 - a plugin that gets unblocklisted should go back to normal. r=bmcbride
This commit is contained in:
parent
9827420b37
commit
cbc3fb0b92
@ -971,6 +971,10 @@ Blocklist.prototype = {
|
||||
if (state == Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE ||
|
||||
state == Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE)
|
||||
plugin.clicktoplay = true;
|
||||
// turn off clicktoplay if it was previously set by the blocklist
|
||||
else if (oldState == Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE ||
|
||||
oldState == Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE)
|
||||
plugin.clicktoplay = false;
|
||||
}
|
||||
|
||||
if (addonList.length == 0) {
|
||||
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">
|
||||
<pluginItems>
|
||||
<pluginItem>
|
||||
<match name="name" exp="^Test Plug-in"/>
|
||||
<versionRange minVersion="0" maxVersion="*" severity="0" vulnerabilitystatus="2"/>
|
||||
</pluginItem>
|
||||
</pluginItems>
|
||||
</blocklist>
|
@ -3,6 +3,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const nsIBLS = Components.interfaces.nsIBlocklistService;
|
||||
Components.utils.import("resource://testing-common/httpd.js");
|
||||
|
||||
var PLUGINS = [{
|
||||
// severity=0, vulnerabilitystatus=0 -> outdated
|
||||
@ -47,25 +48,17 @@ var PLUGINS = [{
|
||||
blocklisted: false
|
||||
}];
|
||||
|
||||
var gNotifier = null;
|
||||
var gNextTest = null;
|
||||
var gServer = null;
|
||||
|
||||
function run_test() {
|
||||
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
|
||||
var blocklistFile = gProfD.clone();
|
||||
blocklistFile.append("blocklist.xml");
|
||||
if (blocklistFile.exists())
|
||||
blocklistFile.remove(false);
|
||||
var source = do_get_file("data/test_pluginBlocklistCtp.xml");
|
||||
source.copyTo(gProfD, "blocklist.xml");
|
||||
|
||||
var blocklist = Components.classes["@mozilla.org/extensions/blocklist;1"]
|
||||
.getService(nsIBLS);
|
||||
function test_basic() {
|
||||
var blocklist = Components.classes["@mozilla.org/extensions/blocklist;1"].getService(nsIBLS);
|
||||
|
||||
do_check_true(blocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9") == nsIBLS.STATE_OUTDATED);
|
||||
|
||||
do_check_true(blocklist.getPluginBlocklistState(PLUGINS[1], "1", "1.9") == nsIBLS.STATE_VULNERABLE_UPDATE_AVAILABLE);
|
||||
|
||||
|
||||
do_check_true(blocklist.getPluginBlocklistState(PLUGINS[2], "1", "1.9") == nsIBLS.STATE_VULNERABLE_NO_UPDATE);
|
||||
|
||||
do_check_true(blocklist.getPluginBlocklistState(PLUGINS[3], "1", "1.9") == nsIBLS.STATE_BLOCKED);
|
||||
@ -73,4 +66,89 @@ function run_test() {
|
||||
do_check_true(blocklist.getPluginBlocklistState(PLUGINS[4], "1", "1.9") == nsIBLS.STATE_SOFTBLOCKED);
|
||||
|
||||
do_check_true(blocklist.getPluginBlocklistState(PLUGINS[5], "1", "1.9") == nsIBLS.STATE_NOT_BLOCKED);
|
||||
|
||||
gNextTest = test_is_not_clicktoplay;
|
||||
do_execute_soon(gNextTest);
|
||||
}
|
||||
|
||||
function get_test_plugin() {
|
||||
var pluginHost = Components.classes["@mozilla.org/plugin/host;1"].getService(Components.interfaces.nsIPluginHost);
|
||||
for (var plugin of pluginHost.getPluginTags()) {
|
||||
if (plugin.name == "Test Plug-in")
|
||||
return plugin;
|
||||
}
|
||||
do_check_true(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.
|
||||
function test_is_not_clicktoplay() {
|
||||
var plugin = get_test_plugin();
|
||||
do_check_false(plugin.clicktoplay);
|
||||
|
||||
Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/test_pluginBlocklistCtpUndo.xml");
|
||||
gNextTest = test_is_clicktoplay;
|
||||
gNotifier.notify(null);
|
||||
}
|
||||
|
||||
// Here, we've updated the blocklist to have a block for the test plugin,
|
||||
// so it should be click-to-play.
|
||||
function test_is_clicktoplay() {
|
||||
var plugin = get_test_plugin();
|
||||
do_check_true(plugin.clicktoplay);
|
||||
|
||||
Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/test_pluginBlocklistCtp.xml");
|
||||
gNextTest = test_is_not_clicktoplay2;
|
||||
gNotifier.notify(null);
|
||||
}
|
||||
|
||||
// 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.
|
||||
function test_is_not_clicktoplay2() {
|
||||
var plugin = get_test_plugin();
|
||||
do_check_false(plugin.clicktoplay);
|
||||
|
||||
plugin.clicktoplay = true;
|
||||
gNextTest = test_is_clicktoplay2;
|
||||
gNotifier.notify(null);
|
||||
}
|
||||
|
||||
// Now test that if the user makes a plugin click-to-play, not having it on
|
||||
// the blocklist doesn't undo that setting.
|
||||
function test_is_clicktoplay2() {
|
||||
var plugin = get_test_plugin();
|
||||
do_check_true(plugin.clicktoplay);
|
||||
|
||||
gServer.stop(do_test_finished);
|
||||
}
|
||||
|
||||
// Observe "blocklist-updated" so we know when to advance to the next test
|
||||
function observer() {
|
||||
do_execute_soon(gNextTest);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
|
||||
|
||||
gServer = new HttpServer();
|
||||
gServer.registerDirectory("/data/", do_get_file("data"));
|
||||
gServer.start(4444);
|
||||
|
||||
Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/test_pluginBlocklistCtp.xml");
|
||||
startupManager();
|
||||
|
||||
gNotifier = Components.classes["@mozilla.org/extensions/blocklist;1"].getService(Components.interfaces.nsITimerCallback);
|
||||
Services.obs.addObserver(observer, "blocklist-updated", false);
|
||||
|
||||
do_register_cleanup(function() {
|
||||
Services.prefs.clearUserPref("extensions.blocklist.url");
|
||||
Services.obs.removeObserver(observer, "blocklist-updated");
|
||||
var plugin = get_test_plugin();
|
||||
plugin.clicktoplay = false;
|
||||
});
|
||||
|
||||
gNextTest = test_basic;
|
||||
do_test_pending();
|
||||
gNotifier.notify(null);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user