From 6e7918b6ccb69876d339a320091fdee811445395 Mon Sep 17 00:00:00 2001 From: Ruben Rodriguez Date: Mon, 20 Oct 2014 02:24:51 +0200 Subject: Generalize data directory --- .../chrome/content/ruleset-tests.js | 155 +++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 data/extensions/https-everywhere@eff.org/chrome/content/ruleset-tests.js (limited to 'data/extensions/https-everywhere@eff.org/chrome/content/ruleset-tests.js') diff --git a/data/extensions/https-everywhere@eff.org/chrome/content/ruleset-tests.js b/data/extensions/https-everywhere@eff.org/chrome/content/ruleset-tests.js new file mode 100644 index 0000000..1aa94d8 --- /dev/null +++ b/data/extensions/https-everywhere@eff.org/chrome/content/ruleset-tests.js @@ -0,0 +1,155 @@ +// load the HTTPS Everywhere component +var HTTPSEverywhere = null; +try { + HTTPSEverywhere = Components.classes["@eff.org/https-everywhere;1"] + .getService(Components.interfaces.nsISupports) + .wrappedJSObject; +} catch(e) { + // HTTPS Everywhere doesn't seem to be installed +} + +// attach testRunner to the HTTPS Everywhere component so that status.js can run it +if(HTTPSEverywhere) { + HTTPSEverywhere.httpseRulesetTests = { + testRunner: testRunner + }; +} + + +function openStatus() { + // make sure mixed content blocking preferences are correct + Services.prefs.setBoolPref("security.mixed_content.block_display_content", false); + Services.prefs.setBoolPref("security.mixed_content.block_active_content", true); + + // open the status tab + var statusTab = gBrowser.addTab('chrome://https-everywhere/content/ruleset-tests-status.xul'); + gBrowser.selectedTab = statusTab; +} + +function testRunner() { + Components.utils.import("resource://gre/modules/PopupNotifications.jsm"); + + const numTabs = 6; + var finished = false; + var output = []; + var urls = []; + var num = 0; + + for(var target in HTTPSEverywhere.https_rules.targets) { + if(!target.indexOf("*") != -1) { + urls.push({ + url: 'https://'+target, + target: target, + ruleset_names: HTTPSEverywhere.https_rules.targets[target] + }); + } + } + + function test() { + var i; + + HTTPSEverywhere.httpseRulesetTests.updateStatusBar(num, urls.length); + + // start loading all the tabs + window.focus + for(i=0; i