fune/browser/base/content/test/plugins/browser_bug743421.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

135 lines
4.3 KiB
JavaScript

var gTestRoot = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content/",
"http://127.0.0.1:8888/"
);
var gTestBrowser = null;
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
);
gBrowser.removeCurrentTab();
window.focus();
gTestBrowser = null;
});
});
add_task(async function() {
let newTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.selectedTab = newTab;
gTestBrowser = gBrowser.selectedBrowser;
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
setTestPluginEnabledState(
Ci.nsIPluginTag.STATE_CLICKTOPLAY,
"Second Test Plug-in"
);
// 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 navigation within the page and the window.history API doesn't break click-to-play state.
add_task(async function() {
await promiseTabLoadEvent(
gBrowser.selectedTab,
gTestRoot + "plugin_add_dynamically.html"
);
let notification = PopupNotifications.getNotification(
"click-to-play-plugins",
gTestBrowser
);
ok(!notification, "Test 1a, Should not have a click-to-play notification");
await SpecialPowers.spawn(gTestBrowser, [], async function() {
new XPCNativeWrapper(XPCNativeWrapper.unwrap(content).addPlugin());
});
await promisePopupNotification("click-to-play-plugins");
});
add_task(async function() {
await SpecialPowers.spawn(gTestBrowser, [], async function() {
let plugin = content.document.getElementsByTagName("embed")[0];
Assert.ok(!plugin.activated, "Test 1b, Plugin should not be activated");
});
// Click the activate button on doorhanger to make sure it works
let notification = PopupNotifications.getNotification(
"click-to-play-plugins",
gTestBrowser
);
await promiseForNotificationShown(notification);
PopupNotifications.panel.firstElementChild.button.click();
await SpecialPowers.spawn(gTestBrowser, [], async function() {
let plugin = content.document.getElementsByTagName("embed")[0];
Assert.ok(plugin.activated, "Test 1b, Plugin should be activated");
});
});
add_task(async function() {
let notification = PopupNotifications.getNotification(
"click-to-play-plugins",
gTestBrowser
);
ok(notification, "Test 1c, Should still have a click-to-play notification");
await SpecialPowers.spawn(gTestBrowser, [], async function() {
new XPCNativeWrapper(XPCNativeWrapper.unwrap(content).addPlugin());
let plugin = content.document.getElementsByTagName("embed")[1];
Assert.ok(
plugin.activated,
"Test 1c, Newly inserted plugin in activated page should be activated"
);
});
});
add_task(async function() {
await SpecialPowers.spawn(gTestBrowser, [], async function() {
let plugin = content.document.getElementsByTagName("embed")[1];
Assert.ok(plugin.activated, "Test 1d, Plugin should be activated");
let promise = ContentTaskUtils.waitForEvent(content, "hashchange");
content.location += "#anchorNavigation";
await promise;
});
});
add_task(async function() {
await SpecialPowers.spawn(gTestBrowser, [], async function() {
new XPCNativeWrapper(XPCNativeWrapper.unwrap(content).addPlugin());
let plugin = content.document.getElementsByTagName("embed")[2];
Assert.ok(plugin.activated, "Test 1e, Plugin should be activated");
});
});
add_task(async function() {
await SpecialPowers.spawn(gTestBrowser, [], async function() {
let plugin = content.document.getElementsByTagName("embed")[2];
Assert.ok(plugin.activated, "Test 1f, Plugin should be activated");
content.history.replaceState({}, "", "replacedState");
new XPCNativeWrapper(XPCNativeWrapper.unwrap(content).addPlugin());
plugin = content.document.getElementsByTagName("embed")[3];
Assert.ok(plugin.activated, "Test 1g, Plugin should be activated");
});
});