From 68b22398293429f9519560705e66519afc54252c Mon Sep 17 00:00:00 2001 From: Joe Drew Date: Tue, 1 Mar 2011 11:58:59 -0500 Subject: [PATCH] Bug 637413 - Always use a blank blocklist.xml file in the addon manager tests so we aren't broken by blocklist file updates. r=mossop a=blocker --- .../extensions/test/xpcshell/head_addons.js | 15 +++++++++++++++ .../extensions/test/xpcshell/test_bug393285.js | 4 ++++ .../extensions/test/xpcshell/test_bug406118.js | 4 ++++ .../extensions/test/xpcshell/test_bug430120.js | 15 --------------- .../extensions/test/xpcshell/test_bug455906.js | 4 ++++ .../extensions/test/xpcshell/test_bug468528.js | 6 +++++- .../extensions/test/xpcshell/test_bug514327_1.js | 4 ++++ .../extensions/test/xpcshell/test_bug514327_2.js | 4 ++++ .../extensions/test/xpcshell/test_bug514327_3.js | 4 ++++ 9 files changed, 44 insertions(+), 16 deletions(-) diff --git a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js index 64f7fffa02f2..308bbd34adf3 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js +++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js @@ -1062,6 +1062,21 @@ gTmpD.append("temp"); gTmpD.create(AM_Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY); registerDirectory("TmpD", gTmpD); +// Write out an empty blocklist.xml file to the profile to ensure nothing +// is blocklisted by default +var blockFile = gProfD.clone(); +blockFile.append("blocklist.xml"); +var stream = AM_Cc["@mozilla.org/network/file-output-stream;1"]. + createInstance(AM_Ci.nsIFileOutputStream); +stream.init(blockFile, FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE | FileUtils.MODE_TRUNCATE, + FileUtils.PERMS_FILE, 0); + +var data = "\n" + + "\n" + + "\n"; +stream.write(data, data.length); +stream.close(); + do_register_cleanup(function() { // Check that the temporary directory is empty var dirEntries = gTmpD.directoryEntries diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug393285.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug393285.js index e3ca8be30973..cf4c9b7432b3 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug393285.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug393285.js @@ -40,6 +40,10 @@ function run_test() { createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9"); // We cannot force the blocklist to update so just copy our test list to the profile + var blocklistFile = gProfD.clone(); + blocklistFile.append("blocklist.xml"); + if (blocklistFile.exists()) + blocklistFile.remove(false); var source = do_get_file("data/test_bug393285.xml"); source.copyTo(gProfD, "blocklist.xml"); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js index 7240df499e24..4ef479d7c809 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js @@ -40,6 +40,10 @@ function run_test() { createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9"); // We cannot force the blocklist to update so just copy our test list to the profile + var blocklistFile = gProfD.clone(); + blocklistFile.append("blocklist.xml"); + if (blocklistFile.exists()) + blocklistFile.remove(false); var source = do_get_file("data/test_bug393285.xml"); source.copyTo(gProfD, "blocklist.xml"); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug430120.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug430120.js index 9b0708337e23..7a8845b8041d 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug430120.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug430120.js @@ -117,21 +117,6 @@ function pathHandler(metadata, response) { } function run_test() { - // Write out an empty blocklist.xml file to the profile to ensure nothing - // is blocklisted by default - var blockFile = gProfD.clone(); - blockFile.append("blocklist.xml"); - var stream = AM_Cc["@mozilla.org/network/file-output-stream;1"]. - createInstance(AM_Ci.nsIFileOutputStream); - stream.init(blockFile, FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE | FileUtils.MODE_TRUNCATE, - FileUtils.PERMS_FILE, 0); - - var data = "\n" + - "\n" + - "\n"; - stream.write(data, data.length); - stream.close(); - var osVersion; var sysInfo = Components.classes["@mozilla.org/system-info;1"] .getService(Components.interfaces.nsIPropertyBag2); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug455906.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug455906.js index bf9cd46a5089..56a8d110c980 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug455906.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug455906.js @@ -257,6 +257,10 @@ function run_test() { // Copy the initial blocklist into the profile to check add-ons start in the // right state. + var blocklistFile = gProfD.clone(); + blocklistFile.append("blocklist.xml"); + if (blocklistFile.exists()) + blocklistFile.remove(false); var blocklist = do_get_file("data/bug455906_start.xml") blocklist.copyTo(gProfD, "blocklist.xml"); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug468528.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug468528.js index 62906f798ed1..0dead0ddb5c1 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug468528.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug468528.js @@ -71,6 +71,10 @@ function run_test() { createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9"); // We cannot force the blocklist to update so just copy our test list to the profile + var blocklistFile = gProfD.clone(); + blocklistFile.append("blocklist.xml"); + if (blocklistFile.exists()) + blocklistFile.remove(false); var source = do_get_file("data/test_bug468528.xml"); source.copyTo(gProfD, "blocklist.xml"); @@ -89,4 +93,4 @@ function run_test() { // not blocked - the previous invalid regexp shouldn't act as a wildcard do_check_true(blocklist.getPluginBlocklistState(PLUGINS[3], "1", "1.9") == nsIBLS.STATE_NOT_BLOCKED); -} \ No newline at end of file +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_1.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_1.js index b0374ac8acc2..9ba65a6fc428 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_1.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_1.js @@ -74,6 +74,10 @@ var PLUGINS = [{ function run_test() { createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9"); + var blocklistFile = gProfD.clone(); + blocklistFile.append("blocklist.xml"); + if (blocklistFile.exists()) + blocklistFile.remove(false); var source = do_get_file("data/test_bug514327_1.xml"); source.copyTo(gProfD, "blocklist.xml"); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_2.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_2.js index 41e1e2ab53e1..3a515486b25b 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_2.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_2.js @@ -54,6 +54,10 @@ function get_test_plugintag() { function run_test() { createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9"); + var blocklistFile = gProfD.clone(); + blocklistFile.append("blocklist.xml"); + if (blocklistFile.exists()) + blocklistFile.remove(false); var source = do_get_file("data/test_bug514327_2.xml"); source.copyTo(gProfD, "blocklist.xml"); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_3.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_3.js index 726d19965155..61b9b50ca9ba 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_3.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_3.js @@ -152,6 +152,10 @@ function run_test() { // initialize the blocklist with no entries + var blocklistFile = gProfD.clone(); + blocklistFile.append("blocklist.xml"); + if (blocklistFile.exists()) + blocklistFile.remove(false); var source = do_get_file("data/test_bug514327_3_empty.xml"); source.copyTo(gProfD, "blocklist.xml");