Backed out 3 changesets (bug 1208242) for emulator mochitest bustage

Backed out changeset d2f87bf3aced (bug 1208242)
Backed out changeset c38225ee4378 (bug 1208242)
Backed out changeset 6dff307959f2 (bug 1208242)
This commit is contained in:
Wes Kocher 2015-10-29 12:17:25 -07:00
parent e25e5027b4
commit 1b29c63fda
11 changed files with 24 additions and 344 deletions

View File

@ -1153,12 +1153,6 @@ pref("dom.performance.enable_notify_performance_timing", true);
pref("b2g.multiscreen.chrome_remote_url", "chrome://b2g/content/shell_remote.html");
pref("b2g.multiscreen.system_remote_url", "index_remote.html");
// Blocklist service
pref("extensions.blocklist.enabled", true);
pref("extensions.blocklist.interval", 86400);
pref("extensions.blocklist.url", "https://blocklist.addons.mozilla.org/blocklist/3/%APP_ID%/%APP_VERSION%/%PRODUCT%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/%PING_COUNT%/%TOTAL_PING_COUNT%/%DAYS_SINCE_LAST_PING%/");
pref("extensions.blocklist.detailsURL", "https://www.mozilla.com/%LOCALE%/blocklist/");
// Because we can't have nice things.
#ifdef MOZ_GRAPHENE
#include ../graphene/graphene.js

View File

@ -537,16 +537,15 @@
#endif // MOZ_WIDGET_GONK && MOZ_B2G_RIL
#ifndef MOZ_WIDGET_GONK
@RESPATH@/components/extensions.manifest
@RESPATH@/components/addonManager.js
@RESPATH@/components/amContentHandler.js
@RESPATH@/components/amInstallTrigger.js
@RESPATH@/components/amWebInstallListener.js
@RESPATH@/components/nsBlocklistService.js
@RESPATH@/components/OopCommandLine.js
@RESPATH@/components/CommandLine.js
#endif
@RESPATH@/components/extensions.manifest
@RESPATH@/components/nsBlocklistService.js
@RESPATH@/components/BootstrapCommandLine.js
#ifdef MOZ_UPDATER

View File

