# HG changeset patch # User Sean Lin # Date 1414640950 -28800 # Thu Oct 30 11:49:10 2014 +0800 # Node ID 2b8d35490d67b80c76a3d4e5cdc33272b49ce436 # Parent 77052db0876656441c526e266f71f42776708e25 Bug 1090896 - Fix mozAlarms.add() method to allow omitting data parameter. r=bz diff --git a/dom/alarm/AlarmsManager.js b/dom/alarm/AlarmsManager.js --- a/dom/alarm/AlarmsManager.js +++ b/dom/alarm/AlarmsManager.js @@ -56,28 +56,31 @@ AlarmsManager.prototype = { isIgnoreTimezone = true; break; default: throw Components.results.NS_ERROR_INVALID_ARG; break; } - // Run JSON.stringify() in the sand box with the principal of the calling - // web page to ensure no cross-origin object is involved. A "Permission - // Denied" error will be thrown in case of privilege violation. - let sandbox = new Cu.Sandbox(Cu.getWebIDLCallerPrincipal()); - sandbox.data = aData; - let data = Cu.evalInSandbox("JSON.stringify(data)", sandbox); + let data = aData; + if (aData) { + // Run JSON.stringify() in the sand box with the principal of the calling + // web page to ensure no cross-origin object is involved. A "Permission + // Denied" error will be thrown in case of privilege violation. + let sandbox = new Cu.Sandbox(Cu.getWebIDLCallerPrincipal()); + sandbox.data = aData; + data = JSON.parse(Cu.evalInSandbox("JSON.stringify(data)", sandbox)); + } let request = this.createRequest(); this._cpmm.sendAsyncMessage("AlarmsManager:Add", { requestId: this.getRequestId(request), date: aDate, ignoreTimezone: isIgnoreTimezone, - data: JSON.parse(data), + data: data, pageURL: this._pageURL, manifestURL: this._manifestURL }); return request; }, remove: function remove(aId) { debug("remove()"); diff --git a/dom/alarm/test/mochitest.ini b/dom/alarm/test/mochitest.ini --- a/dom/alarm/test/mochitest.ini +++ b/dom/alarm/test/mochitest.ini @@ -13,8 +13,10 @@ skip-if = ((buildapp == 'mulet' || build [test_alarm_non_permitted_app.html] [test_alarm_permitted_app.html] [test_alarm_remove.html] skip-if = ((buildapp == 'mulet' || buildapp == 'b2g') && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage [test_bug1015540.html] skip-if = buildapp == 'mulet' || (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage [test_bug1037079.html] skip-if = buildapp == 'mulet' || (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage +[test_bug1090896.html] +skip-if = buildapp == 'mulet' || (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage diff --git a/dom/alarm/test/test_bug1090896.html b/dom/alarm/test/test_bug1090896.html new file mode 100644 --- /dev/null +++ b/dom/alarm/test/test_bug1090896.html @@ -0,0 +1,83 @@ + + + + + Test time alert is fired for Bug 1090896 + + + + +

+ +
+  
+
+ +