fune/browser/base/content/test/plugins/browser_plugin_reloading.js
Gijs Kruitbosch f1a04bd343 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
2020-03-09 12:02:17 +00:00

113 lines
3.2 KiB
JavaScript

var gTestRoot = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content/",
"http://127.0.0.1:8888/"
);
var gPluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
var gTestBrowser = null;
function updateAllTestPlugins(aState) {
setTestPluginEnabledState(aState, "Test Plug-in");
setTestPluginEnabledState(aState, "Second Test Plug-in");
}
add_task(async function() {
registerCleanupFunction(async function() {
clearAllPluginPermissions();
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(
Ci.nsIPluginTag.STATE_ENABLED,
"Second Test Plug-in"
);
await asyncSetAndUpdateBlocklist(
gTestRoot + "blockNoPlugins",
gTestBrowser
);
gTestBrowser = null;
gBrowser.removeCurrentTab();
window.focus();
});
});
add_task(async function() {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gTestBrowser = gBrowser.selectedBrowser;
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
// 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", gTestBrowser);
});
// Tests that a click-to-play plugin retains its activated state upon reloading
add_task(async function() {
clearAllPluginPermissions();
updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
await promiseTabLoadEvent(
gBrowser.selectedTab,
gTestRoot + "plugin_test.html"
);
// Work around for delayed PluginBindingAttached
await promiseUpdatePluginBindings(gTestBrowser);
let notification = PopupNotifications.getNotification(
"click-to-play-plugins",
gTestBrowser
);
ok(notification, "Test 1, Should have a click-to-play notification");
let pluginInfo = await promiseForPluginInfo("test");
is(
pluginInfo.pluginFallbackType,
Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY,
"Test 2, plugin fallback type should be PLUGIN_CLICK_TO_PLAY"
);
// run the plugin
await promisePlayObject("test");
await promiseUpdatePluginBindings(gTestBrowser);
pluginInfo = await promiseForPluginInfo("test");
is(
pluginInfo.displayedType,
Ci.nsIObjectLoadingContent.TYPE_PLUGIN,
"Test 3, plugin should have started"
);
ok(pluginInfo.activated, "Test 4, plugin node should not be activated");
await SpecialPowers.spawn(gTestBrowser, [], async function() {
let plugin = content.document.getElementById("test");
let npobj1 = Cu.waiveXrays(plugin).getObjectValue();
// eslint-disable-next-line no-self-assign
plugin.src = plugin.src;
let pluginsDiffer = false;
try {
Cu.waiveXrays(plugin).checkObjectValue(npobj1);
} catch (e) {
pluginsDiffer = true;
}
Assert.ok(pluginsDiffer, "Test 5, plugins differ.");
});
pluginInfo = await promiseForPluginInfo("test");
ok(
pluginInfo.activated,
"Test 6, Plugin should have retained activated state."
);
is(
pluginInfo.displayedType,
Ci.nsIObjectLoadingContent.TYPE_PLUGIN,
"Test 7, plugin should have started"
);
});