@ -131,10 +131,6 @@ function _setAppProperties(aObj, aApp) {
aObj.enabled = aApp.enabled !== undefined ? aApp.enabled : true;
aObj.sideloaded = aApp.sideloaded;
aObj.extensionVersion = aApp.extensionVersion;
aObj.blockedStatus =
aApp.blockedStatus !== undefined ? aApp.blockedStatus
: Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
aObj.blocklistId = aApp.blocklistId;
#ifdef MOZ_B2GDROID
aObj.android_packagename = aApp.android_packagename;
aObj.android_classname = aApp.android_classname;

View File

@ -251,9 +251,7 @@ this.ImportExport = {
throw "NoManifestFound";
}
return [readObjectFromZip(appZipReader, "manifest.webapp"),
readObjectFromZip(appZipReader, "update.webapp"),
file];
return [readObjectFromZip(appZipReader, "manifest.webapp"), file];
},
// Returns a promise that resolves to the temp file path.
@ -309,7 +307,6 @@ this.ImportExport = {
let meta;
let appDir;
let manifest;
let updateManifest;
let zipReader = Cc["@mozilla.org/libjar/zip-reader;1"]
.createInstance(Ci.nsIZipReader);
try {
@ -356,7 +353,7 @@ this.ImportExport = {
let appFile;
if (isPackage) {
[manifest, updateManifest, appFile] =
[manifest, appFile] =
this._importPackagedApp(zipReader, meta.manifestURL, appDir);
} else {
manifest = this._importHostedApp(zipReader, meta.manifestURL);
@ -398,11 +395,6 @@ this.ImportExport = {
meta.installerIsBrowser = false;
meta.role = manifest.role;
// If there is an id in the mini-manifest, use it for blocklisting purposes.
if (isPackage && updateManifest && ("id" in updateManifest)) {
meta.blocklistId = updateManifest["id"];
}
let devMode = false;
try {
devMode = Services.prefs.getBoolPref("dom.apps.developer_mode");

View File

@ -348,10 +348,6 @@ this.DOMApplicationRegistry = {
app.enabled = true;
}
if (app.blockedStatus === undefined) {
app.blockedStatus = Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
}
// At startup we can't be downloading, and the $TMP directory
// will be empty so we can't just apply a staged update.
app.downloading = false;
@ -1215,7 +1211,6 @@ this.DOMApplicationRegistry = {
ppmm.removeMessageListener(msgName, this);
}).bind(this));
Services.obs.removeObserver(this, "xpcom-shutdown");
Services.obs.removeObserver(this, "memory-pressure");
cpmm = null;
ppmm = null;
if (AppConstants.MOZ_B2GDROID) {
@ -1227,55 +1222,6 @@ this.DOMApplicationRegistry = {
}
},
// Check extensions to be blocked.
blockExtensions: function(aExtensions) {
debug("blockExtensions");
let app;
let runtime = Services.appinfo.QueryInterface(Ci.nsIXULRuntime);
aExtensions.filter(extension => {
// Filter out id-less items and those who don't have a matching installed
// extension.
if (!extension.attributes.has("id")) {
return false;
}
// Check that we have an app with this extension id.
let extId = extension.attributes.get("id");
for (let id in this.webapps) {
if (this.webapps[id].blocklistId == extId) {
app = this.webapps[id];
return true;
}
}
// No webapp found for this extension id.
return false;
}).forEach(extension => {
// `extension` is a object such as:
// {"versions":[{"minVersion":"0.1",
// "maxVersion":"1.3.328.4",
// "severity":"1",
// "vulnerabilityStatus":0,
// "targetApps":{
// "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}":[{"minVersion":"3.7a1pre","maxVersion":"*"}]
// }
// }],
// "prefs":[],
// "blockID":"i24",
// "attributes": Map()
// }
//
// `versions` is array of BlocklistItemData (see nsBlocklistService.js)
let severity = Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
for (let item of extension.versions) {
if (item.includesItem(app.extensionVersion, runtime.version, runtime.platformVersion)) {
severity = item.severity;
break;
}
}
this.setBlockedStatus(app.manifestURL, severity);
});
},
formatMessage: function(aData) {
let msg = aData;
delete msg["mm"];
@ -1973,9 +1919,6 @@ this.DOMApplicationRegistry = {
delete app.retryingDownload;
// Once updated we are not in the blocklist anymore.
app.blockedStatus = Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
// Update the asm.js scripts we need to compile.
yield ScriptPreloader.preload(app, newManifest);
@ -3018,10 +2961,6 @@ this.DOMApplicationRegistry = {
this._writeManifestFile(app.id, false, aManifest);
if (aUpdateManifest) {
this._writeManifestFile(app.id, true, aUpdateManifest);
// If there is an id in the mini-manifest, use it for blocklisting purposes.
if (aData.isPackage && ("id" in aUpdateManifest)) {
this.webapps[app.id].blocklistId = aUpdateManifest["id"];
}
}
this._saveApps().then(() => {
@ -3056,10 +2995,6 @@ this.DOMApplicationRegistry = {
let jsonManifest = aData.isPackage ? app.updateManifest : app.manifest;
yield this._writeManifestFile(id, aData.isPackage, jsonManifest);
// If there is an id in the mini-manifest, use it for blocklisting purposes.
if (aData.isPackage && ("id" in jsonManifest)) {
app.blocklistId = jsonManifest["id"];
}
debug("app.origin: " + app.origin);
let manifest =
@ -4646,20 +4581,6 @@ this.DOMApplicationRegistry = {
});
},
setBlockedStatus: function(aManifestURL, aSeverity) {
let id = this._appIdForManifestURL(aManifestURL);
if (!id || !this.webapps[id]) {
return;
}
debug(`Setting blocked status ${aSeverity} on ${id}`);
let app = this.webapps[id];
app.blockedStatus = aSeverity;
let enabled = aSeverity == Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
this.setEnabled({ manifestURL: aManifestURL, enabled });
},
setEnabled: function(aData) {
debug("setEnabled " + aData.manifestURL + " : " + aData.enabled);
let id = this._appIdForManifestURL(aData.manifestURL);
@ -4669,13 +4590,7 @@ this.DOMApplicationRegistry = {
debug("Enabling " + id);
let app = this.webapps[id];
// If we try to enable an app, check if it's not blocked.
if (!aData.enabled ||
app.blockedStatus == Ci.nsIBlocklistService.STATE_NOT_BLOCKED) {
app.enabled = aData.enabled;
}
this._saveApps().then(() => {
MessageBroadcaster.broadcastMessage("Webapps:UpdateState", {
app: app,

View File

@ -2,6 +2,5 @@
"name": "Addon app",
"description": "Let me inject script and css!",
"developer": { "name": "The Mozilla Community" },
"package_path" : "application.zip",
"id": "webextension@mochitest"
"package_path" : "application.zip"
}

View File

@ -39,8 +39,6 @@ support-files =
[test_app_addons.html]
skip-if = os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
[test_app_blocklist.html]
skip-if = buildapp != 'b2g'
[test_app_enabled.html]
[test_app_update.html]
skip-if = os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app

View File

@ -1,193 +0,0 @@
<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id={1208242}
-->
<head>
<title>Test for Bug {1208242}</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id={1208242}">Mozilla Bug {1208242}</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="application/javascript;version=1.7">
var baseURL = "http://mochi.test:8888/tests/dom/apps/tests/addons/";
var appManifestURL = baseURL + "update.webapp";
SimpleTest.waitForExplicitFinish();
var gGenerator = runTest();
// Utilities to turn off auto update of the blocklist.
// Copied from toolkit/mozapps/extensions/test/browser/head.js
var gCatMan = SpecialPowers.Cc["@mozilla.org/categorymanager;1"]
.getService(SpecialPowers.Ci.nsICategoryManager);
var UTIMER = "update-timer";
var BLOCKLIST = "nsBlocklistService";
var blocklistUpdateConfig = "@mozilla.org/extensions/blocklist;1,getService,blocklist-background-update-timer,extensions.blocklist.interval,86400";
function disableBlocklistUpdateTimer() {
info("Disabling " + UTIMER + " " + BLOCKLIST);
blocklistUpdateConfig = gCatMan.getCategoryEntry(UTIMER, BLOCKLIST);
gCatMan.deleteCategoryEntry(UTIMER, BLOCKLIST, true);
}
function enableBlocklistUpdateTimer() {
info("Enabling " + UTIMER + " " + BLOCKLIST);
gCatMan.addCategoryEntry(UTIMER, BLOCKLIST, blocklistUpdateConfig, false, true);
}
// End of utilities
function go() {
disableBlocklistUpdateTimer();
SpecialPowers.allowUnsignedAddons();
SpecialPowers.pushPermissions(
[{ "type": "webapps-manage", "allow": 1, "context": document }],
function() { gGenerator.next() });
}
function continueTest() {
try {
gGenerator.next();
} catch (e if e instanceof StopIteration) {
finish();
}
}
function finish() {
enableBlocklistUpdateTimer();
SimpleTest.finish();
}
function cbError(aEvent) {
ok(false, "Error callback invoked " +
aEvent.target.error.name + " " + aEvent.target.error.message);
finish();
}
function mozAppsError() {
ok(false, "mozApps error: " + this.error.name);
SpecialPowers.debugUserCustomizations(false);
SimpleTest.finish();
}
function installApp(manifestURL) {
info("About to install app at " + manifestURL);
let req = navigator.mozApps.installPackage(manifestURL);
req.onsuccess = function() {
is(req.result.manifestURL, manifestURL, "app installed");
if (req.result.installState == "installed") {
is(req.result.manifest.version, "1.0", "correct version");
is(req.result.installState, "installed", "app downloaded");
continueTest();
} else {
req.result.ondownloadapplied = function() {
is(req.result.manifest.version, "1.0", "correct version");
is(req.result.installState, "installed", "app downloaded");
continueTest();
}
req.result.ondownloaderror = function() {
ok(false, "unexpected installation error: " + req.result.downloadError.name);
continueTest();
}
}
}
req.onerror = mozAppsError;
return req;
}
/**
* Test blocking of an add-on.
*/
function runTest() {
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.autoConfirmAppInstall(continueTest);
yield undefined;
SpecialPowers.autoConfirmAppUninstall(continueTest);
yield undefined;
request = navigator.mozApps.mgmt.getAll();
request.onerror = cbError;
request.onsuccess = continueTest;
yield undefined;
var initialAppsCount = request.result.length;
info("Starting with " + initialAppsCount + " apps installed.");
// Install valid addon app.
var req = installApp(appManifestURL, false);
yield undefined;
var app = req.result;
ok(app, "App is non-null");
is(app.manifestURL, appManifestURL, "App manifest url is correct.");
is(app.enabled, true, "App is enabled by default after install.");
// Check that the app is disabled
navigator.mozApps.mgmt.onenabledstatechange = function(event) {
ok(true, "onenabledstatechange received");
is(event.application.enabled, false, "Application is disabled");
continueTest();
}
// Trigger the blocklist by passing an XML blocklist string.
var blocklist =
`<?xml version="1.0"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1443544016000">
<emItems>
<emItem blockID="i00" id="webextension@mochitest">
<versionRange minVersion="0" maxVersion="*" severity="1"> </versionRange>
</emItem>
</emItems>
</blocklist>`;
var bls = SpecialPowers.Cc["@mozilla.org/extensions/blocklist;1"]
.getService(SpecialPowers.Ci.nsIBlocklistService).wrappedJSObject;
bls._loadBlocklistFromString(blocklist);
//navigator.mozApps.mgmt.setEnabled(app, true);
yield undefined;
// Cleaning up after ourselves.
navigator.mozApps.mgmt.onuninstall = function(event) {
var app = event.application;
is(app.manifestURL, appManifestURL, "App uninstall event ok.");
is(app.manifest.name, "Addon app", "App uninstall manifest ok.");
continueTest();
}
request = navigator.mozApps.mgmt.uninstall(app);
request.onerror = cbError;
request.onsuccess = continueTest;
yield undefined;
yield undefined;
is(request.result, appManifestURL, "App uninstalled.");
navigator.mozApps.mgmt.onuninstall = null;
request = navigator.mozApps.mgmt.getAll();
request.onerror = cbError;
request.onsuccess = continueTest;
yield undefined;
is(request.result.length, initialAppsCount, "All apps are uninstalled.");
}
addLoadEvent(() => prepareEnv(go));
</script>
</pre>
</body>
</html>

View File

@ -4,8 +4,8 @@ category profile-after-change nsBlocklistService @mozilla.org/extensions/blockli
component {e0a106ed-6ad4-47a4-b6af-2f1c8aa4712d} nsBlocklistServiceContent.js process=content
contract @mozilla.org/extensions/blocklist;1 {e0a106ed-6ad4-47a4-b6af-2f1c8aa4712d} process=content
category update-timer nsBlocklistService @mozilla.org/extensions/blocklist;1,getService,blocklist-background-update-timer,extensions.blocklist.interval,86400
#ifndef MOZ_WIDGET_GONK
category update-timer nsBlocklistService @mozilla.org/extensions/blocklist;1,getService,blocklist-background-update-timer,extensions.blocklist.interval,86400
component {4399533d-08d1-458c-a87a-235f74451cfa} addonManager.js
contract @mozilla.org/addons/integration;1 {4399533d-08d1-458c-a87a-235f74451cfa}
category update-timer addonManager @mozilla.org/addons/integration;1,getService,addon-background-update-timer,extensions.update.interval,86400

View File

@ -21,12 +21,12 @@ EXTRA_COMPONENTS += [
'amContentHandler.js',
'amInstallTrigger.js',
'amWebInstallListener.js',
'nsBlocklistService.js',
'nsBlocklistServiceContent.js',
]
EXTRA_PP_COMPONENTS += [
'extensions.manifest',
'nsBlocklistService.js',
]
EXTRA_JS_MODULES += [

View File

@ -12,7 +12,6 @@ const Cr = Components.results;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/AppConstants.jsm");
try {
// AddonManager.jsm doesn't allow itself to be imported in the child
@ -30,8 +29,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "OS",
"resource://gre/modules/osfile.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "DOMApplicationRegistry",
"resource://gre/modules/Webapps.jsm");
const TOOLKIT_ID = "toolkit@mozilla.org";
const KEY_PROFILEDIR = "ProfD";
@ -110,8 +107,7 @@ XPCOMUtils.defineLazyGetter(this, "gABI", function bls_gABI() {
catch (e) {
LOG("BlockList Global gABI: XPCOM ABI unknown.");
}
if (AppConstants.platform == "macosx") {
#ifdef XP_MACOSX
// Mac universal build should report a different ABI than either macppc
// or mactel.
let macutils = Cc["@mozilla.org/xpcom/mac-utils;1"].
@ -119,7 +115,7 @@ XPCOMUtils.defineLazyGetter(this, "gABI", function bls_gABI() {
if (macutils.isUniversalBinary)
abi += "-u-" + macutils.architecturesInBinary;
}
#endif
return abi;
});
@ -896,21 +892,10 @@ Blocklist.prototype = {
continue;
switch (element.localName) {
case "emItems":
// Special case for b2g, since we don't use the addon manager.
if (AppConstants.MOZ_B2G) {
let extensions = this._processItemNodes(element.childNodes, "em",
this._handleEmItemNode);
DOMApplicationRegistry.blockExtensions(extensions);
return;
}
this._addonEntries = this._processItemNodes(element.childNodes, "em",
this._handleEmItemNode);
break;
case "pluginItems":
// We don't support plugins on b2g.
if (AppConstants.MOZ_B2G) {
return;
}
this._pluginEntries = this._processItemNodes(element.childNodes, "plugin",
this._handlePluginItemNode);
break;
@ -1075,15 +1060,14 @@ Blocklist.prototype = {
/* See nsIBlocklistService */
getPluginBlocklistState: function Blocklist_getPluginBlocklistState(plugin,
appVersion, toolkitVersion) {
if (AppConstants.platform == "android" ||
AppConstants.MOZ_B2G) {
#ifdef ANDROID
return Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
} else {
#else
if (!this._isBlocklistLoaded())
this._loadBlocklist();
return this._getPluginBlocklistState(plugin, this._pluginEntries,
appVersion, toolkitVersion);
}
#endif // ifdef ANDROID
},
/**
@ -1223,10 +1207,6 @@ Blocklist.prototype = {
},
_blocklistUpdated: function Blocklist_blocklistUpdated(oldAddonEntries, oldPluginEntries) {
if (AppConstants.MOZ_B2G) {
return;
}
var addonList = [];
// A helper function that reverts the prefs passed to default values.