diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /browser/base/content/test/plugins/browser_blocklist_content.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/base/content/test/plugins/browser_blocklist_content.js')
-rw-r--r-- | browser/base/content/test/plugins/browser_blocklist_content.js | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/browser/base/content/test/plugins/browser_blocklist_content.js b/browser/base/content/test/plugins/browser_blocklist_content.js new file mode 100644 index 000000000..bf4e159bc --- /dev/null +++ b/browser/base/content/test/plugins/browser_blocklist_content.js @@ -0,0 +1,104 @@ +var gTestBrowser = null; +var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); +var gChromeRoot = getRootDirectory(gTestPath); + +add_task(function* () { + registerCleanupFunction(Task.async(function*() { + clearAllPluginPermissions(); + Services.prefs.clearUserPref("extensions.blocklist.suppressUI"); + Services.prefs.clearUserPref("plugins.click_to_play"); + setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in"); + setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in"); + yield asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser); + resetBlocklist(); + gBrowser.removeCurrentTab(); + window.focus(); + gTestBrowser = null; + })); +}); + +add_task(function* () { + Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true); + Services.prefs.setBoolPref("plugins.click_to_play", true); + + gBrowser.selectedTab = gBrowser.addTab(); + gTestBrowser = gBrowser.selectedBrowser; + + setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in"); + setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in"); + + // Prime the blocklist service, the remote service doesn't launch on startup. + yield promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html></html>"); + let exmsg = yield promiseInitContentBlocklistSvc(gBrowser.selectedBrowser); + ok(!exmsg, "exception: " + exmsg); +}); + +add_task(function* () { + yield promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html"); + + yield asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser); + + // Work around for delayed PluginBindingAttached + yield promiseUpdatePluginBindings(gTestBrowser); + + yield ContentTask.spawn(gTestBrowser, {}, function* () { + let test = content.document.getElementById("test"); + Assert.ok(test.activated, "task 1a: test plugin should be activated!"); + }); +}); + +// Load a fresh page, load a new plugin blocklist, then load the same page again. +add_task(function* () { + yield promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html>GO!</html>"); + yield asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginHard.xml", gTestBrowser); + yield promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html"); + + // Work around for delayed PluginBindingAttached + yield promiseUpdatePluginBindings(gTestBrowser); + + yield ContentTask.spawn(gTestBrowser, {}, function* () { + let test = content.document.getElementById("test"); + ok(!test.activated, "task 2a: test plugin shouldn't activate!"); + }); +}); + +// Unload the block list and lets do this again, only this time lets +// hack around in the content blocklist service maliciously. +add_task(function* () { + yield promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html>GO!</html>"); + + yield asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", 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. + let mm = gTestBrowser.messageManager; + info("test 3a: loading " + gChromeRoot + "blocklist_proxy.js" + "\n"); + mm.loadFrameScript(gChromeRoot + "blocklist_proxy.js", true); + + yield promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html"); + + // Work around for delayed PluginBindingAttached + yield promiseUpdatePluginBindings(gTestBrowser); + + yield ContentTask.spawn(gTestBrowser, {}, function* () { + let test = content.document.getElementById("test"); + Assert.ok(test.activated, "task 3a: test plugin should be activated!"); + }); +}); + +// Load a fresh page, load a new plugin blocklist, then load the same page again. +add_task(function* () { + yield promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html>GO!</html>"); + yield asyncSetAndUpdateBlocklist(gTestRoot + "blockPluginHard.xml", gTestBrowser); + yield promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html"); + + // Work around for delayed PluginBindingAttached + yield promiseUpdatePluginBindings(gTestBrowser); + + yield ContentTask.spawn(gTestBrowser, {}, function* () { + let test = content.document.getElementById("test"); + Assert.ok(!test.activated, "task 4a: test plugin shouldn't activate!"); + }); + + yield asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser); +}); |