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 that compatibility overrides are refreshed when showing the addon |
michael@0 | 6 | // selection UI. |
michael@0 | 7 | |
michael@0 | 8 | const PREF_GETADDONS_BYIDS = "extensions.getAddons.get.url"; |
michael@0 | 9 | const PREF_MIN_PLATFORM_COMPAT = "extensions.minCompatiblePlatformVersion"; |
michael@0 | 10 | |
michael@0 | 11 | var gTestAddon = null; |
michael@0 | 12 | var gWin; |
michael@0 | 13 | |
michael@0 | 14 | function waitForView(aView, aCallback) { |
michael@0 | 15 | var view = gWin.document.getElementById(aView); |
michael@0 | 16 | if (view.parentNode.selectedPanel == view) { |
michael@0 | 17 | aCallback(); |
michael@0 | 18 | return; |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | view.addEventListener("ViewChanged", function() { |
michael@0 | 22 | view.removeEventListener("ViewChanged", arguments.callee, false); |
michael@0 | 23 | aCallback(); |
michael@0 | 24 | }, false); |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | function install_test_addon(aCallback) { |
michael@0 | 28 | AddonManager.getInstallForURL(TESTROOT + "addons/browser_select_compatoverrides_1.xpi", function(aInstall) { |
michael@0 | 29 | var listener = { |
michael@0 | 30 | onInstallEnded: function() { |
michael@0 | 31 | AddonManager.getAddonByID("addon1@tests.mozilla.org", function(addon) { |
michael@0 | 32 | gTestAddon = addon; |
michael@0 | 33 | aCallback(); |
michael@0 | 34 | }); |
michael@0 | 35 | } |
michael@0 | 36 | }; |
michael@0 | 37 | aInstall.addListener(listener); |
michael@0 | 38 | aInstall.install(); |
michael@0 | 39 | }, "application/x-xpinstall"); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | registerCleanupFunction(function() { |
michael@0 | 43 | if (gWin) |
michael@0 | 44 | gWin.close(); |
michael@0 | 45 | if (gTestAddon) |
michael@0 | 46 | gTestAddon.uninstall(); |
michael@0 | 47 | |
michael@0 | 48 | Services.prefs.clearUserPref(PREF_MIN_PLATFORM_COMPAT); |
michael@0 | 49 | }); |
michael@0 | 50 | |
michael@0 | 51 | function end_test() { |
michael@0 | 52 | finish(); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | |
michael@0 | 56 | function test() { |
michael@0 | 57 | waitForExplicitFinish(); |
michael@0 | 58 | Services.prefs.setCharPref(PREF_UPDATEURL, TESTROOT + "missing.rdf"); |
michael@0 | 59 | Services.prefs.setBoolPref(PREF_STRICT_COMPAT, false); |
michael@0 | 60 | Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0"); |
michael@0 | 61 | |
michael@0 | 62 | install_test_addon(run_next_test); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | add_test(function() { |
michael@0 | 66 | gWin = Services.ww.openWindow(null, |
michael@0 | 67 | "chrome://mozapps/content/extensions/selectAddons.xul", |
michael@0 | 68 | "", |
michael@0 | 69 | "chrome,centerscreen,dialog,titlebar", |
michael@0 | 70 | null); |
michael@0 | 71 | waitForFocus(function() { |
michael@0 | 72 | waitForView("select", run_next_test); |
michael@0 | 73 | }, gWin); |
michael@0 | 74 | }); |
michael@0 | 75 | |
michael@0 | 76 | add_test(function() { |
michael@0 | 77 | for (var row = gWin.document.getElementById("select-rows").firstChild; row; row = row.nextSibling) { |
michael@0 | 78 | if (row.localName == "separator") |
michael@0 | 79 | continue; |
michael@0 | 80 | if (row.id.substr(-18) != "@tests.mozilla.org") |
michael@0 | 81 | continue; |
michael@0 | 82 | |
michael@0 | 83 | is(row.id, "addon1@tests.mozilla.org", "Should get expected addon"); |
michael@0 | 84 | isnot(row.action, "incompatible", "Addon should not be incompatible"); |
michael@0 | 85 | |
michael@0 | 86 | gWin.close(); |
michael@0 | 87 | gWin = null; |
michael@0 | 88 | run_next_test(); |
michael@0 | 89 | } |
michael@0 | 90 | }); |
michael@0 | 91 | |
michael@0 | 92 | add_test(function() { |
michael@0 | 93 | Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, TESTROOT + "browser_select_compatoverrides.xml"); |
michael@0 | 94 | Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); |
michael@0 | 95 | |
michael@0 | 96 | gWin = Services.ww.openWindow(null, |
michael@0 | 97 | "chrome://mozapps/content/extensions/selectAddons.xul", |
michael@0 | 98 | "", |
michael@0 | 99 | "chrome,centerscreen,dialog,titlebar", |
michael@0 | 100 | null); |
michael@0 | 101 | waitForFocus(function() { |
michael@0 | 102 | waitForView("select", run_next_test); |
michael@0 | 103 | }, gWin); |
michael@0 | 104 | }); |
michael@0 | 105 | |
michael@0 | 106 | add_test(function() { |
michael@0 | 107 | for (var row = gWin.document.getElementById("select-rows").firstChild; row; row = row.nextSibling) { |
michael@0 | 108 | if (row.localName == "separator") |
michael@0 | 109 | continue; |
michael@0 | 110 | if (row.id.substr(-18) != "@tests.mozilla.org") |
michael@0 | 111 | continue; |
michael@0 | 112 | is(row.id, "addon1@tests.mozilla.org", "Should get expected addon"); |
michael@0 | 113 | is(row.action, "incompatible", "Addon should be incompatible"); |
michael@0 | 114 | run_next_test(); |
michael@0 | 115 | } |
michael@0 | 116 | }); |