michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Tests that compatibility overrides are refreshed when showing the addon michael@0: // selection UI. michael@0: michael@0: const PREF_GETADDONS_BYIDS = "extensions.getAddons.get.url"; michael@0: const PREF_MIN_PLATFORM_COMPAT = "extensions.minCompatiblePlatformVersion"; michael@0: michael@0: var gTestAddon = null; michael@0: var gWin; michael@0: michael@0: function waitForView(aView, aCallback) { michael@0: var view = gWin.document.getElementById(aView); michael@0: if (view.parentNode.selectedPanel == view) { michael@0: aCallback(); michael@0: return; michael@0: } michael@0: michael@0: view.addEventListener("ViewChanged", function() { michael@0: view.removeEventListener("ViewChanged", arguments.callee, false); michael@0: aCallback(); michael@0: }, false); michael@0: } michael@0: michael@0: function install_test_addon(aCallback) { michael@0: AddonManager.getInstallForURL(TESTROOT + "addons/browser_select_compatoverrides_1.xpi", function(aInstall) { michael@0: var listener = { michael@0: onInstallEnded: function() { michael@0: AddonManager.getAddonByID("addon1@tests.mozilla.org", function(addon) { michael@0: gTestAddon = addon; michael@0: aCallback(); michael@0: }); michael@0: } michael@0: }; michael@0: aInstall.addListener(listener); michael@0: aInstall.install(); michael@0: }, "application/x-xpinstall"); michael@0: } michael@0: michael@0: registerCleanupFunction(function() { michael@0: if (gWin) michael@0: gWin.close(); michael@0: if (gTestAddon) michael@0: gTestAddon.uninstall(); michael@0: michael@0: Services.prefs.clearUserPref(PREF_MIN_PLATFORM_COMPAT); michael@0: }); michael@0: michael@0: function end_test() { michael@0: finish(); michael@0: } michael@0: michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: Services.prefs.setCharPref(PREF_UPDATEURL, TESTROOT + "missing.rdf"); michael@0: Services.prefs.setBoolPref(PREF_STRICT_COMPAT, false); michael@0: Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0"); michael@0: michael@0: install_test_addon(run_next_test); michael@0: } michael@0: michael@0: add_test(function() { michael@0: gWin = Services.ww.openWindow(null, michael@0: "chrome://mozapps/content/extensions/selectAddons.xul", michael@0: "", michael@0: "chrome,centerscreen,dialog,titlebar", michael@0: null); michael@0: waitForFocus(function() { michael@0: waitForView("select", run_next_test); michael@0: }, gWin); michael@0: }); michael@0: michael@0: add_test(function() { michael@0: for (var row = gWin.document.getElementById("select-rows").firstChild; row; row = row.nextSibling) { michael@0: if (row.localName == "separator") michael@0: continue; michael@0: if (row.id.substr(-18) != "@tests.mozilla.org") michael@0: continue; michael@0: michael@0: is(row.id, "addon1@tests.mozilla.org", "Should get expected addon"); michael@0: isnot(row.action, "incompatible", "Addon should not be incompatible"); michael@0: michael@0: gWin.close(); michael@0: gWin = null; michael@0: run_next_test(); michael@0: } michael@0: }); michael@0: michael@0: add_test(function() { michael@0: Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, TESTROOT + "browser_select_compatoverrides.xml"); michael@0: Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); michael@0: michael@0: gWin = Services.ww.openWindow(null, michael@0: "chrome://mozapps/content/extensions/selectAddons.xul", michael@0: "", michael@0: "chrome,centerscreen,dialog,titlebar", michael@0: null); michael@0: waitForFocus(function() { michael@0: waitForView("select", run_next_test); michael@0: }, gWin); michael@0: }); michael@0: michael@0: add_test(function() { michael@0: for (var row = gWin.document.getElementById("select-rows").firstChild; row; row = row.nextSibling) { michael@0: if (row.localName == "separator") michael@0: continue; michael@0: if (row.id.substr(-18) != "@tests.mozilla.org") michael@0: continue; michael@0: is(row.id, "addon1@tests.mozilla.org", "Should get expected addon"); michael@0: is(row.action, "incompatible", "Addon should be incompatible"); michael@0: run_next_test(); michael@0: } michael@0: });