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 the discovery view loads properly michael@0: michael@0: const MAIN_URL = "https://example.com/" + RELATIVE_DIR + "discovery.html"; michael@0: michael@0: var gManagerWindow; michael@0: var gCategoryUtilities; michael@0: var gProvider; michael@0: michael@0: var gLoadCompleteCallback = null; michael@0: michael@0: var gProgressListener = { michael@0: onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) { michael@0: // Only care about the network stop status events michael@0: if (!(aStateFlags & (Ci.nsIWebProgressListener.STATE_IS_NETWORK)) || michael@0: !(aStateFlags & (Ci.nsIWebProgressListener.STATE_STOP))) michael@0: return; michael@0: michael@0: if (gLoadCompleteCallback) michael@0: executeSoon(gLoadCompleteCallback); michael@0: gLoadCompleteCallback = null; michael@0: }, michael@0: michael@0: onLocationChange: function() { }, michael@0: onSecurityChange: function() { }, michael@0: onProgressChange: function() { }, michael@0: onStatusChange: function() { }, michael@0: michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener, michael@0: Ci.nsISupportsWeakReference]), michael@0: }; michael@0: michael@0: function test() { michael@0: // Switch to a known url michael@0: Services.prefs.setCharPref(PREF_DISCOVERURL, MAIN_URL); michael@0: // Temporarily enable caching michael@0: Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); michael@0: michael@0: waitForExplicitFinish(); michael@0: michael@0: gProvider = new MockProvider(); michael@0: michael@0: gProvider.createAddons([{ michael@0: id: "addon1@tests.mozilla.org", michael@0: name: "Test add-on 1", michael@0: type: "extension", michael@0: version: "2.2", michael@0: isCompatible: false, michael@0: blocklistState: Ci.nsIBlocklistService.STATE_SOFTBLOCKED, michael@0: userDisabled: false michael@0: }, { michael@0: id: "addon2@tests.mozilla.org", michael@0: name: "Test add-on 2", michael@0: type: "plugin", michael@0: version: "3.1.5", michael@0: isCompatible: true, michael@0: blocklistState: Ci.nsIBlocklistService.STATE_NOT_BLOCKED, michael@0: userDisabled: false michael@0: }, { michael@0: id: "addon3@tests.mozilla.org", michael@0: name: "Test add-on 3", michael@0: type: "theme", michael@0: version: "1.2b1", michael@0: isCompatible: false, michael@0: blocklistState: Ci.nsIBlocklistService.STATE_BLOCKED, michael@0: userDisabled: true michael@0: }]); michael@0: michael@0: run_next_test(); michael@0: } michael@0: michael@0: function end_test() { michael@0: finish(); michael@0: } michael@0: michael@0: function getURL(aBrowser) { michael@0: if (gManagerWindow.document.getElementById("discover-view").selectedPanel != michael@0: aBrowser) michael@0: return null; michael@0: michael@0: var url = aBrowser.currentURI.spec; michael@0: var pos = url.indexOf("#"); michael@0: if (pos != -1) michael@0: return url.substring(0, pos); michael@0: return url; michael@0: } michael@0: michael@0: function getHash(aBrowser) { michael@0: if (gManagerWindow.document.getElementById("discover-view").selectedPanel != michael@0: aBrowser) michael@0: return null; michael@0: michael@0: var url = aBrowser.currentURI.spec; michael@0: var pos = url.indexOf("#"); michael@0: if (pos != -1) michael@0: return decodeURIComponent(url.substring(pos + 1)); michael@0: return null; michael@0: } michael@0: michael@0: function testHash(aBrowser, aTestAddonVisible, aCallback) { michael@0: var hash = getHash(aBrowser); michael@0: isnot(hash, null, "There should be a hash"); michael@0: try { michael@0: var data = JSON.parse(hash); michael@0: } michael@0: catch (e) { michael@0: ok(false, "Hash should have been valid JSON: " + e); michael@0: aCallback(); michael@0: return; michael@0: } michael@0: is(typeof data, "object", "Hash should be a JS object"); michael@0: michael@0: // Ensure that at least the test add-ons are present michael@0: if (aTestAddonVisible[0]) michael@0: ok("addon1@tests.mozilla.org" in data, "Test add-on 1 should be listed"); michael@0: else michael@0: ok(!("addon1@tests.mozilla.org" in data), "Test add-on 1 should not be listed"); michael@0: if (aTestAddonVisible[1]) michael@0: ok("addon2@tests.mozilla.org" in data, "Test add-on 2 should be listed"); michael@0: else michael@0: ok(!("addon2@tests.mozilla.org" in data), "Test add-on 2 should not be listed"); michael@0: if (aTestAddonVisible[2]) michael@0: ok("addon3@tests.mozilla.org" in data, "Test add-on 3 should be listed"); michael@0: else michael@0: ok(!("addon3@tests.mozilla.org" in data), "Test add-on 3 should not be listed"); michael@0: michael@0: // Test against all the add-ons the manager knows about since plugins and michael@0: // app extensions may exist michael@0: AddonManager.getAllAddons(function(aAddons) { michael@0: for (let addon of aAddons) { michael@0: if (!(addon.id in data)) { michael@0: // Test add-ons will have shown an error if necessary above michael@0: if (addon.id.substring(6) != "@tests.mozilla.org") michael@0: ok(false, "Add-on " + addon.id + " was not included in the data"); michael@0: continue; michael@0: } michael@0: michael@0: info("Testing data for add-on " + addon.id); michael@0: var addonData = data[addon.id]; michael@0: is(addonData.name, addon.name, "Name should be correct"); michael@0: is(addonData.version, addon.version, "Version should be correct"); michael@0: is(addonData.type, addon.type, "Type should be correct"); michael@0: is(addonData.userDisabled, addon.userDisabled, "userDisabled should be correct"); michael@0: is(addonData.isBlocklisted, addon.blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED, "blocklisted should be correct"); michael@0: is(addonData.isCompatible, addon.isCompatible, "isCompatible should be correct"); michael@0: } michael@0: aCallback(); michael@0: }); michael@0: } michael@0: michael@0: function isLoading() { michael@0: var loading = gManagerWindow.document.getElementById("discover-view").selectedPanel == michael@0: gManagerWindow.document.getElementById("discover-loading"); michael@0: if (loading) { michael@0: is_element_visible(gManagerWindow.document.querySelector("#discover-loading .loading"), michael@0: "Loading message should be visible when its panel is the selected panel"); michael@0: } michael@0: return loading; michael@0: } michael@0: michael@0: function isError() { michael@0: return gManagerWindow.document.getElementById("discover-view").selectedPanel == michael@0: gManagerWindow.document.getElementById("discover-error"); michael@0: } michael@0: michael@0: function clickLink(aId, aCallback) { michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: browser.addProgressListener(gProgressListener); michael@0: michael@0: gLoadCompleteCallback = function() { michael@0: browser.removeProgressListener(gProgressListener); michael@0: aCallback(); michael@0: }; michael@0: michael@0: var link = browser.contentDocument.getElementById(aId); michael@0: EventUtils.sendMouseEvent({type: "click"}, link); michael@0: michael@0: executeSoon(function() { michael@0: ok(isLoading(), "Clicking a link should show the loading pane"); michael@0: }); michael@0: } michael@0: michael@0: // Tests that switching to the discovery view displays the right url michael@0: add_test(function() { michael@0: open_manager("addons://list/extension", function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: michael@0: gCategoryUtilities.openType("discover", function() { michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: testHash(browser, [true, true, true], function() { michael@0: close_manager(gManagerWindow, run_next_test); michael@0: }); michael@0: }); michael@0: michael@0: ok(isLoading(), "Should be loading at first"); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that loading the add-ons manager with the discovery view as the last michael@0: // selected view displays the right url michael@0: add_test(function() { michael@0: // Hide one of the test add-ons michael@0: Services.prefs.setBoolPref("extensions.addon2@tests.mozilla.org.getAddons.cache.enabled", false); michael@0: Services.prefs.setBoolPref("extensions.addon3@tests.mozilla.org.getAddons.cache.enabled", true); michael@0: michael@0: open_manager(null, function(aWindow) { michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: is(gCategoryUtilities.selectedCategory, "discover", "Should have loaded the right view"); michael@0: michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: testHash(browser, [true, false, true], function() { michael@0: close_manager(gManagerWindow, run_next_test); michael@0: }); michael@0: }, function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: ok(isLoading(), "Should be loading at first"); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that loading the add-ons manager with the discovery view as the initial michael@0: // view displays the right url michael@0: add_test(function() { michael@0: Services.prefs.clearUserPref("extensions.addon2@tests.mozilla.org.getAddons.cache.enabled"); michael@0: Services.prefs.setBoolPref("extensions.addon3@tests.mozilla.org.getAddons.cache.enabled", false); michael@0: michael@0: open_manager(null, function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: gCategoryUtilities.openType("extension", function() { michael@0: close_manager(gManagerWindow, function() { michael@0: open_manager("addons://discover/", function(aWindow) { michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: is(gCategoryUtilities.selectedCategory, "discover", "Should have loaded the right view"); michael@0: michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: testHash(browser, [true, true, false], function() { michael@0: Services.prefs.clearUserPref("extensions.addon3@tests.mozilla.org.getAddons.cache.enabled"); michael@0: close_manager(gManagerWindow, run_next_test); michael@0: }); michael@0: }, function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: ok(isLoading(), "Should be loading at first"); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that switching to the discovery view displays the right url michael@0: add_test(function() { michael@0: Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false); michael@0: michael@0: open_manager("addons://list/extension", function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: michael@0: gCategoryUtilities.openType("discover", function() { michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: is(getHash(browser), null, "Hash should not have been passed"); michael@0: close_manager(gManagerWindow, run_next_test); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that loading the add-ons manager with the discovery view as the last michael@0: // selected view displays the right url michael@0: add_test(function() { michael@0: open_manager(null, function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: is(gCategoryUtilities.selectedCategory, "discover", "Should have loaded the right view"); michael@0: michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: is(getHash(browser), null, "Hash should not have been passed"); michael@0: close_manager(gManagerWindow, run_next_test); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that loading the add-ons manager with the discovery view as the initial michael@0: // view displays the right url michael@0: add_test(function() { michael@0: open_manager(null, function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: gCategoryUtilities.openType("extension", function() { michael@0: close_manager(gManagerWindow, function() { michael@0: open_manager("addons://discover/", function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: is(gCategoryUtilities.selectedCategory, "discover", "Should have loaded the right view"); michael@0: michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: is(getHash(browser), null, "Hash should not have been passed"); michael@0: close_manager(gManagerWindow, run_next_test); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that navigating to an insecure page fails michael@0: add_test(function() { michael@0: open_manager("addons://discover/", function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: clickLink("link-http", function() { michael@0: ok(isError(), "Should have shown the error page"); michael@0: michael@0: gCategoryUtilities.openType("extension", function() { michael@0: gCategoryUtilities.openType("discover", function() { michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: close_manager(gManagerWindow, run_next_test); michael@0: }); michael@0: ok(isLoading(), "Should start loading again"); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that navigating to a different domain fails michael@0: add_test(function() { michael@0: open_manager("addons://discover/", function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: clickLink("link-domain", function() { michael@0: ok(isError(), "Should have shown the error page"); michael@0: michael@0: gCategoryUtilities.openType("extension", function() { michael@0: gCategoryUtilities.openType("discover", function() { michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: close_manager(gManagerWindow, run_next_test); michael@0: }); michael@0: ok(isLoading(), "Should start loading again"); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that navigating to a missing page fails michael@0: add_test(function() { michael@0: open_manager("addons://discover/", function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: clickLink("link-bad", function() { michael@0: ok(isError(), "Should have shown the error page"); michael@0: michael@0: gCategoryUtilities.openType("extension", function() { michael@0: gCategoryUtilities.openType("discover", function() { michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: close_manager(gManagerWindow, run_next_test); michael@0: }); michael@0: ok(isLoading(), "Should start loading again"); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that navigating to a page on the same domain works michael@0: add_test(function() { michael@0: open_manager("addons://discover/", function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: clickLink("link-good", function() { michael@0: is(getURL(browser), "https://example.com/" + RELATIVE_DIR + "releaseNotes.xhtml", "Should have loaded the right url"); michael@0: michael@0: gCategoryUtilities.openType("extension", function() { michael@0: gCategoryUtilities.openType("discover", function() { michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: close_manager(gManagerWindow, run_next_test); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests repeated navigation to the same page followed by a navigation to a michael@0: // different domain michael@0: add_test(function() { michael@0: open_manager("addons://discover/", function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: var count = 10; michael@0: function clickAgain(aCallback) { michael@0: if (count-- == 0) michael@0: aCallback(); michael@0: else michael@0: clickLink("link-normal", clickAgain.bind(null, aCallback)); michael@0: } michael@0: michael@0: clickAgain(function() { michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: clickLink("link-domain", function() { michael@0: ok(isError(), "Should have shown the error page"); michael@0: michael@0: gCategoryUtilities.openType("extension", function() { michael@0: gCategoryUtilities.openType("discover", function() { michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: close_manager(gManagerWindow, run_next_test); michael@0: }); michael@0: ok(isLoading(), "Should start loading again"); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Loading an insecure main page should work if that is what the prefs say, should michael@0: // also be able to navigate to a https page and back again michael@0: add_test(function() { michael@0: Services.prefs.setCharPref(PREF_DISCOVERURL, TESTROOT + "discovery.html"); michael@0: michael@0: open_manager("addons://discover/", function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: is(getURL(browser), TESTROOT + "discovery.html", "Should have loaded the right url"); michael@0: michael@0: clickLink("link-normal", function() { michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: clickLink("link-http", function() { michael@0: is(getURL(browser), TESTROOT + "discovery.html", "Should have loaded the right url"); michael@0: michael@0: close_manager(gManagerWindow, run_next_test); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Stopping the initial load should display the error page and then correctly michael@0: // reload when switching away and back again michael@0: add_test(function() { michael@0: Services.prefs.setCharPref(PREF_DISCOVERURL, MAIN_URL); michael@0: michael@0: open_manager("addons://list/extension", function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: michael@0: EventUtils.synthesizeMouse(gCategoryUtilities.get("discover"), 2, 2, { }, gManagerWindow); michael@0: michael@0: wait_for_view_load(gManagerWindow, function() { michael@0: ok(isError(), "Should have shown the error page"); michael@0: michael@0: gCategoryUtilities.openType("extension", function() { michael@0: EventUtils.synthesizeMouse(gCategoryUtilities.get("discover"), 2, 2, { }, gManagerWindow); michael@0: michael@0: wait_for_view_load(gManagerWindow, function() { michael@0: ok(isError(), "Should have shown the error page"); michael@0: michael@0: gCategoryUtilities.openType("extension", function() { michael@0: gCategoryUtilities.openType("discover", function() { michael@0: is(getURL(browser), MAIN_URL, "Should have loaded the right url"); michael@0: michael@0: close_manager(gManagerWindow, run_next_test); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: ok(isLoading(), "Should be loading"); michael@0: // This will stop the real page load michael@0: browser.stop(); michael@0: }); michael@0: }); michael@0: michael@0: ok(isLoading(), "Should be loading"); michael@0: // This will actually stop the about:blank load michael@0: browser.stop(); michael@0: }); michael@0: }); michael@0: michael@0: // Test for Bug 703929 - Loading the discover view from a chrome XUL file fails when michael@0: // the add-on manager is reopened. michael@0: add_test(function() { michael@0: const url = "chrome://mochitests/content/" + RELATIVE_DIR + "addon_about.xul"; michael@0: Services.prefs.setCharPref(PREF_DISCOVERURL, url); michael@0: michael@0: open_manager("addons://discover/", function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: is(getURL(browser), url, "Loading a chrome XUL file should work"); michael@0: michael@0: restart_manager(gManagerWindow, "addons://discover/", function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: is(getURL(browser), url, "Should be able to load the chrome XUL file a second time"); michael@0: michael@0: close_manager(gManagerWindow, run_next_test); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Bug 711693 - Send the compatibility mode when loading the Discovery pane michael@0: add_test(function() { michael@0: info("Test '%COMPATIBILITY_MODE%' in the URL is correctly replaced by 'normal'"); michael@0: Services.prefs.setCharPref(PREF_DISCOVERURL, MAIN_URL + "?mode=%COMPATIBILITY_MODE%"); michael@0: Services.prefs.setBoolPref(PREF_STRICT_COMPAT, false); michael@0: michael@0: open_manager("addons://discover/", function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: is(getURL(browser), MAIN_URL + "?mode=normal", "Should have loaded the right url"); michael@0: close_manager(gManagerWindow, run_next_test); michael@0: }); michael@0: }); michael@0: michael@0: add_test(function() { michael@0: info("Test '%COMPATIBILITY_MODE%' in the URL is correctly replaced by 'strict'"); michael@0: Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true); michael@0: michael@0: open_manager("addons://discover/", function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: is(getURL(browser), MAIN_URL + "?mode=strict", "Should have loaded the right url"); michael@0: close_manager(gManagerWindow, run_next_test); michael@0: }); michael@0: }); michael@0: michael@0: add_test(function() { michael@0: info("Test '%COMPATIBILITY_MODE%' in the URL is correctly replaced by 'ignore'"); michael@0: Services.prefs.setBoolPref(PREF_CHECK_COMPATIBILITY, false); michael@0: michael@0: open_manager("addons://discover/", function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: var browser = gManagerWindow.document.getElementById("discover-browser"); michael@0: is(getURL(browser), MAIN_URL + "?mode=ignore", "Should have loaded the right url"); michael@0: close_manager(gManagerWindow, run_next_test); michael@0: }); michael@0: }); michael@0: michael@0: // Test for Bug 601442 - extensions.getAddons.showPane need to be update michael@0: // for the new addon manager. michael@0: function bug_601442_test_elements(visible) { michael@0: open_manager("addons://list/extension", function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: if(visible) michael@0: ok(gCategoryUtilities.isTypeVisible("discover"), "Discover category should be visible"); michael@0: else michael@0: ok(!gCategoryUtilities.isTypeVisible("discover"), "Discover category should not be visible"); michael@0: michael@0: gManagerWindow.loadView("addons://list/dictionary"); michael@0: wait_for_view_load(gManagerWindow, function(aManager) { michael@0: var button = aManager.document.getElementById("discover-button-install"); michael@0: if(visible) michael@0: ok(!is_hidden(button), "Discover button should be visible!"); michael@0: else michael@0: ok(is_hidden(button), "Discover button should not be visible!"); michael@0: michael@0: close_manager(gManagerWindow, run_next_test); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: add_test(function() { michael@0: Services.prefs.setBoolPref(PREF_DISCOVER_ENABLED, false); michael@0: Services.prefs.setBoolPref(PREF_XPI_ENABLED, true); michael@0: bug_601442_test_elements(false); michael@0: }); michael@0: add_test(function() { michael@0: Services.prefs.setBoolPref(PREF_DISCOVER_ENABLED, true); michael@0: Services.prefs.setBoolPref(PREF_XPI_ENABLED, false); michael@0: bug_601442_test_elements(false); michael@0: }); michael@0: add_test(function() { michael@0: Services.prefs.setBoolPref(PREF_DISCOVER_ENABLED, false); michael@0: Services.prefs.setBoolPref(PREF_XPI_ENABLED, false); michael@0: bug_601442_test_elements(false); michael@0: }); michael@0: add_test(function() { michael@0: Services.prefs.setBoolPref(PREF_DISCOVER_ENABLED, true); michael@0: Services.prefs.setBoolPref(PREF_XPI_ENABLED, true); michael@0: bug_601442_test_elements(true); michael@0: });