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 /toolkit/forgetaboutsite/test/browser | |
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 'toolkit/forgetaboutsite/test/browser')
4 files changed, 132 insertions, 0 deletions
diff --git a/toolkit/forgetaboutsite/test/browser/.eslintrc.js b/toolkit/forgetaboutsite/test/browser/.eslintrc.js new file mode 100644 index 000000000..c764b133d --- /dev/null +++ b/toolkit/forgetaboutsite/test/browser/.eslintrc.js @@ -0,0 +1,7 @@ +"use strict"; + +module.exports = { + "extends": [ + "../../../../testing/mochitest/browser.eslintrc.js" + ] +}; diff --git a/toolkit/forgetaboutsite/test/browser/browser.ini b/toolkit/forgetaboutsite/test/browser/browser.ini new file mode 100644 index 000000000..517d89d78 --- /dev/null +++ b/toolkit/forgetaboutsite/test/browser/browser.ini @@ -0,0 +1,4 @@ +[DEFAULT] +support-files = browser_clearplugindata.html + +[browser_clearplugindata.js] diff --git a/toolkit/forgetaboutsite/test/browser/browser_clearplugindata.html b/toolkit/forgetaboutsite/test/browser/browser_clearplugindata.html new file mode 100644 index 000000000..b2bba12ce --- /dev/null +++ b/toolkit/forgetaboutsite/test/browser/browser_clearplugindata.html @@ -0,0 +1,30 @@ +<!-- + Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ +--> +<html> + <head> + <title>Plugin Clear Site Data clear by domain test</title> + + <embed id="plugin1" type="application/x-test" width="200" height="200"></embed> + + <script type="application/javascript"> + function testSteps() + { + var p = document.getElementById("plugin1"); + + p.setSitesWithData( + "foo.com:0:0," + + "bar.foo.com:0:0," + + "baz.foo.com:0:0," + + "bar.com:1:0," + + "[192.168.1.1]:0:0," + + "localhost:0:0" + ); + } + </script> + </head> + + <body></body> + +</html> diff --git a/toolkit/forgetaboutsite/test/browser/browser_clearplugindata.js b/toolkit/forgetaboutsite/test/browser/browser_clearplugindata.js new file mode 100644 index 000000000..ec0a70228 --- /dev/null +++ b/toolkit/forgetaboutsite/test/browser/browser_clearplugindata.js @@ -0,0 +1,91 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +Components.utils.import("resource://gre/modules/ForgetAboutSite.jsm"); + +// Test clearing plugin data by domain using ForgetAboutSite. +const testURL = "http://mochi.test:8888/browser/toolkit/forgetaboutsite/test/browser/browser_clearplugindata.html"; + +const pluginHostIface = Ci.nsIPluginHost; +var pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost); +pluginHost.QueryInterface(pluginHostIface); + +var pluginTag; + +function stored(needles) { + var something = pluginHost.siteHasData(this.pluginTag, null); + if (!needles) + return something; + + if (!something) + return false; + + for (var i = 0; i < needles.length; ++i) { + if (!pluginHost.siteHasData(this.pluginTag, needles[i])) + return false; + } + return true; +} + +function setTestPluginEnabledState(newEnabledState, plugin) { + var oldEnabledState = plugin.enabledState; + plugin.enabledState = newEnabledState; + SimpleTest.registerCleanupFunction(function() { + plugin.enabledState = oldEnabledState; + }); +} + +add_task(function* setup() { + var tags = pluginHost.getPluginTags(); + + // Find the test plugin + for (var i = 0; i < tags.length; i++) + { + if (tags[i].name == "Test Plug-in") + { + pluginTag = tags[i]; + } + } + if (!pluginTag) { + ok(false, "Test Plug-in not available, can't run test"); + finish(); + } + setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, pluginTag); +}); + +add_task(function* () { + yield BrowserTestUtils.openNewForegroundTab(gBrowser, testURL); + + // Set data for the plugin after the page load. + yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { + content.wrappedJSObject.testSteps(); + }); + + ok(stored(["192.168.1.1", "foo.com", "nonexistent.foo.com", "bar.com", "localhost"]), + "Data stored for sites"); + + // Clear data for "foo.com" and its subdomains. + yield ForgetAboutSite.removeDataFromDomain("foo.com"); + + ok(stored(["bar.com", "192.168.1.1", "localhost"]), "Data stored for sites"); + ok(!stored(["foo.com"]), "Data cleared for foo.com"); + ok(!stored(["bar.foo.com"]), "Data cleared for subdomains of foo.com"); + + // Clear data for "bar.com" using a subdomain. + yield ForgetAboutSite.removeDataFromDomain("foo.bar.com"); + ok(!stored(["bar.com"]), "Data cleared for bar.com"); + + // Clear data for "192.168.1.1". + yield ForgetAboutSite.removeDataFromDomain("192.168.1.1"); + ok(!stored(["192.168.1.1"]), "Data cleared for 192.168.1.1"); + + // Clear data for "localhost". + yield ForgetAboutSite.removeDataFromDomain("localhost"); + ok(!stored(null), "All data cleared"); + + gBrowser.removeCurrentTab(); +}); + + |