Bug 1194525 - Gecko should ignore |postResult| calls for WebActivities with no returnValue. r=fabrice,sicking

This commit is contained in:
Andre Natal 2015-11-09 15:33:00 +01:00
parent 19fa673ace
commit d00989a641
3 changed files with 17 additions and 8 deletions

View File

@ -36,9 +36,10 @@ ActivityRequestHandler.prototype = {
this._window = aWindow;
},
__init: function arh___init(aId, aOptions) {
__init: function arh___init(aId, aOptions, aReturnValue) {
this._id = aId;
this._options = aOptions;
this._returnValue = aReturnValue;
},
get source() {
@ -49,11 +50,16 @@ ActivityRequestHandler.prototype = {
},
postResult: function arh_postResult(aResult) {
cpmm.sendAsyncMessage("Activity:PostResult", {
"id": this._id,
"result": aResult
});
Services.obs.notifyObservers(null, "activity-success", this._id);
if (this._returnValue) {
cpmm.sendAsyncMessage("Activity:PostResult", {
"id": this._id,
"result": aResult
});
Services.obs.notifyObservers(null, "activity-success", this._id);
} else {
Cu.reportError("postResult() can't be called when 'returnValue': 'true' isn't declared in manifest.webapp");
throw new Error("postResult() can't be called when 'returnValue': 'true' isn't declared in manifest.webapp");
}
},
postError: function arh_postError(aError) {

View File

@ -37,7 +37,10 @@ ActivityWrapper.prototype = {
// Activity workflow.
cpmm.sendAsyncMessage("Activity:Ready", { id: aMessage.id });
let handler = new aWindow.ActivityRequestHandler(aMessage.id, aMessage.payload);
// Gecko should ignore |postResult| calls for WebActivities with no returnValue
// We need to pass returnValue to ActivityRequestHandler constructor to then properly
// decide if should call postResult or not
let handler = new aWindow.ActivityRequestHandler(aMessage.id, aMessage.payload, aMessage.target.returnValue);
// When the activity window is closed, fire an error to notify the activity
// caller of the situation.

View File

@ -4,7 +4,7 @@
[Pref="dom.sysmsg.enabled",
JSImplementation="@mozilla.org/dom/activities/request-handler;1",
ChromeConstructor(DOMString id, optional ActivityOptions options),
ChromeConstructor(DOMString id, optional ActivityOptions options, optional boolean returnvalue),
ChromeOnly]
interface ActivityRequestHandler
{