forked from mirrors/gecko-dev
--HG-- rename : browser/base/content/test/general/blockNoPlugins.xml => browser/base/content/test/plugins/blockNoPlugins.xml rename : browser/base/content/test/general/blockPluginHard.xml => browser/base/content/test/plugins/blockPluginHard.xml rename : browser/base/content/test/general/blockPluginVulnerableNoUpdate.xml => browser/base/content/test/plugins/blockPluginVulnerableNoUpdate.xml rename : browser/base/content/test/general/blockPluginVulnerableUpdatable.xml => browser/base/content/test/plugins/blockPluginVulnerableUpdatable.xml rename : browser/base/content/test/general/browser_CTP_context_menu.js => browser/base/content/test/plugins/browser_CTP_context_menu.js rename : browser/base/content/test/general/browser_CTP_crashreporting.js => browser/base/content/test/plugins/browser_CTP_crashreporting.js rename : browser/base/content/test/general/browser_CTP_data_urls.js => browser/base/content/test/plugins/browser_CTP_data_urls.js rename : browser/base/content/test/general/browser_CTP_drag_drop.js => browser/base/content/test/plugins/browser_CTP_drag_drop.js rename : browser/base/content/test/general/browser_CTP_hide_overlay.js => browser/base/content/test/plugins/browser_CTP_hide_overlay.js rename : browser/base/content/test/general/browser_CTP_multi_allow.js => browser/base/content/test/plugins/browser_CTP_multi_allow.js rename : browser/base/content/test/general/browser_CTP_nonplugins.js => browser/base/content/test/plugins/browser_CTP_nonplugins.js rename : browser/base/content/test/general/browser_CTP_notificationBar.js => browser/base/content/test/plugins/browser_CTP_notificationBar.js rename : browser/base/content/test/general/browser_CTP_outsideScrollArea.js => browser/base/content/test/plugins/browser_CTP_outsideScrollArea.js rename : browser/base/content/test/general/browser_CTP_resize.js => browser/base/content/test/plugins/browser_CTP_resize.js rename : browser/base/content/test/general/browser_bug743421.js => browser/base/content/test/plugins/browser_bug743421.js rename : browser/base/content/test/general/browser_bug744745.js => browser/base/content/test/plugins/browser_bug744745.js rename : browser/base/content/test/general/browser_bug752516.js => browser/base/content/test/plugins/browser_bug752516.js rename : browser/base/content/test/general/browser_bug787619.js => browser/base/content/test/plugins/browser_bug787619.js rename : browser/base/content/test/general/browser_bug797677.js => browser/base/content/test/plugins/browser_bug797677.js rename : browser/base/content/test/general/browser_bug812562.js => browser/base/content/test/plugins/browser_bug812562.js rename : browser/base/content/test/general/browser_bug818118.js => browser/base/content/test/plugins/browser_bug818118.js rename : browser/base/content/test/general/browser_bug820497.js => browser/base/content/test/plugins/browser_bug820497.js rename : browser/base/content/test/general/browser_clearplugindata.html => browser/base/content/test/plugins/browser_clearplugindata.html rename : browser/base/content/test/general/browser_clearplugindata.js => browser/base/content/test/plugins/browser_clearplugindata.js rename : browser/base/content/test/general/browser_clearplugindata_noage.html => browser/base/content/test/plugins/browser_clearplugindata_noage.html rename : browser/base/content/test/general/browser_pageInfo_plugins.js => browser/base/content/test/plugins/browser_pageInfo_plugins.js rename : browser/base/content/test/general/browser_pluginCrashCommentAndURL.js => browser/base/content/test/plugins/browser_pluginCrashCommentAndURL.js rename : browser/base/content/test/general/browser_pluginnotification.js => browser/base/content/test/plugins/browser_pluginnotification.js rename : browser/base/content/test/general/browser_pluginplaypreview.js => browser/base/content/test/plugins/browser_pluginplaypreview.js rename : browser/base/content/test/general/browser_pluginplaypreview2.js => browser/base/content/test/plugins/browser_pluginplaypreview2.js rename : browser/base/content/test/general/browser_plugins_added_dynamically.js => browser/base/content/test/plugins/browser_plugins_added_dynamically.js rename : browser/base/content/test/general/plugin_add_dynamically.html => browser/base/content/test/plugins/plugin_add_dynamically.html rename : browser/base/content/test/general/plugin_alternate_content.html => browser/base/content/test/plugins/plugin_alternate_content.html rename : browser/base/content/test/general/plugin_big.html => browser/base/content/test/plugins/plugin_big.html rename : browser/base/content/test/general/plugin_both.html => browser/base/content/test/plugins/plugin_both.html rename : browser/base/content/test/general/plugin_both2.html => browser/base/content/test/plugins/plugin_both2.html rename : browser/base/content/test/general/plugin_bug744745.html => browser/base/content/test/plugins/plugin_bug744745.html rename : browser/base/content/test/general/plugin_bug749455.html => browser/base/content/test/plugins/plugin_bug749455.html rename : browser/base/content/test/general/plugin_bug752516.html => browser/base/content/test/plugins/plugin_bug752516.html rename : browser/base/content/test/general/plugin_bug787619.html => browser/base/content/test/plugins/plugin_bug787619.html rename : browser/base/content/test/general/plugin_bug797677.html => browser/base/content/test/plugins/plugin_bug797677.html rename : browser/base/content/test/general/plugin_bug820497.html => browser/base/content/test/plugins/plugin_bug820497.html rename : browser/base/content/test/general/plugin_clickToPlayAllow.html => browser/base/content/test/plugins/plugin_clickToPlayAllow.html rename : browser/base/content/test/general/plugin_clickToPlayDeny.html => browser/base/content/test/plugins/plugin_clickToPlayDeny.html rename : browser/base/content/test/general/pluginCrashCommentAndURL.html => browser/base/content/test/plugins/plugin_crashCommentAndURL.html rename : browser/base/content/test/general/plugin_data_url.html => browser/base/content/test/plugins/plugin_data_url.html rename : browser/base/content/test/general/plugin_hidden_to_visible.html => browser/base/content/test/plugins/plugin_hidden_to_visible.html rename : browser/base/content/test/general/plugin_outsideScrollArea.html => browser/base/content/test/plugins/plugin_outsideScrollArea.html rename : browser/base/content/test/general/plugin_overlayed.html => browser/base/content/test/plugins/plugin_overlayed.html rename : browser/base/content/test/general/plugin_positioned.html => browser/base/content/test/plugins/plugin_positioned.html rename : browser/base/content/test/general/plugin_small.html => browser/base/content/test/plugins/plugin_small.html rename : browser/base/content/test/general/plugin_syncRemoved.html => browser/base/content/test/plugins/plugin_syncRemoved.html rename : browser/base/content/test/general/plugin_test.html => browser/base/content/test/plugins/plugin_test.html rename : browser/base/content/test/general/plugin_test2.html => browser/base/content/test/plugins/plugin_test2.html rename : browser/base/content/test/general/plugin_test3.html => browser/base/content/test/plugins/plugin_test3.html rename : browser/base/content/test/general/plugin_two_types.html => browser/base/content/test/plugins/plugin_two_types.html rename : browser/base/content/test/general/plugin_unknown.html => browser/base/content/test/plugins/plugin_unknown.html
133 lines
3.9 KiB
JavaScript
133 lines
3.9 KiB
JavaScript
/**
|
|
* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
*/
|
|
|
|
var rootDir = getRootDirectory(gTestPath);
|
|
const gHttpTestRoot = rootDir.replace("chrome://mochitests/content/", "http://mochi.test:8888/");
|
|
|
|
// Test clearing plugin data using sanitize.js.
|
|
const testURL1 = gHttpTestRoot + "browser_clearplugindata.html";
|
|
const testURL2 = gHttpTestRoot + "browser_clearplugindata_noage.html";
|
|
|
|
let tempScope = {};
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader)
|
|
.loadSubScript("chrome://browser/content/sanitize.js", tempScope);
|
|
let Sanitizer = tempScope.Sanitizer;
|
|
|
|
const pluginHostIface = Ci.nsIPluginHost;
|
|
var pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
|
|
pluginHost.QueryInterface(pluginHostIface);
|
|
|
|
var pluginTag = getTestPlugin();
|
|
var s;
|
|
|
|
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 test() {
|
|
waitForExplicitFinish();
|
|
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED);
|
|
|
|
s = new Sanitizer();
|
|
s.ignoreTimespan = false;
|
|
s.prefDomain = "privacy.cpd.";
|
|
var itemPrefs = gPrefService.getBranch(s.prefDomain);
|
|
itemPrefs.setBoolPref("history", false);
|
|
itemPrefs.setBoolPref("downloads", false);
|
|
itemPrefs.setBoolPref("cache", false);
|
|
itemPrefs.setBoolPref("cookies", true); // plugin data
|
|
itemPrefs.setBoolPref("formdata", false);
|
|
itemPrefs.setBoolPref("offlineApps", false);
|
|
itemPrefs.setBoolPref("passwords", false);
|
|
itemPrefs.setBoolPref("sessions", false);
|
|
itemPrefs.setBoolPref("siteSettings", false);
|
|
|
|
executeSoon(test_with_age);
|
|
}
|
|
|
|
function setFinishedCallback(callback)
|
|
{
|
|
let testPage = gBrowser.selectedBrowser.contentWindow.wrappedJSObject;
|
|
testPage.testFinishedCallback = function() {
|
|
setTimeout(function() {
|
|
info("got finished callback");
|
|
callback();
|
|
}, 0);
|
|
}
|
|
}
|
|
|
|
function test_with_age()
|
|
{
|
|
// Load page to set data for the plugin.
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
gBrowser.selectedBrowser.addEventListener("load", function () {
|
|
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
|
|
|
setFinishedCallback(function() {
|
|
ok(stored(["foo.com","bar.com","baz.com","qux.com"]),
|
|
"Data stored for sites");
|
|
|
|
// Clear 20 seconds ago
|
|
var now_uSec = Date.now() * 1000;
|
|
s.range = [now_uSec - 20*1000000, now_uSec];
|
|
s.sanitize();
|
|
|
|
ok(stored(["bar.com","qux.com"]), "Data stored for sites");
|
|
ok(!stored(["foo.com"]), "Data cleared for foo.com");
|
|
ok(!stored(["baz.com"]), "Data cleared for baz.com");
|
|
|
|
// Clear everything
|
|
s.range = null;
|
|
s.sanitize();
|
|
|
|
ok(!stored(null), "All data cleared");
|
|
|
|
gBrowser.removeCurrentTab();
|
|
|
|
executeSoon(test_without_age);
|
|
});
|
|
}, true);
|
|
content.location = testURL1;
|
|
}
|
|
|
|
function test_without_age()
|
|
{
|
|
// Load page to set data for the plugin.
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
gBrowser.selectedBrowser.addEventListener("load", function () {
|
|
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
|
|
|
setFinishedCallback(function() {
|
|
ok(stored(["foo.com","bar.com","baz.com","qux.com"]),
|
|
"Data stored for sites");
|
|
|
|
// Attempt to clear 20 seconds ago. The plugin will throw
|
|
// NS_ERROR_PLUGIN_TIME_RANGE_NOT_SUPPORTED, which should result in us
|
|
// clearing all data regardless of age.
|
|
var now_uSec = Date.now() * 1000;
|
|
s.range = [now_uSec - 20*1000000, now_uSec];
|
|
s.sanitize();
|
|
|
|
ok(!stored(null), "All data cleared");
|
|
|
|
gBrowser.removeCurrentTab();
|
|
|
|
executeSoon(finish);
|
|
});
|
|
}, true);
|
|
content.location = testURL2;
|
|
}
|
|
|