Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 3 | */ |
michael@0 | 4 | |
michael@0 | 5 | // Tests whether |
michael@0 | 6 | const Cc = Components.classes; |
michael@0 | 7 | const Ci = Components.interfaces; |
michael@0 | 8 | const Cu = Components.utils; |
michael@0 | 9 | |
michael@0 | 10 | Cu.import("resource://testing-common/httpd.js"); |
michael@0 | 11 | |
michael@0 | 12 | var gTestserver = new HttpServer(); |
michael@0 | 13 | gTestserver.start(-1); |
michael@0 | 14 | gPort = gTestserver.identity.primaryPort; |
michael@0 | 15 | mapFile("/data/test_bug619730.xml", gTestserver); |
michael@0 | 16 | |
michael@0 | 17 | function load_blocklist(file, aCallback) { |
michael@0 | 18 | Services.obs.addObserver(function() { |
michael@0 | 19 | Services.obs.removeObserver(arguments.callee, "blocklist-updated"); |
michael@0 | 20 | |
michael@0 | 21 | do_execute_soon(aCallback); |
michael@0 | 22 | }, "blocklist-updated", false); |
michael@0 | 23 | |
michael@0 | 24 | Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" + |
michael@0 | 25 | gPort + "/data/" + file); |
michael@0 | 26 | var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. |
michael@0 | 27 | getService(Ci.nsITimerCallback); |
michael@0 | 28 | blocklist.notify(null); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | var gSawGFX = false; |
michael@0 | 32 | var gSawTest = false; |
michael@0 | 33 | |
michael@0 | 34 | // Performs the initial setup |
michael@0 | 35 | function run_test() { |
michael@0 | 36 | createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8"); |
michael@0 | 37 | startupManager(); |
michael@0 | 38 | |
michael@0 | 39 | do_test_pending(); |
michael@0 | 40 | |
michael@0 | 41 | Services.obs.addObserver(function(aSubject, aTopic, aData) { |
michael@0 | 42 | do_check_true(aSubject instanceof AM_Ci.nsIDOMElement); |
michael@0 | 43 | do_check_eq(aSubject.getAttribute("testattr"), "GFX"); |
michael@0 | 44 | do_check_eq(aSubject.childNodes.length, 2); |
michael@0 | 45 | gSawGFX = true; |
michael@0 | 46 | }, "blocklist-data-gfxItems", false); |
michael@0 | 47 | |
michael@0 | 48 | Services.obs.addObserver(function(aSubject, aTopic, aData) { |
michael@0 | 49 | do_check_true(aSubject instanceof AM_Ci.nsIDOMElement); |
michael@0 | 50 | do_check_eq(aSubject.getAttribute("testattr"), "FOO"); |
michael@0 | 51 | do_check_eq(aSubject.childNodes.length, 3); |
michael@0 | 52 | gSawTest = true; |
michael@0 | 53 | }, "blocklist-data-testItems", false); |
michael@0 | 54 | |
michael@0 | 55 | Services.obs.addObserver(function(aSubject, aTopic, aData) { |
michael@0 | 56 | do_check_true(gSawGFX); |
michael@0 | 57 | do_check_true(gSawTest); |
michael@0 | 58 | }, "blocklist-data-fooItems", false); |
michael@0 | 59 | |
michael@0 | 60 | // Need to wait for the blocklist to load; Bad Things happen if the test harness |
michael@0 | 61 | // shuts down AddonManager before the blocklist service is done telling it about |
michael@0 | 62 | // changes |
michael@0 | 63 | load_blocklist("test_bug619730.xml", () => gTestserver.stop(do_test_finished)); |
michael@0 | 64 | } |