зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1337627 - Remove remote discovery pane from about:addons r=robwu,fluent-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D55719 --HG-- rename : browser/base/content/test/general/browser_bug581242.js => browser/base/content/test/webextensions/browser_aboutaddons_blanktab.js extra : moz-landing-system : lando
This commit is contained in:
Родитель
0a677b0f34
Коммит
749ba15c52
|
@ -43,9 +43,6 @@ pref("extensions.getAddons.link.url", "https://addons.mozilla.org/%LOCALE%/firef
|
|||
pref("extensions.getAddons.langpacks.url", "https://services.addons.mozilla.org/api/v3/addons/language-tools/?app=firefox&type=language&appversion=%VERSION%");
|
||||
pref("extensions.getAddons.discovery.api_url", "https://services.addons.mozilla.org/api/v4/discovery/?lang=%LOCALE%&edition=%DISTRIBUTION%");
|
||||
|
||||
// Enable the HTML-based discovery panel at about:addons.
|
||||
pref("extensions.htmlaboutaddons.discover.enabled", true);
|
||||
|
||||
// The URL for the privacy policy related to recommended extensions.
|
||||
pref("extensions.recommendations.privacyPolicyUrl", "https://www.mozilla.org/privacy/firefox/?utm_source=firefox-browser&utm_medium=firefox-browser&utm_content=privacy-policy-link#addons");
|
||||
// The URL for Firefox Color, recommended on the theme page in about:addons.
|
||||
|
|
|
@ -159,8 +159,6 @@ skip-if = (os == "mac") #Bug 1526628
|
|||
[browser_bug579872.js]
|
||||
skip-if = (verify && debug && (os == 'linux')) || (os == 'mac') || (os == 'linux' && !debug) #Bug 1448915
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_bug581242.js]
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_bug581253.js]
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_bug585785.js]
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
function test() {
|
||||
// Create a new tab and load about:addons
|
||||
let blanktab = BrowserTestUtils.addTab(gBrowser);
|
||||
gBrowser.selectedTab = blanktab;
|
||||
BrowserOpenAddonsMgr();
|
||||
|
||||
is(blanktab, gBrowser.selectedTab, "Current tab should be blank tab");
|
||||
// Verify that about:addons loads
|
||||
waitForExplicitFinish();
|
||||
gBrowser.selectedBrowser.addEventListener(
|
||||
"load",
|
||||
function() {
|
||||
let browser = blanktab.linkedBrowser;
|
||||
is(
|
||||
browser.currentURI.spec,
|
||||
"about:addons",
|
||||
"about:addons should load into blank tab."
|
||||
);
|
||||
gBrowser.removeTab(blanktab);
|
||||
finish();
|
||||
},
|
||||
{ capture: true, once: true }
|
||||
);
|
||||
}
|
|
@ -16,6 +16,7 @@ support-files =
|
|||
browser_webext_update_origins2.xpi
|
||||
browser_webext_update.json
|
||||
|
||||
[browser_aboutaddons_blanktab.js]
|
||||
[browser_extension_sideloading.js]
|
||||
[browser_extension_update_background.js]
|
||||
[browser_extension_update_background_noprompt.js]
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
add_task(async function testBlankTabReusedAboutAddons() {
|
||||
await BrowserTestUtils.withNewTab({ gBrowser }, async browser => {
|
||||
let tabCount = gBrowser.tabs.length;
|
||||
is(browser, gBrowser.selectedBrowser, "New tab is selected");
|
||||
|
||||
// Opening about:addons shouldn't change the selected tab.
|
||||
BrowserOpenAddonsMgr();
|
||||
|
||||
is(browser, gBrowser.selectedBrowser, "No new tab was opened");
|
||||
|
||||
// Wait for about:addons to load.
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
||||
is(
|
||||
browser.currentURI.spec,
|
||||
"about:addons",
|
||||
"about:addons should load into blank tab."
|
||||
);
|
||||
|
||||
is(gBrowser.tabs.length, tabCount, "Still the same number of tabs");
|
||||
});
|
||||
});
|
|
@ -13,9 +13,6 @@ search-header =
|
|||
search-header-shortcut =
|
||||
.key = f
|
||||
|
||||
loading-label =
|
||||
.value = Loading…
|
||||
|
||||
list-empty-installed =
|
||||
.value = You don’t have any add-ons of this type installed
|
||||
|
||||
|
@ -82,17 +79,6 @@ cmd-contribute =
|
|||
.accesskey = C
|
||||
.tooltiptext = Contribute to the development of this add-on
|
||||
|
||||
discover-title = What are Add-ons?
|
||||
|
||||
discover-description =
|
||||
Add-ons are applications that let you personalize { -brand-short-name } with
|
||||
extra functionality or style. Try a time-saving sidebar, a weather notifier, or a themed look to make { -brand-short-name }
|
||||
your own.
|
||||
|
||||
discover-footer =
|
||||
When you’re connected to the internet, this pane will feature
|
||||
some of the best and most popular add-ons for you to try out.
|
||||
|
||||
detail-version =
|
||||
.label = Version
|
||||
|
||||
|
|
|
@ -18,16 +18,6 @@ ChromeUtils.defineModuleGetter(
|
|||
"AMTelemetry",
|
||||
"resource://gre/modules/AddonManager.jsm"
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"ClientID",
|
||||
"resource://gre/modules/ClientID.jsm"
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"PrivateBrowsingUtils",
|
||||
"resource://gre/modules/PrivateBrowsingUtils.jsm"
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
|
@ -36,17 +26,7 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
|||
true
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"useHtmlDiscover",
|
||||
"extensions.htmlaboutaddons.discover.enabled"
|
||||
);
|
||||
|
||||
const PREF_DISCOVERURL = "extensions.webservice.discoverURL";
|
||||
const PREF_DISCOVER_ENABLED = "extensions.getAddons.showPane";
|
||||
const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled";
|
||||
const PREF_GETADDONS_CACHE_ID_ENABLED =
|
||||
"extensions.%ID%.getAddons.cache.enabled";
|
||||
const PREF_UI_TYPE_HIDDEN = "extensions.ui.%TYPE%.hidden";
|
||||
const PREF_UI_LASTCATEGORY = "extensions.ui.lastCategory";
|
||||
|
||||
|
@ -251,12 +231,6 @@ function loadView(aViewId) {
|
|||
}
|
||||
|
||||
function isDiscoverEnabled() {
|
||||
if (
|
||||
Services.prefs.getPrefType(PREF_DISCOVERURL) == Services.prefs.PREF_INVALID
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!Services.prefs.getBoolPref(PREF_DISCOVER_ENABLED)) {
|
||||
return false;
|
||||
|
@ -536,11 +510,10 @@ var gViewController = {
|
|||
// gUpdatesView still handles when the Available Updates category is
|
||||
// shown. Include it in viewObjects so it gets initialized and shutdown.
|
||||
this.viewObjects._availableUpdatesSidebar = gUpdatesView;
|
||||
this.viewObjects.discover = htmlView("discover");
|
||||
|
||||
if (useHtmlDiscover && isDiscoverEnabled()) {
|
||||
this.viewObjects.discover = htmlView("discover");
|
||||
} else {
|
||||
this.viewObjects.discover = gDiscoverView;
|
||||
if (!isDiscoverEnabled()) {
|
||||
gCategories.get("addons://discover/").hidden = true;
|
||||
}
|
||||
|
||||
for (let type in this.viewObjects) {
|
||||
|
@ -1052,345 +1025,6 @@ var gCategories = {
|
|||
// categories are in the XUL markup.
|
||||
gCategories._defineCustomElement();
|
||||
|
||||
var gDiscoverView = {
|
||||
node: null,
|
||||
enabled: true,
|
||||
// Set to true after the view is first shown. If initialization completes
|
||||
// after this then it must also load the discover homepage
|
||||
loaded: false,
|
||||
_browser: null,
|
||||
_loading: null,
|
||||
_error: null,
|
||||
homepageURL: null,
|
||||
_loadListeners: [],
|
||||
hideHeader: true,
|
||||
isRoot: true,
|
||||
|
||||
get clientIdDiscoveryEnabled() {
|
||||
// These prefs match Discovery.jsm for enabling clientId cookies.
|
||||
return (
|
||||
Services.prefs.getBoolPref(
|
||||
"datareporting.healthreport.uploadEnabled",
|
||||
false
|
||||
) &&
|
||||
Services.prefs.getBoolPref("browser.discovery.enabled", false) &&
|
||||
!PrivateBrowsingUtils.isContentWindowPrivate(window)
|
||||
);
|
||||
},
|
||||
|
||||
async getClientHeader() {
|
||||
if (!this.clientIdDiscoveryEnabled) {
|
||||
return undefined;
|
||||
}
|
||||
let clientId = await ClientID.getClientIdHash();
|
||||
|
||||
let stream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(
|
||||
Ci.nsISupportsCString
|
||||
);
|
||||
stream.data = `Moz-Client-Id: ${clientId}\r\n`;
|
||||
return stream;
|
||||
},
|
||||
|
||||
async initialize() {
|
||||
this.enabled = isDiscoverEnabled();
|
||||
if (!this.enabled) {
|
||||
gCategories.get("addons://discover/").hidden = true;
|
||||
return null;
|
||||
}
|
||||
|
||||
this.node = document.getElementById("discover-view");
|
||||
this._loading = document.getElementById("discover-loading");
|
||||
this._error = document.getElementById("discover-error");
|
||||
this._browser = document.getElementById("discover-browser");
|
||||
|
||||
let compatMode = "normal";
|
||||
if (!AddonManager.checkCompatibility) {
|
||||
compatMode = "ignore";
|
||||
} else if (AddonManager.strictCompatibility) {
|
||||
compatMode = "strict";
|
||||
}
|
||||
|
||||
var url = Services.prefs.getCharPref(PREF_DISCOVERURL);
|
||||
url = url.replace("%COMPATIBILITY_MODE%", compatMode);
|
||||
url = Services.urlFormatter.formatURL(url);
|
||||
|
||||
let setURL = async aURL => {
|
||||
try {
|
||||
this.homepageURL = Services.io.newURI(aURL);
|
||||
} catch (e) {
|
||||
this.showError();
|
||||
notifyInitialized();
|
||||
return;
|
||||
}
|
||||
|
||||
this._browser.addProgressListener(
|
||||
this,
|
||||
Ci.nsIWebProgress.NOTIFY_STATE_ALL |
|
||||
Ci.nsIWebProgress.NOTIFY_SECURITY |
|
||||
Ci.nsIWebProgress.NOTIFY_LOCATION
|
||||
);
|
||||
|
||||
if (this.loaded) {
|
||||
this._loadURL(
|
||||
this.homepageURL.spec,
|
||||
false,
|
||||
notifyInitialized,
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
await this.getClientHeader()
|
||||
);
|
||||
} else {
|
||||
notifyInitialized();
|
||||
}
|
||||
};
|
||||
|
||||
if (!Services.prefs.getBoolPref(PREF_GETADDONS_CACHE_ENABLED)) {
|
||||
return setURL(url);
|
||||
}
|
||||
|
||||
gPendingInitializations++;
|
||||
let aAddons = await AddonManager.getAddonsByTypes(["extension", "theme"]);
|
||||
var list = {};
|
||||
for (let addon of aAddons) {
|
||||
var prefName = PREF_GETADDONS_CACHE_ID_ENABLED.replace("%ID%", addon.id);
|
||||
try {
|
||||
if (!Services.prefs.getBoolPref(prefName)) {
|
||||
continue;
|
||||
}
|
||||
} catch (e) {}
|
||||
list[addon.id] = {
|
||||
name: addon.name,
|
||||
version: addon.version,
|
||||
type: addon.type,
|
||||
userDisabled: addon.userDisabled,
|
||||
isCompatible: addon.isCompatible,
|
||||
isBlocklisted:
|
||||
addon.blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED,
|
||||
};
|
||||
}
|
||||
|
||||
return setURL(url + "#" + JSON.stringify(list));
|
||||
},
|
||||
|
||||
destroy() {
|
||||
try {
|
||||
this._browser.removeProgressListener(this);
|
||||
} catch (e) {
|
||||
// Ignore the case when the listener wasn't already registered
|
||||
}
|
||||
},
|
||||
|
||||
async show(aParam, aRequest, aState, aIsRefresh) {
|
||||
// If we're being told to load a specific URL then just do that
|
||||
if (aState && "url" in aState) {
|
||||
this.loaded = true;
|
||||
this._loadURL(aState.url);
|
||||
}
|
||||
|
||||
// If the view has loaded before and still at the homepage (if refreshing),
|
||||
// and the error page is not visible then there is nothing else to do
|
||||
if (
|
||||
this.loaded &&
|
||||
this.node.selectedPanel != this._error &&
|
||||
(!aIsRefresh ||
|
||||
(this._browser.currentURI &&
|
||||
this._browser.currentURI.spec == this.homepageURL.spec))
|
||||
) {
|
||||
gViewController.notifyViewChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
this.loaded = true;
|
||||
|
||||
// No homepage means initialization isn't complete, the browser will get
|
||||
// loaded once initialization is complete
|
||||
if (!this.homepageURL) {
|
||||
this._loadListeners.push(
|
||||
gViewController.notifyViewChanged.bind(gViewController)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
this._loadURL(
|
||||
this.homepageURL.spec,
|
||||
aIsRefresh,
|
||||
gViewController.notifyViewChanged.bind(gViewController),
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
await this.getClientHeader()
|
||||
);
|
||||
},
|
||||
|
||||
canRefresh() {
|
||||
if (
|
||||
this._browser.currentURI &&
|
||||
this._browser.currentURI.spec == this.homepageURL.spec
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
refresh(aParam, aRequest, aState) {
|
||||
this.show(aParam, aRequest, aState, true);
|
||||
},
|
||||
|
||||
hide() {},
|
||||
|
||||
showError() {
|
||||
this.node.selectedPanel = this._error;
|
||||
},
|
||||
|
||||
_loadURL(aURL, aKeepHistory, aCallback, aPrincipal, headers) {
|
||||
if (this._browser.currentURI && this._browser.currentURI.spec == aURL) {
|
||||
if (aCallback) {
|
||||
aCallback();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (aCallback) {
|
||||
this._loadListeners.push(aCallback);
|
||||
}
|
||||
|
||||
var flags = 0;
|
||||
if (!aKeepHistory) {
|
||||
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY;
|
||||
}
|
||||
|
||||
this._browser.loadURI(aURL, {
|
||||
flags,
|
||||
triggeringPrincipal:
|
||||
aPrincipal || Services.scriptSecurityManager.createNullPrincipal({}),
|
||||
headers,
|
||||
});
|
||||
},
|
||||
|
||||
onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {
|
||||
// Ignore the about:blank load
|
||||
if (aLocation.spec == "about:blank") {
|
||||
return;
|
||||
}
|
||||
|
||||
// When using the real session history the inner-frame will update the
|
||||
// session history automatically, if using the fake history though it must
|
||||
// be manually updated
|
||||
if (gHistory == FakeHistory) {
|
||||
var docshell = aWebProgress.QueryInterface(Ci.nsIDocShell);
|
||||
|
||||
var state = {
|
||||
view: "addons://discover/",
|
||||
url: aLocation.spec,
|
||||
};
|
||||
|
||||
var replaceHistory = Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY << 16;
|
||||
if (docshell.loadType & replaceHistory) {
|
||||
gHistory.replaceState(state);
|
||||
} else {
|
||||
gHistory.pushState(state);
|
||||
}
|
||||
gViewController.lastHistoryIndex = gHistory.index;
|
||||
}
|
||||
|
||||
// If the hostname is the same as the new location's host and either the
|
||||
// default scheme is insecure or the new location is secure then continue
|
||||
// with the load
|
||||
if (
|
||||
aLocation.host == this.homepageURL.host &&
|
||||
(!this.homepageURL.schemeIs("https") || aLocation.schemeIs("https"))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Canceling the request will send an error to onStateChange which will show
|
||||
// the error page
|
||||
aRequest.cancel(Cr.NS_BINDING_ABORTED);
|
||||
},
|
||||
|
||||
onSecurityChange(aWebProgress, aRequest, aState) {
|
||||
// Don't care about security if the page is not https
|
||||
if (!this.homepageURL.schemeIs("https")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the request was secure then it is ok
|
||||
if (aState & Ci.nsIWebProgressListener.STATE_IS_SECURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Canceling the request will send an error to onStateChange which will show
|
||||
// the error page
|
||||
aRequest.cancel(Cr.NS_BINDING_ABORTED);
|
||||
},
|
||||
|
||||
onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
|
||||
let transferStart =
|
||||
Ci.nsIWebProgressListener.STATE_IS_DOCUMENT |
|
||||
Ci.nsIWebProgressListener.STATE_IS_REQUEST |
|
||||
Ci.nsIWebProgressListener.STATE_TRANSFERRING;
|
||||
// Once transferring begins show the content
|
||||
if ((aStateFlags & transferStart) === transferStart) {
|
||||
this.node.selectedPanel = this._browser;
|
||||
}
|
||||
|
||||
// Only care about the network events
|
||||
if (!(aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If this is the start of network activity then show the loading page
|
||||
if (aStateFlags & Ci.nsIWebProgressListener.STATE_START) {
|
||||
this.node.selectedPanel = this._loading;
|
||||
}
|
||||
|
||||
// Ignore anything except stop events
|
||||
if (!(aStateFlags & Ci.nsIWebProgressListener.STATE_STOP)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Consider the successful load of about:blank as still loading
|
||||
if (
|
||||
aRequest instanceof Ci.nsIChannel &&
|
||||
aRequest.URI.spec == "about:blank"
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If there was an error loading the page or the new hostname is not the
|
||||
// same as the default hostname or the default scheme is secure and the new
|
||||
// scheme is insecure then show the error page
|
||||
const NS_ERROR_PARSED_DATA_CACHED = 0x805d0021;
|
||||
if (
|
||||
!(
|
||||
Components.isSuccessCode(aStatus) ||
|
||||
aStatus == NS_ERROR_PARSED_DATA_CACHED
|
||||
) ||
|
||||
(aRequest &&
|
||||
aRequest instanceof Ci.nsIHttpChannel &&
|
||||
!aRequest.requestSucceeded)
|
||||
) {
|
||||
this.showError();
|
||||
} else {
|
||||
// Got a successful load, make sure the browser is visible
|
||||
this.node.selectedPanel = this._browser;
|
||||
}
|
||||
|
||||
var listeners = this._loadListeners;
|
||||
this._loadListeners = [];
|
||||
|
||||
for (let listener of listeners) {
|
||||
listener();
|
||||
}
|
||||
},
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI([
|
||||
Ci.nsIWebProgressListener,
|
||||
Ci.nsISupportsWeakReference,
|
||||
]),
|
||||
|
||||
getSelectedAddon() {
|
||||
return null;
|
||||
},
|
||||
};
|
||||
|
||||
var gUpdatesView = {
|
||||
_categoryItem: null,
|
||||
isRoot: true,
|
||||
|
|
|
@ -82,37 +82,6 @@
|
|||
<vbox class="main-content" flex="1">
|
||||
<!-- view port -->
|
||||
<deck id="view-port" flex="1" selectedIndex="0">
|
||||
<!-- discover view -->
|
||||
<deck id="discover-view" flex="1" class="view-pane" selectedIndex="0">
|
||||
<vbox id="discover-loading" align="center" pack="stretch" flex="1" class="alert-container">
|
||||
<spacer class="alert-spacer-before"/>
|
||||
<hbox class="alert loading" align="center">
|
||||
<image/>
|
||||
<label data-l10n-id="loading-label"/>
|
||||
</hbox>
|
||||
<spacer class="alert-spacer-after"/>
|
||||
</vbox>
|
||||
<vbox id="discover-error" align="center" pack="stretch" flex="1" class="alert-container">
|
||||
<spacer class="alert-spacer-before"/>
|
||||
<hbox>
|
||||
<spacer class="discover-spacer-before"/>
|
||||
<vbox class="alert" align="center">
|
||||
<image class="discover-logo"/>
|
||||
<vbox flex="1" align="stretch">
|
||||
<label class="discover-title" data-l10n-id="discover-title"></label>
|
||||
<description class="discover-description" data-l10n-id="discover-description"></description>
|
||||
<description class="discover-footer" data-l10n-id="discover-footer"></description>
|
||||
</vbox>
|
||||
</vbox>
|
||||
<spacer class="discover-spacer-after"/>
|
||||
</hbox>
|
||||
<spacer class="alert-spacer-after"/>
|
||||
</vbox>
|
||||
|
||||
<browser id="discover-browser" type="content" flex="1"
|
||||
disablehistory="true"/>
|
||||
</deck>
|
||||
|
||||
<!-- container for views with the search/tools header -->
|
||||
<vbox id="headered-views" flex="1">
|
||||
<deck id="headered-views-content" flex="1" selectedIndex="0">
|
||||
|
|
|
@ -14,13 +14,9 @@ support-files =
|
|||
discovery/api_response.json
|
||||
discovery/api_response_empty.json
|
||||
discovery/small-1x1.png
|
||||
discovery.html
|
||||
head.js
|
||||
more_options.xhtml
|
||||
options.xhtml
|
||||
plugin_test.html
|
||||
redirect.sjs
|
||||
releaseNotes.xhtml
|
||||
blockNoPlugins.xml
|
||||
blockPluginHard.xml
|
||||
browser_updatessl.json
|
||||
|
@ -58,7 +54,6 @@ skip-if = (!debug && os == 'win') #Bug 1489496
|
|||
skip-if = os == "linux" && !debug # Bug 1395539 - fails on multi-core
|
||||
[browser_bug679604.js]
|
||||
[browser_checkAddonCompatibility.js]
|
||||
[browser_discovery.js]
|
||||
[browser_dragdrop.js]
|
||||
[browser_extension_sideloading_permission.js]
|
||||
[browser_file_xpi_no_process_switch.js]
|
||||
|
|
|
@ -1,606 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Tests that the discovery view loads properly
|
||||
|
||||
const MAIN_URL = "https://example.com/" + RELATIVE_DIR + "discovery.html";
|
||||
|
||||
var gManagerWindow;
|
||||
var gCategoryUtilities;
|
||||
var gProvider;
|
||||
|
||||
var gLoadCompleteCallback = null;
|
||||
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.htmlaboutaddons.discover.enabled", false]],
|
||||
});
|
||||
|
||||
var gProgressListener = {
|
||||
onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
|
||||
// Only care about the network stop status events
|
||||
if (
|
||||
!(aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) ||
|
||||
!(aStateFlags & Ci.nsIWebProgressListener.STATE_STOP)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (gLoadCompleteCallback) {
|
||||
executeSoon(gLoadCompleteCallback);
|
||||
}
|
||||
gLoadCompleteCallback = null;
|
||||
},
|
||||
|
||||
onLocationChange() {},
|
||||
onSecurityChange() {},
|
||||
onProgressChange() {},
|
||||
onStatusChange() {},
|
||||
onContentBlockingEvent() {},
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI([
|
||||
Ci.nsIWebProgressListener,
|
||||
Ci.nsISupportsWeakReference,
|
||||
]),
|
||||
};
|
||||
|
||||
function test() {
|
||||
// Switch to a known url
|
||||
Services.prefs.setCharPref(PREF_DISCOVERURL, MAIN_URL);
|
||||
// Temporarily enable caching
|
||||
Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
gProvider = new MockProvider();
|
||||
|
||||
gProvider.createAddons([
|
||||
{
|
||||
id: "addon1@tests.mozilla.org",
|
||||
name: "Test add-on 1",
|
||||
type: "extension",
|
||||
version: "2.2",
|
||||
isCompatible: false,
|
||||
blocklistState: Ci.nsIBlocklistService.STATE_SOFTBLOCKED,
|
||||
userDisabled: false,
|
||||
},
|
||||
{
|
||||
id: "addon3@tests.mozilla.org",
|
||||
name: "Test add-on 3",
|
||||
type: "theme",
|
||||
version: "1.2b1",
|
||||
isCompatible: false,
|
||||
blocklistState: Ci.nsIBlocklistService.STATE_BLOCKED,
|
||||
userDisabled: true,
|
||||
},
|
||||
]);
|
||||
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
finish();
|
||||
}
|
||||
|
||||
function getURL(aBrowser) {
|
||||
if (
|
||||
gManagerWindow.document.getElementById("discover-view").selectedPanel !=
|
||||
aBrowser
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var url = aBrowser.currentURI.spec;
|
||||
var pos = url.indexOf("#");
|
||||
if (pos != -1) {
|
||||
return url.substring(0, pos);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
function getHash(aBrowser) {
|
||||
if (
|
||||
gManagerWindow.document.getElementById("discover-view").selectedPanel !=
|
||||
aBrowser
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var url = aBrowser.currentURI.spec;
|
||||
var pos = url.indexOf("#");
|
||||
if (pos != -1) {
|
||||
return decodeURIComponent(url.substring(pos + 1));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async function testHash(aBrowser, aTestAddonVisible) {
|
||||
var hash = getHash(aBrowser);
|
||||
isnot(hash, null, "There should be a hash");
|
||||
try {
|
||||
var data = JSON.parse(hash);
|
||||
} catch (e) {
|
||||
ok(false, "Hash should have been valid JSON: " + e);
|
||||
return;
|
||||
}
|
||||
is(typeof data, "object", "Hash should be a JS object");
|
||||
|
||||
// Ensure that at least the test add-ons are present
|
||||
if (aTestAddonVisible[0]) {
|
||||
ok("addon1@tests.mozilla.org" in data, "Test add-on 1 should be listed");
|
||||
} else {
|
||||
ok(
|
||||
!("addon1@tests.mozilla.org" in data),
|
||||
"Test add-on 1 should not be listed"
|
||||
);
|
||||
}
|
||||
if (aTestAddonVisible[1]) {
|
||||
ok("addon3@tests.mozilla.org" in data, "Test add-on 3 should be listed");
|
||||
} else {
|
||||
ok(
|
||||
!("addon3@tests.mozilla.org" in data),
|
||||
"Test add-on 3 should not be listed"
|
||||
);
|
||||
}
|
||||
|
||||
// Test against all the add-ons the manager knows about since plugins and
|
||||
// app extensions may exist
|
||||
let aAddons = await AddonManager.getAddonsByTypes(["extension", "theme"]);
|
||||
for (let addon of aAddons) {
|
||||
if (!(addon.id in data)) {
|
||||
// Test add-ons will have shown an error if necessary above
|
||||
if (addon.id.substring(6) != "@tests.mozilla.org") {
|
||||
ok(false, "Add-on " + addon.id + " was not included in the data");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
info("Testing data for add-on " + addon.id);
|
||||
var addonData = data[addon.id];
|
||||
is(addonData.name, addon.name, "Name should be correct");
|
||||
is(addonData.version, addon.version, "Version should be correct");
|
||||
is(addonData.type, addon.type, "Type should be correct");
|
||||
is(
|
||||
addonData.userDisabled,
|
||||
addon.userDisabled,
|
||||
"userDisabled should be correct"
|
||||
);
|
||||
is(
|
||||
addonData.isBlocklisted,
|
||||
addon.blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED,
|
||||
"blocklisted should be correct"
|
||||
);
|
||||
is(
|
||||
addonData.isCompatible,
|
||||
addon.isCompatible,
|
||||
"isCompatible should be correct"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function isLoading() {
|
||||
var loading =
|
||||
gManagerWindow.document.getElementById("discover-view").selectedPanel ==
|
||||
gManagerWindow.document.getElementById("discover-loading");
|
||||
if (loading) {
|
||||
is_element_visible(
|
||||
gManagerWindow.document.querySelector("#discover-loading .loading"),
|
||||
"Loading message should be visible when its panel is the selected panel"
|
||||
);
|
||||
}
|
||||
return loading;
|
||||
}
|
||||
|
||||
function isError() {
|
||||
return (
|
||||
gManagerWindow.document.getElementById("discover-view").selectedPanel ==
|
||||
gManagerWindow.document.getElementById("discover-error")
|
||||
);
|
||||
}
|
||||
|
||||
function clickLink(aId, aCallback) {
|
||||
let promise = new Promise(resolve => {
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
browser.addProgressListener(gProgressListener);
|
||||
|
||||
gLoadCompleteCallback = function() {
|
||||
browser.removeProgressListener(gProgressListener);
|
||||
resolve();
|
||||
};
|
||||
|
||||
var link = browser.contentDocument.getElementById(aId);
|
||||
EventUtils.sendMouseEvent({ type: "click" }, link);
|
||||
|
||||
executeSoon(function() {
|
||||
ok(isLoading(), "Clicking link " + aId + " should show the loading pane");
|
||||
});
|
||||
});
|
||||
if (aCallback) {
|
||||
promise.then(aCallback);
|
||||
}
|
||||
return promise;
|
||||
}
|
||||
|
||||
// Tests that switching to the discovery view displays the right url
|
||||
add_test(async function() {
|
||||
let aWindow = await open_manager("addons://list/extension");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
await gCategoryUtilities.openType("discover");
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
await testHash(browser, [true, true]);
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Tests that loading the add-ons manager with the discovery view as the last
|
||||
// selected view displays the right url
|
||||
add_test(async function() {
|
||||
// Hide one of the test add-ons
|
||||
Services.prefs.setBoolPref(
|
||||
"extensions.addon3@tests.mozilla.org.getAddons.cache.enabled",
|
||||
false
|
||||
);
|
||||
await open_manager(null, null, function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
ok(isLoading(), "Should be loading at first");
|
||||
});
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"discover",
|
||||
"Should have loaded the right view"
|
||||
);
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
await testHash(browser, [true, false]);
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Tests that loading the add-ons manager with the discovery view as the initial
|
||||
// view displays the right url
|
||||
add_test(async function() {
|
||||
Services.prefs.clearUserPref(
|
||||
"extensions.addon3@tests.mozilla.org.getAddons.cache.enabled"
|
||||
);
|
||||
let aWindow = await open_manager(null);
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
await gCategoryUtilities.openType("extension");
|
||||
await close_manager(gManagerWindow);
|
||||
aWindow = await open_manager("addons://discover/", null, function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
ok(isLoading(), "Should be loading at first");
|
||||
});
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"discover",
|
||||
"Should have loaded the right view"
|
||||
);
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
await testHash(browser, [true, true]);
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Tests that switching to the discovery view displays the right url
|
||||
add_test(async function() {
|
||||
Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false);
|
||||
|
||||
let aWindow = await open_manager("addons://list/extension");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
await gCategoryUtilities.openType("discover");
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
is(getHash(browser), null, "Hash should not have been passed");
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Tests that loading the add-ons manager with the discovery view as the last
|
||||
// selected view displays the right url
|
||||
add_test(async function() {
|
||||
let aWindow = await open_manager(null);
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"discover",
|
||||
"Should have loaded the right view"
|
||||
);
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
is(getHash(browser), null, "Hash should not have been passed");
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Tests that loading the add-ons manager with the discovery view as the initial
|
||||
// view displays the right url
|
||||
add_test(async function() {
|
||||
let aWindow = await open_manager(null);
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
await gCategoryUtilities.openType("extension");
|
||||
await close_manager(gManagerWindow);
|
||||
aWindow = await open_manager("addons://discover/");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"discover",
|
||||
"Should have loaded the right view"
|
||||
);
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
is(getHash(browser), null, "Hash should not have been passed");
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Tests that navigating to a page on the same domain works
|
||||
add_test(async function() {
|
||||
let aWindow = await open_manager("addons://discover/");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
await clickLink("link-good");
|
||||
is(
|
||||
getURL(browser),
|
||||
"https://example.com/" + RELATIVE_DIR + "releaseNotes.xhtml",
|
||||
"Should have loaded the right url"
|
||||
);
|
||||
|
||||
await gCategoryUtilities.openType("extension");
|
||||
await gCategoryUtilities.openType("discover");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Loading an insecure main page should work if that is what the prefs say, should
|
||||
// also be able to navigate to a https page and back again
|
||||
add_test(async function() {
|
||||
Services.prefs.setCharPref(PREF_DISCOVERURL, TESTROOT + "discovery.html");
|
||||
|
||||
let aWindow = await open_manager("addons://discover/");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(
|
||||
getURL(browser),
|
||||
TESTROOT + "discovery.html",
|
||||
"Should have loaded the right url"
|
||||
);
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Stopping the initial load should display the error page and then correctly
|
||||
// reload when switching away and back again
|
||||
add_test(async function() {
|
||||
Services.prefs.setCharPref(PREF_DISCOVERURL, MAIN_URL);
|
||||
|
||||
let aWindow = await open_manager("addons://list/extension");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
|
||||
EventUtils.synthesizeMouse(
|
||||
gCategoryUtilities.get("discover"),
|
||||
2,
|
||||
2,
|
||||
{},
|
||||
gManagerWindow
|
||||
);
|
||||
|
||||
// Do this after wait_for_view_load has had a chance to setup its
|
||||
// listeners.
|
||||
executeSoon(() => {
|
||||
ok(isLoading(), "Should be loading");
|
||||
// This will actually stop the about:blank load
|
||||
browser.stop();
|
||||
});
|
||||
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
ok(isError(), "Should have shown the error page");
|
||||
|
||||
await gCategoryUtilities.openType("extension");
|
||||
EventUtils.synthesizeMouse(
|
||||
gCategoryUtilities.get("discover"),
|
||||
2,
|
||||
2,
|
||||
{},
|
||||
gManagerWindow
|
||||
);
|
||||
|
||||
// Do this after wait_for_view_load has had a chance to setup its
|
||||
// listeners.
|
||||
executeSoon(() => {
|
||||
ok(isLoading(), "Should be loading");
|
||||
// This will actually stop the about:blank load
|
||||
browser.stop();
|
||||
});
|
||||
|
||||
await wait_for_view_load(gManagerWindow);
|
||||
ok(isError(), "Should have shown the error page");
|
||||
|
||||
await gCategoryUtilities.openType("extension");
|
||||
await gCategoryUtilities.openType("discover");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Test for Bug 703929 - Loading the discover view from a chrome XUL file fails when
|
||||
// the add-on manager is reopened.
|
||||
add_test(async function() {
|
||||
const url =
|
||||
"chrome://mochitests/content/" + RELATIVE_DIR + "addon_prefs.xhtml";
|
||||
Services.prefs.setCharPref(PREF_DISCOVERURL, url);
|
||||
|
||||
let aWindow = await open_manager("addons://discover/");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), url, "Loading a chrome XUL file should work");
|
||||
|
||||
aWindow = await restart_manager(gManagerWindow, "addons://discover/");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(
|
||||
getURL(browser),
|
||||
url,
|
||||
"Should be able to load the chrome XUL file a second time"
|
||||
);
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Bug 711693 - Send the compatibility mode when loading the Discovery pane
|
||||
add_test(async function() {
|
||||
info(
|
||||
"Test '%COMPATIBILITY_MODE%' in the URL is correctly replaced by 'normal'"
|
||||
);
|
||||
Services.prefs.setCharPref(
|
||||
PREF_DISCOVERURL,
|
||||
MAIN_URL + "?mode=%COMPATIBILITY_MODE%"
|
||||
);
|
||||
Services.prefs.setBoolPref(PREF_STRICT_COMPAT, false);
|
||||
|
||||
let aWindow = await open_manager("addons://discover/");
|
||||
gManagerWindow = aWindow;
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(
|
||||
getURL(browser),
|
||||
MAIN_URL + "?mode=normal",
|
||||
"Should have loaded the right url"
|
||||
);
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
add_test(async function() {
|
||||
info(
|
||||
"Test '%COMPATIBILITY_MODE%' in the URL is correctly replaced by 'strict'"
|
||||
);
|
||||
Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true);
|
||||
|
||||
let aWindow = await open_manager("addons://discover/");
|
||||
gManagerWindow = aWindow;
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(
|
||||
getURL(browser),
|
||||
MAIN_URL + "?mode=strict",
|
||||
"Should have loaded the right url"
|
||||
);
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
add_test(async function() {
|
||||
info(
|
||||
"Test '%COMPATIBILITY_MODE%' in the URL is correctly replaced by 'ignore'"
|
||||
);
|
||||
Services.prefs.setBoolPref(PREF_CHECK_COMPATIBILITY, false);
|
||||
|
||||
let aWindow = await open_manager("addons://discover/");
|
||||
gManagerWindow = aWindow;
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(
|
||||
getURL(browser),
|
||||
MAIN_URL + "?mode=ignore",
|
||||
"Should have loaded the right url"
|
||||
);
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
|
||||
// Test for Bug 601442 - extensions.getAddons.showPane need to be update
|
||||
// for the new addon manager.
|
||||
async function bug_601442_test_elements(visible) {
|
||||
let aWindow = await open_manager("addons://list/extension");
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
if (visible) {
|
||||
ok(
|
||||
gCategoryUtilities.isTypeVisible("discover"),
|
||||
"Discover category should be visible"
|
||||
);
|
||||
} else {
|
||||
ok(
|
||||
!gCategoryUtilities.isTypeVisible("discover"),
|
||||
"Discover category should not be visible"
|
||||
);
|
||||
}
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
}
|
||||
|
||||
add_test(function() {
|
||||
Services.prefs.setBoolPref(PREF_DISCOVER_ENABLED, false);
|
||||
Services.prefs.setBoolPref(PREF_XPI_ENABLED, true);
|
||||
bug_601442_test_elements(false);
|
||||
});
|
||||
add_test(function() {
|
||||
Services.prefs.setBoolPref(PREF_DISCOVER_ENABLED, true);
|
||||
Services.prefs.setBoolPref(PREF_XPI_ENABLED, false);
|
||||
bug_601442_test_elements(false);
|
||||
});
|
||||
add_test(function() {
|
||||
Services.prefs.setBoolPref(PREF_DISCOVER_ENABLED, false);
|
||||
Services.prefs.setBoolPref(PREF_XPI_ENABLED, false);
|
||||
bug_601442_test_elements(false);
|
||||
});
|
||||
add_test(function() {
|
||||
Services.prefs.setBoolPref(PREF_DISCOVER_ENABLED, true);
|
||||
Services.prefs.setBoolPref(PREF_XPI_ENABLED, true);
|
||||
bug_601442_test_elements(true);
|
||||
});
|
||||
|
||||
// Test for Bug 1132971 - if extensions.getAddons.showPane is false,
|
||||
// the extensions pane should show by default
|
||||
add_test(async function() {
|
||||
Services.prefs.clearUserPref(PREF_UI_LASTCATEGORY);
|
||||
Services.prefs.setBoolPref(PREF_DISCOVER_ENABLED, false);
|
||||
|
||||
let aWindow = await open_manager(null);
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
is(
|
||||
gCategoryUtilities.selectedCategory,
|
||||
"extension",
|
||||
"Should be showing the extension view"
|
||||
);
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
Services.prefs.clearUserPref(PREF_DISCOVER_ENABLED);
|
||||
});
|
||||
|
||||
// Test for Bug 1219495 - should show placeholder content when offline
|
||||
add_test(async function() {
|
||||
// set a URL to cause an error
|
||||
Services.prefs.setCharPref(PREF_DISCOVERURL, "https://nocert.example.com/");
|
||||
|
||||
let aWindow = await open_manager("addons://discover/");
|
||||
gManagerWindow = aWindow;
|
||||
|
||||
ok(isError(), "Should have shown the placeholder content");
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
|
@ -114,36 +114,16 @@ function is_in_detail(aManager, view, canGoBack, canGoForward) {
|
|||
}
|
||||
|
||||
function is_in_discovery(aManager, url, canGoBack, canGoForward) {
|
||||
if (
|
||||
Services.prefs.getBoolPref("extensions.htmlaboutaddons.discover.enabled")
|
||||
) {
|
||||
is(
|
||||
get_current_view(aManager).id,
|
||||
"html-view",
|
||||
"the current view should be set to the HTML about:addons browser"
|
||||
);
|
||||
const doc = aManager.getHtmlBrowser().contentDocument;
|
||||
ok(
|
||||
doc.querySelector("discovery-pane"),
|
||||
"Got a discovery panel in the HTML about:addons browser"
|
||||
);
|
||||
} else {
|
||||
var browser = aManager.document.getElementById("discover-browser");
|
||||
|
||||
is(
|
||||
aManager.document.getElementById("discover-view").selectedPanel,
|
||||
browser,
|
||||
"Browser should be visible"
|
||||
);
|
||||
|
||||
var spec = browser.currentURI.spec;
|
||||
var pos = spec.indexOf("#");
|
||||
if (pos != -1) {
|
||||
spec = spec.substring(0, pos);
|
||||
}
|
||||
|
||||
is(spec, url, "Should have loaded the right url");
|
||||
}
|
||||
is(
|
||||
get_current_view(aManager).id,
|
||||
"html-view",
|
||||
"the current view should be set to the HTML about:addons browser"
|
||||
);
|
||||
const doc = aManager.getHtmlBrowser().contentDocument;
|
||||
ok(
|
||||
doc.querySelector("discovery-pane"),
|
||||
"Got a discovery panel in the HTML about:addons browser"
|
||||
);
|
||||
|
||||
check_state(canGoBack, canGoForward);
|
||||
}
|
||||
|
@ -570,10 +550,7 @@ add_task(async function test_open_last_view() {
|
|||
// Tests that navigating the discovery page works when that was the first view
|
||||
add_task(async function test_discopane_first_history_entry() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.discover.enabled", true],
|
||||
["extensions.getAddons.discovery.api_url", DISCOAPI_URL],
|
||||
],
|
||||
set: [["extensions.getAddons.discovery.api_url", DISCOAPI_URL]],
|
||||
});
|
||||
|
||||
let aManager = await open_manager("addons://discover/");
|
||||
|
|
|
@ -294,7 +294,6 @@ add_task(async function setup() {
|
|||
"extensions.getAddons.discovery.api_url",
|
||||
`http://${AMO_TEST_HOST}/discoapi`,
|
||||
],
|
||||
["extensions.htmlaboutaddons.discover.enabled", true],
|
||||
// Disable non-discopane recommendations to avoid unexpected discovery
|
||||
// API requests.
|
||||
["extensions.htmlaboutaddons.recommendations.enabled", false],
|
||||
|
|
|
@ -47,7 +47,6 @@ add_task(async function setup() {
|
|||
["datareporting.healthreport.uploadEnabled", true],
|
||||
["extensions.getAddons.discovery.api_url", `${serverBaseUrl}discoapi`],
|
||||
["app.support.baseURL", `${serverBaseUrl}sumo/`],
|
||||
["extensions.htmlaboutaddons.discover.enabled", true],
|
||||
// Discovery API requests can be triggered by the discopane and the
|
||||
// recommendations in the list view. To make sure that the every test
|
||||
// checks the behavior of the view they're testing, ensure that only one
|
||||
|
@ -162,8 +161,8 @@ add_task(async function clientid_enabled_from_extension_list() {
|
|||
await SpecialPowers.pushPrefEnv({
|
||||
// Override prefs from setup to enable recommendations.
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.discover.enabled", false],
|
||||
["extensions.htmlaboutaddons.recommendations.enabled", true],
|
||||
["extensions.getAddons.showPane", false],
|
||||
],
|
||||
});
|
||||
|
||||
|
@ -197,8 +196,8 @@ add_task(async function clientid_enabled_from_theme_list() {
|
|||
await SpecialPowers.pushPrefEnv({
|
||||
// Override prefs from setup to enable recommendations.
|
||||
set: [
|
||||
["extensions.htmlaboutaddons.discover.enabled", false],
|
||||
["extensions.htmlaboutaddons.recommendations.enabled", true],
|
||||
["extensions.getAddons.showPane", false],
|
||||
],
|
||||
});
|
||||
|
||||
|
|
|
@ -56,7 +56,6 @@ add_task(async function setup() {
|
|||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.getAddons.discovery.api_url", TEST_API_URL],
|
||||
["extensions.htmlaboutaddons.discover.enabled", true],
|
||||
// Disable recommendations at the HTML about:addons view to avoid sending
|
||||
// a discovery API request from the fallback view (extension list) in the
|
||||
// showPane_false test.
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
<html>
|
||||
<body>
|
||||
<h1>Test page for the discovery pane</h1>
|
||||
<p><a id="link-normal" href="https://example.com/browser/toolkit/mozapps/extensions/test/browser/discovery.html">Load normal</a></p>
|
||||
<p><a id="link-http" href="http://example.com/browser/toolkit/mozapps/extensions/test/browser/discovery.html">Load insecure</a></p>
|
||||
<p><a id="link-domain" href="https://test1.example.com/browser/toolkit/mozapps/extensions/test/browser/discovery.html">Load other domain</a></p>
|
||||
<p><a id="link-bad" href="https://example.com/browser/toolkit/mozapps/extensions/test/browser/foo.html">Load missing page</a></p>
|
||||
<p><a id="link-good" href="https://example.com/browser/toolkit/mozapps/extensions/test/browser/releaseNotes.xhtml">Load other page</a></p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,32 +0,0 @@
|
|||
<?xml version="1.0" ?>
|
||||
<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<setting pref="extensions.inlinesettings3.radioBool" type="radio" title="Radio">
|
||||
<radiogroup>
|
||||
<radio label="Delta" value="true" />
|
||||
<radio label="Echo" value="false" />
|
||||
</radiogroup>
|
||||
</setting>
|
||||
<setting pref="extensions.inlinesettings3.radioInt" type="radio" title="Radio">
|
||||
<radiogroup>
|
||||
<radio label="Foxtrot" value="4" />
|
||||
<radio label="Golf" value="5" />
|
||||
<radio label="Hotel" value="6" />
|
||||
</radiogroup>
|
||||
</setting>
|
||||
<setting pref="extensions.inlinesettings3.radioString" type="radio" title="Radio">
|
||||
<radiogroup>
|
||||
<radio label="India" value="india" />
|
||||
<radio label="Juliet" value="juliet" />
|
||||
<radio label="Kilo ㎏" value="kilo ㎏" />
|
||||
</radiogroup>
|
||||
</setting>
|
||||
<setting pref="extensions.inlinesettings3.menulist" type="menulist" title="Menulist">
|
||||
<menulist sizetopopup="always">
|
||||
<menupopup>
|
||||
<menuitem label="Lima" value="7" />
|
||||
<menuitem label="Mike" value="8" />
|
||||
<menuitem label="November" value="9" />
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</setting>
|
||||
</vbox>
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" ?>
|
||||
<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<setting />
|
||||
<setting pref="extensions.inlinesettings2.bool1" type="bool" title="Bool 1" desc="Description Attribute"/>
|
||||
<setting pref="extensions.inlinesettings2.bool2" type="bool" title="Bool 2">Description Text Node</setting>
|
||||
<setting type="control" title="Button">
|
||||
This is a test, <button label="button" />all this text should be visible
|
||||
</setting>
|
||||
<setting type="unsupported">
|
||||
This setting should never appear
|
||||
</setting>
|
||||
</vbox>
|
|
@ -1,15 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html lang="en-US" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>OMG, an update!!!!</h1>
|
||||
<ul>
|
||||
<li>Made everything more awesome</li>
|
||||
<li>Added hot sauce</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
Двоичные данные
toolkit/themes/osx/mozapps/extensions/discover-logo.png
Двоичные данные
toolkit/themes/osx/mozapps/extensions/discover-logo.png
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 11 KiB |
|
@ -6,7 +6,6 @@ toolkit.jar:
|
|||
#include ../../shared/mozapps.inc.mn
|
||||
skin/classic/mozapps/downloads/buttons.png (downloads/buttons.png)
|
||||
skin/classic/mozapps/downloads/unknownContentType.css (downloads/unknownContentType.css)
|
||||
skin/classic/mozapps/extensions/discover-logo.png (extensions/discover-logo.png)
|
||||
skin/classic/mozapps/extensions/rating-won.png (extensions/rating-won.png)
|
||||
skin/classic/mozapps/extensions/rating-not-won.png (extensions/rating-not-won.png)
|
||||
skin/classic/mozapps/extensions/cancel.png (extensions/cancel.png)
|
||||
|
|
|
@ -323,39 +323,6 @@ button.warning {
|
|||
margin-inline-start: 28px;
|
||||
}
|
||||
|
||||
/*** discover view ***/
|
||||
|
||||
.discover-spacer-before,
|
||||
.discover-spacer-after {
|
||||
-moz-box-flex: 1;
|
||||
}
|
||||
|
||||
#discover-error .alert {
|
||||
max-width: 45em;
|
||||
-moz-box-flex: 1;
|
||||
}
|
||||
|
||||
.discover-logo {
|
||||
list-style-image: url("chrome://mozapps/skin/extensions/discover-logo.png");
|
||||
margin-inline-end: 15px;
|
||||
}
|
||||
|
||||
.discover-title {
|
||||
font-weight: bold;
|
||||
font-size: 24px;
|
||||
font-family: MetaWebPro-Book, "Trebuchet MS", sans-serif;
|
||||
margin: 0 0 15px 0;
|
||||
}
|
||||
|
||||
.discover-description {
|
||||
text-align: justify;
|
||||
margin: 0 0 15px 0;
|
||||
}
|
||||
|
||||
.discover-footer {
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
|
||||
/*** list ***/
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
skin/classic/mozapps/downloads/downloadButtons.png (../../windows/mozapps/downloads/downloadButtons.png)
|
||||
skin/classic/mozapps/downloads/unknownContentType.css (../../windows/mozapps/downloads/unknownContentType.css)
|
||||
skin/classic/mozapps/extensions/blocklist.css (../../windows/mozapps/extensions/blocklist.css)
|
||||
skin/classic/mozapps/extensions/discover-logo.png (../../windows/mozapps/extensions/discover-logo.png)
|
||||
skin/classic/mozapps/extensions/rating-won.png (../../windows/mozapps/extensions/rating-won.png)
|
||||
skin/classic/mozapps/extensions/rating-not-won.png (../../windows/mozapps/extensions/rating-not-won.png)
|
||||
skin/classic/mozapps/extensions/cancel.png (../../windows/mozapps/extensions/cancel.png)
|
||||
|
|
Двоичные данные
toolkit/themes/windows/mozapps/extensions/discover-logo.png
Двоичные данные
toolkit/themes/windows/mozapps/extensions/discover-logo.png
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 11 KiB |
Загрузка…
Ссылка в новой задаче