Backed out 2 changesets (bug 1176712) for gip f5 permafail CLOSED TREE

Backed out changeset 52fd1c8b0fcb (bug 1176712)
Backed out changeset 6baeaddb32cc (bug 1176712)
This commit is contained in:
Wes Kocher 2015-07-02 09:21:23 -07:00
parent 268167f91a
commit ab9f88adea
7 changed files with 110 additions and 412 deletions

View File

@ -34,7 +34,7 @@ function debug(aMsg) {
} }
const DB_NAME = "activities"; const DB_NAME = "activities";
const DB_VERSION = 2; const DB_VERSION = 1;
const STORE_NAME = "activities"; const STORE_NAME = "activities";
function ActivitiesDb() { function ActivitiesDb() {
@ -63,25 +63,6 @@ ActivitiesDb.prototype = {
*/ */
upgradeSchema: function actdb_upgradeSchema(aTransaction, aDb, aOldVersion, aNewVersion) { upgradeSchema: function actdb_upgradeSchema(aTransaction, aDb, aOldVersion, aNewVersion) {
debug("Upgrade schema " + aOldVersion + " -> " + aNewVersion); debug("Upgrade schema " + aOldVersion + " -> " + aNewVersion);
let self = this;
function upgrade(currentVersion) {
let next = upgrade.bind(self, currentVersion + 1);
switch (currentVersion) {
case 0:
self.createSchema(aDb, next);
break;
case 1:
self.upgradeSchemaVersion2(aDb, aTransaction, next);
break;
}
}
upgrade(aOldVersion);
},
createSchema: function(aDb, aNext) {
let objectStore = aDb.createObjectStore(STORE_NAME, { keyPath: "id" }); let objectStore = aDb.createObjectStore(STORE_NAME, { keyPath: "id" });
// indexes // indexes
@ -89,49 +70,6 @@ ActivitiesDb.prototype = {
objectStore.createIndex("manifest", "manifest", { unique: false }); objectStore.createIndex("manifest", "manifest", { unique: false });
debug("Created object stores and indexes"); debug("Created object stores and indexes");
aNext();
},
upgradeSchemaVersion2: function(aDb, aTransaction, aNext) {
debug("Upgrading DB to version 2");
// In order to be able to have multiple activities with same name
// but different descriptions, we need to update the keypath from
// a hash made from {manifest, name} to a hash made from {manifest,
// name, description}.
//
// Unfortunately, updating the keypath is not allowed by IDB, so we
// need to remove and recreate the activities object store.
let activities = [];
let objectStore = aTransaction.objectStore(STORE_NAME);
objectStore.openCursor().onsuccess = (event) => {
let cursor = event.target.result;
if (!cursor) {
aDb.deleteObjectStore(STORE_NAME);
let objectStore = aDb.createObjectStore(STORE_NAME, { keyPath: "id" });
// indexes
objectStore.createIndex("name", "name", { unique: false });
objectStore.createIndex("manifest", "manifest", { unique: false });
this.add(activities, () => {
debug("DB upgraded to version 2");
aNext();
}, () => {
dump("Error upgrading DB to version 2 " + error + "\n");
});
return;
}
let activity = cursor.value;
debug("Upgrading activity " + JSON.stringify(activity));
activity.id = this.createId(activity);
activities.push(activity);
cursor.continue();
};
}, },
// unique ids made of (uri, action) // unique ids made of (uri, action)
@ -145,17 +83,8 @@ ActivitiesDb.prototype = {
hasher.init(hasher.SHA1); hasher.init(hasher.SHA1);
// add uri and action to the hash // add uri and action to the hash
["manifest", "name", "description"].forEach(function(aProp) { ["manifest", "name"].forEach(function(aProp) {
if (!aObject[aProp]) { let data = converter.convertToByteArray(aObject[aProp], {});
return;
}
let property = aObject[aProp];
if (aProp == "description") {
property = JSON.stringify(aObject[aProp]);
}
let data = converter.convertToByteArray(property, {});
hasher.update(data, data.length); hasher.update(data, data.length);
}); });
@ -181,17 +110,16 @@ ActivitiesDb.prototype = {
// Remove all the activities carried in the |aObjects| array. // Remove all the activities carried in the |aObjects| array.
remove: function actdb_remove(aObjects) { remove: function actdb_remove(aObjects) {
this.newTxn("readwrite", STORE_NAME, (txn, store) => { this.newTxn("readwrite", STORE_NAME, function (txn, store) {
aObjects.forEach((aObject) => { aObjects.forEach(function (aObject) {
let object = { let object = {
manifest: aObject.manifest, manifest: aObject.manifest,
name: aObject.name, name: aObject.name
description: aObject.description
}; };
debug("Going to remove " + JSON.stringify(object)); debug("Going to remove " + JSON.stringify(object));
store.delete(this.createId(object)); store.delete(this.createId(object));
}); }, this);
}, function() {}, function() {}); }.bind(this), function() {}, function() {});
}, },
// Remove all activities associated with the given |aManifest| URL. // Remove all activities associated with the given |aManifest| URL.
@ -319,8 +247,8 @@ let Activities = {
debug("Activity choice: " + aResult); debug("Activity choice: " + aResult);
// We have no matching activity registered, let's fire an error. // We have no matching activity registered, let's fire an error.
// Don't do this check until we have passed to UIGlue so the glue // Don't do this check until we have passed to UIGlue so the glue can choose to launch
// can choose to launch its own activity if needed. // its own activity if needed.
if (aResults.options.length === 0) { if (aResults.options.length === 0) {
self.trySendAndCleanup(aMsg.id, "Activity:FireError", { self.trySendAndCleanup(aMsg.id, "Activity:FireError", {
"id": aMsg.id, "id": aMsg.id,

View File

@ -1,37 +0,0 @@
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
const ACTIVITY_GLUE_CID = Components.ID("{f4cfbe10-a106-4cd1-b04e-0d2a6aac138b}");
const SYS_MSG_GLUE_CID = Components.ID("{b0b6b9af-bc4e-4200-bffe-fb7691065ec9}");
const gRootUrl = "http://test/chrome/dom/activities/tests/mochi/";
function registerComponent(aObject, aDescription, aContract, aCid) {
info("Registering " + aCid);
var componentManager =
Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
componentManager.registerFactory(aCid, aDescription, aContract, aObject);
// Keep the id on the object so we can unregister later.
aObject.cid = aCid;
}
function unregisterComponent(aObject) {
info("Unregistering " + aObject.cid);
var componentManager =
Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
componentManager.unregisterFactory(aObject.cid, aObject);
}
function cbError(aEvent) {
ok(false, "Error callback invoked " +
aEvent.target.error.name + " " + aEvent.target.error.message);
finish();
}
function unexpectedSuccess(aMsg) {
return function() {
ok(false, "Should not have succeeded: " + aMsg);
finish();
}
}

View File

@ -1,17 +1,6 @@
{ {
"name": "Random app", "name": "Random app",
"activities": { "activities": {
"import-app": { "blob": { "required": true } }, "import-app": { "blob": { "required": true } }
"bug1176712": [{
"filters": {
"type": "type1"
},
"href": "href1"
}, {
"filters": {
"type": "type2"
},
"href": "href2"
}]
} }
} }

View File

@ -1,11 +1,9 @@
[DEFAULT] [DEFAULT]
skip-if = e10s skip-if = e10s
support-files = support-files =
common.js
system.webapp system.webapp
system.webapp^headers^ system.webapp^headers^
manifest.webapp manifest.webapp
manifest.webapp^headers^ manifest.webapp^headers^
[test_dev_mode_activity.html] [test_dev_mode_activity.html]
[test_same_name_multiple_filters.html]

View File

@ -9,8 +9,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id={1123846}
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" <script type="application/javascript"
src="chrome://mochikit/content/chrome-harness.js"></script> src="chrome://mochikit/content/chrome-harness.js"></script>
<script type="application/javascript"
src="http://test/chrome/dom/activities/tests/mochi/common.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head> </head>
<body> <body>
@ -35,6 +33,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id={1123846}
* 4) Dev mode, system app and other app installed (success, only system app returned). * 4) Dev mode, system app and other app installed (success, only system app returned).
*/ */
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
var gRootUrl = "http://test/chrome/dom/activities/tests/mochi/";
var gGenerator = runTest(); var gGenerator = runTest();
function go() { function go() {
@ -51,6 +52,19 @@ function go() {
continueTest) }); continueTest) });
} }
function cbError(aEvent) {
ok(false, "Error callback invoked " +
aEvent.target.error.name + " " + aEvent.target.error.message);
finish();
}
function unexpectedSuccess(aMsg) {
return function() {
ok(false, "Should not have succeeded: " + aMsg);
finish();
}
}
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var systemAppUrl = gRootUrl + "system.webapp"; var systemAppUrl = gRootUrl + "system.webapp";
@ -78,6 +92,28 @@ function uninstall(aApp) {
request.onsuccess = continueTest; request.onsuccess = continueTest;
} }
function registerComponent(aObject, aDescription, aContract) {
var uuidGenerator = Cc["@mozilla.org/uuid-generator;1"]
.getService(Ci.nsIUUIDGenerator);
var cid = uuidGenerator.generateUUID();
info("Registering " + cid);
var componentManager =
Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
componentManager.registerFactory(cid, aDescription, aContract, aObject);
// Keep the id on the object so we can unregister later.
aObject.cid = cid;
}
function unregisterComponent(aObject) {
info("Unregistering " + aObject.cid);
var componentManager =
Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
componentManager.unregisterFactory(aObject.cid, aObject);
}
var ActivityGlue = { var ActivityGlue = {
// nsISupports implementation. // nsISupports implementation.
QueryInterface: function(iid) { QueryInterface: function(iid) {
@ -121,27 +157,22 @@ var SystemMessageGlue = {
// nsISystemMessageGlue implementation. // nsISystemMessageGlue implementation.
openApp(pageURL, manifestURL, type, target, showApp, onlyShowApp, extra) { openApp(pageURL, manifestURL, type, target, showApp, onlyShowApp, extra) {
// We should only try to open a page in the system app. // We should only try to open a page in the sytem app.
is(manifestURL, systemAppUrl, "Opening a page in the system app."); is(manifestURL, systemAppUrl, "Opening a page in the system app.");
} }
}; };
registerComponent(ActivityGlue, registerComponent(ActivityGlue,
"Activity Glue", "Activity Glue",
"@mozilla.org/dom/activities/ui-glue;1", "@mozilla.org/dom/activities/ui-glue;1");
ACTIVITY_GLUE_CID);
registerComponent(SystemMessageGlue, registerComponent(SystemMessageGlue,
"System Message Glue", "System Message Glue",
"@mozilla.org/dom/messages/system-message-glue;1", "@mozilla.org/dom/messages/system-message-glue;1");
SYS_MSG_GLUE_CID);
function finish() { function finish() {
unregisterComponent(ActivityGlue); unregisterComponent(ActivityGlue);
unregisterComponent(SystemMessageGlue); unregisterComponent(SystemMessageGlue);
obsService.removeObserver(continueTest, "new-activity-registered-success");
obsService.removeObserver(continueTest, "new-activity-registered-failure");
SimpleTest.finish(); SimpleTest.finish();
} }

View File

@ -1,222 +0,0 @@
<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id={1176712}
-->
<head>
<title>Test for Bug {1176712}</title>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/chrome-harness.js"></script>
<script type="application/javascript"
src="http://test/chrome/dom/activities/tests/mochi/common.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id={1176712}">Mozilla Bug {1176712}</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 gGenerator = runTest();
function go() {
SpecialPowers.pushPermissions(
[{ "type": "webapps-manage", "allow": 1, "context": document },
{ "type": "browser", "allow": 1, "context": document },
{ "type": "embed-apps", "allow": 1, "context": document }],
function() {
SpecialPowers.pushPrefEnv(
{'set': [["dom.mozBrowserFramesEnabled", true],
["dom.sysmsg.enabled", true]]},
continueTest) });
}
SimpleTest.waitForExplicitFinish();
function installApp(aUrl) {
var request = navigator.mozApps.install(aUrl, { });
request.onerror = cbError;
request.onsuccess = continueTest;
return request;
}
function uninstall(aApp) {
info("Uninstalling " + (aApp ? aApp.manifestURL : "NO APP!!"));
var request = navigator.mozApps.mgmt.uninstall(aApp);
request.onerror = cbError;
request.onsuccess = continueTest;
}
var ActivityGlue = {
// nsISupports implementation.
QueryInterface: function(iid) {
if (iid.equals(Ci.nsISupports) ||
iid.equals(Ci.nsIFactory) ||
iid.equals(Ci.nsIActivityUIGlue)) {
return this;
}
throw Cr.NS_ERROR_NO_INTERFACE;
},
// nsIFactory implementation.
createInstance: function(outer, iid) {
return this.QueryInterface(iid);
},
// nsIActivityUIGlue implementation.
chooseActivity: function(aOptions, aActivities, aCallback) {
aCallback.handleEvent(Ci.nsIActivityUIGlueCallback.WEBAPPS_ACTIVITY,
aActivities.length == 1 ? 0 : -1);
}
};
var SystemMessageGlue = {
// nsISupports implementation.
QueryInterface: function(iid) {
if (iid.equals(Ci.nsISupports) ||
iid.equals(Ci.nsIFactory) ||
iid.equals(Ci.nsISystemMessageGlue)) {
return this;
}
throw Cr.NS_ERROR_NO_INTERFACE;
},
// nsIFactory implementation.
createInstance: function(outer, iid) {
return this.QueryInterface(iid);
},
// nsISystemMessageGlue implementation.
openApp(pageURL, manifestURL, type, target, showApp, onlyShowApp, extra) {
}
};
registerComponent(ActivityGlue,
"Activity Glue",
"@mozilla.org/dom/activities/ui-glue;1",
ACTIVITY_GLUE_CID);
registerComponent(SystemMessageGlue,
"System Message Glue",
"@mozilla.org/dom/messages/system-message-glue;1",
SYS_MSG_GLUE_CID);
function finish() {
unregisterComponent(ActivityGlue);
unregisterComponent(SystemMessageGlue);
SimpleTest.finish();
}
function continueTest() {
try {
gGenerator.next();
} catch (e if e instanceof StopIteration) {
finish();
}
}
function runTest() {
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.autoConfirmAppInstall(continueTest);
yield undefined;
SpecialPowers.autoConfirmAppUninstall(continueTest);
yield undefined;
// Check how many apps we are starting with.
var request = navigator.mozApps.mgmt.getAll();
request.onerror = cbError;
request.onsuccess = continueTest;
yield undefined;
var initialAppsCount = request.result.length;
info("Starting with " + initialAppsCount + " apps installed.");
// Before app installed
var activity = new MozActivity({
name: "bug1176712",
data: {
type: "type1"
}
});
activity.onsuccess = unexpectedSuccess("Shouldn't launch unregistered activity");
activity.onerror = () => {
ok(activity.error.name == "NO_PROVIDER", "Expected NO_PROVIDER");
continueTest();
};
yield undefined;
var activity = new MozActivity({
name: "bug1176712",
data: {
type: "type2"
}
});
activity.onsuccess = unexpectedSuccess("Shouldn't launch unregistered activity");
activity.onerror = () => {
ok(activity.error.name == "NO_PROVIDER", "Expected NO_PROVIDER");
continueTest();
};
yield undefined;
var request = installApp(gRootUrl + "manifest.webapp");
yield undefined;
var app = request.result;
ok(app, "App installed");
// After app installed
var activity = new MozActivity({
name: "bug1176712",
data: {
type: "type1"
}
});
activity.onsuccess = function() {
ok(true, "Activity launch succeed");
continueTest();
}
activity.onerror = cbError;
yield undefined;
var activity = new MozActivity({
name: "bug1176712",
data: {
type: "type2"
}
});
activity.onsuccess = function() {
ok(true, "Activity launch succeed");
continueTest();
}
activity.onerror = cbError;
yield undefined;
// Cleanup
uninstall(app);
yield undefined;
// Check that we restored the app registry.
request = navigator.mozApps.mgmt.getAll();
request.onerror = cbError;
request.onsuccess = continueTest;
yield undefined;
is(request.result.length, initialAppsCount, "All apps are uninstalled.");
}
addLoadEvent(go);
</script>
</pre>
</body>
</html>

View File

@ -990,8 +990,7 @@ this.DOMApplicationRegistry = {
// |aEntryPoint| is either the entry_point name or the null in which case we // |aEntryPoint| is either the entry_point name or the null in which case we
// use the root of the manifest. // use the root of the manifest.
_createActivitiesToRegister: function(aManifest, aApp, aEntryPoint, _createActivitiesToRegister: function(aManifest, aApp, aEntryPoint, aRunUpdate) {
aRunUpdate, aUninstall) {
let activitiesToRegister = []; let activitiesToRegister = [];
let root = aManifest; let root = aManifest;
if (aEntryPoint && aManifest.entry_points[aEntryPoint]) { if (aEntryPoint && aManifest.entry_points[aEntryPoint]) {
@ -1004,56 +1003,46 @@ this.DOMApplicationRegistry = {
let manifest = new ManifestHelper(aManifest, aApp.origin, aApp.manifestURL); let manifest = new ManifestHelper(aManifest, aApp.origin, aApp.manifestURL);
for (let activity in root.activities) { for (let activity in root.activities) {
let entry = root.activities[activity]; let description = root.activities[activity];
if (!Array.isArray(entry)) { let href = description.href;
entry = [entry]; if (!href) {
href = manifest.launch_path;
} }
for (let i = 0; i < entry.length; i++) {
let description = entry[i];
let href = description.href;
if (!href) {
href = manifest.launch_path;
}
try { try {
href = manifest.resolveURL(href); href = manifest.resolveURL(href);
} catch (e) { } catch (e) {
debug("Activity href (" + href + ") is invalid, skipping. " + debug("Activity href (" + href + ") is invalid, skipping. " +
"Error is: " + e); "Error is: " + e);
continue; continue;
} }
// Make a copy of the description object since we don't want to modify // Make a copy of the description object since we don't want to modify
// the manifest itself, but need to register with a resolved URI. // the manifest itself, but need to register with a resolved URI.
let newDesc = {}; let newDesc = {};
for (let prop in description) { for (let prop in description) {
newDesc[prop] = description[prop]; newDesc[prop] = description[prop];
} }
newDesc.href = href; newDesc.href = href;
debug('_createActivitiesToRegister: ' + aApp.manifestURL + ', activity ' + debug('_createActivitiesToRegister: ' + aApp.manifestURL + ', activity ' +
activity + ', description.href is ' + newDesc.href); activity + ', description.href is ' + newDesc.href);
if (aRunUpdate || aUninstall) { if (aRunUpdate) {
activitiesToRegister.push({ "manifest": aApp.manifestURL, activitiesToRegister.push({ "manifest": aApp.manifestURL,
"name": activity, "name": activity,
"icon": manifest.iconURLForSize(128), "icon": manifest.iconURLForSize(128),
"description": newDesc }); "description": newDesc });
} }
if (aUninstall) { let launchPathURI = Services.io.newURI(href, null, null);
continue; let manifestURI = Services.io.newURI(aApp.manifestURL, null, null);
}
let launchPathURI = Services.io.newURI(href, null, null); if (SystemMessagePermissionsChecker
let manifestURI = Services.io.newURI(aApp.manifestURL, null, null); .isSystemMessagePermittedToRegister("activity",
aApp.manifestURL,
if (SystemMessagePermissionsChecker aManifest)) {
.isSystemMessagePermittedToRegister("activity", msgmgr.registerPage("activity", launchPathURI, manifestURI);
aApp.manifestURL,
aManifest)) {
msgmgr.registerPage("activity", launchPathURI, manifestURI);
}
} }
} }
return activitiesToRegister; return activitiesToRegister;
@ -1099,6 +1088,28 @@ this.DOMApplicationRegistry = {
this._registerActivitiesForApps([{ manifest: aManifest, app: aApp }], aRunUpdate); this._registerActivitiesForApps([{ manifest: aManifest, app: aApp }], aRunUpdate);
}, },
// |aEntryPoint| is either the entry_point name or the null in which case we
// use the root of the manifest.
_createActivitiesToUnregister: function(aManifest, aApp, aEntryPoint) {
let activitiesToUnregister = [];
let root = aManifest;
if (aEntryPoint && aManifest.entry_points[aEntryPoint]) {
root = aManifest.entry_points[aEntryPoint];
}
if (!root.activities) {
return activitiesToUnregister;
}
for (let activity in root.activities) {
let description = root.activities[activity];
activitiesToUnregister.push({ "manifest": aApp.manifestURL,
"name": activity,
"description": description });
}
return activitiesToUnregister;
},
// |aAppsToUnregister| contains an array of apps to be unregistered, where // |aAppsToUnregister| contains an array of apps to be unregistered, where
// each element is an object in the format of {manifest: foo, app: bar}. // each element is an object in the format of {manifest: foo, app: bar}.
_unregisterActivitiesForApps: function(aAppsToUnregister) { _unregisterActivitiesForApps: function(aAppsToUnregister) {
@ -1108,7 +1119,7 @@ this.DOMApplicationRegistry = {
let manifest = aApp.manifest; let manifest = aApp.manifest;
let app = aApp.app; let app = aApp.app;
activitiesToUnregister.push.apply(activitiesToUnregister, activitiesToUnregister.push.apply(activitiesToUnregister,
this._createActivitiesToRegister(manifest, app, null, false, true)); this._createActivitiesToUnregister(manifest, app, null));
if (!manifest.entry_points) { if (!manifest.entry_points) {
return; return;
@ -1116,7 +1127,7 @@ this.DOMApplicationRegistry = {
for (let entryPoint in manifest.entry_points) { for (let entryPoint in manifest.entry_points) {
activitiesToUnregister.push.apply(activitiesToUnregister, activitiesToUnregister.push.apply(activitiesToUnregister,
this._createActivitiesToRegister(manifest, app, entryPoint, false, true)); this._createActivitiesToUnregister(manifest, app, entryPoint));
} }
}, this); }, this);