mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 879308 - null date to mozAlarms.add throws exception. r=nsm sr=mounir
--HG-- extra : rebase_source : 538259df2de7483e277e59de8edcefe94f04c0a9
This commit is contained in:
parent
2c00aaf97f
commit
783d0e604b
@ -53,6 +53,10 @@ AlarmsManager.prototype = {
|
||||
throw Components.results.NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!aDate) {
|
||||
throw Components.results.NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
let isIgnoreTimezone = true;
|
||||
switch (aRespectTimezone) {
|
||||
case "honorTimezone":
|
||||
@ -64,7 +68,7 @@ AlarmsManager.prototype = {
|
||||
break;
|
||||
|
||||
default:
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
throw Components.results.NS_ERROR_INVALID_ARG;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -25,23 +25,26 @@
|
||||
} catch (e) {
|
||||
ok(false,
|
||||
"Unexpected exception trying to add alarm for tomorrow.");
|
||||
|
||||
// Proceed to next test.
|
||||
return testPastDate();
|
||||
}
|
||||
domRequest.onsuccess = function(e) {
|
||||
navigator.mozAlarms.remove(e.target.result);
|
||||
ok(true, "Add alarm for future date.");
|
||||
|
||||
// Awesome, no error so proceed to next test
|
||||
// Awesome, no error so proceed to next test.
|
||||
testPastDate();
|
||||
};
|
||||
domRequest.onerror = function(e) {
|
||||
ok(false, "Unable to add alarm for tomorrow`.");
|
||||
|
||||
// Proceed to next test.
|
||||
testPastDate();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// Verify passing a Date that's already past fails
|
||||
// Verify passing a Date that's already past doesn't fail (it should fire immediately).
|
||||
function testPastDate() {
|
||||
var yesterday = new Date();
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
@ -52,61 +55,61 @@
|
||||
} catch (e) {
|
||||
ok(false,
|
||||
"Unexpected exception trying to add alarm for yesterday.");
|
||||
return testNull();
|
||||
|
||||
// Move on to the next test.
|
||||
testNullDate();
|
||||
}
|
||||
domRequest.onsuccess = function(e) {
|
||||
navigator.mozAlarms.remove(e.target.result);
|
||||
|
||||
ok(true, "Should be able to add alarm for already past date, which should fire immediately.");
|
||||
testNull();
|
||||
|
||||
// Move on to the next test.
|
||||
testNullDate();
|
||||
};
|
||||
domRequest.onerror = function(e) {
|
||||
ok(false, "Unable to add alarm for yesterday.");
|
||||
|
||||
// Errors as it should, on to the next test
|
||||
testNull();
|
||||
// Move on to the next test.
|
||||
testNullDate();
|
||||
}
|
||||
}
|
||||
|
||||
// Verify passing null does indeed fail
|
||||
function testNull() {
|
||||
var domRequest;
|
||||
function testNullDate() {
|
||||
try {
|
||||
domRequest = navigator.mozAlarms.add(null, "honorTimezone", {});
|
||||
navigator.mozAlarms.add(null, "honorTimezone", {});
|
||||
ok(false, "Expected an exception to be thrown for alarm with null date.");
|
||||
} catch(e) {
|
||||
ok(false, "Unexpected exception thrown while testing null case.");
|
||||
|
||||
// Exception thrown
|
||||
return SimpleTest.finish();
|
||||
ok(true, "Exception thrown for alarm with null date.");
|
||||
}
|
||||
domRequest.onsuccess = function(e) {
|
||||
// Null should not be valid
|
||||
ok(false, "Null should not be accepted as input for `date` param.");
|
||||
SimpleTest.finish();
|
||||
};
|
||||
domRequest.onerror = function(e) {
|
||||
// Null should not be valid
|
||||
ok(true, "Passing null for date value causes failure.");
|
||||
|
||||
// Move on to the next test.
|
||||
testInvalidTimeZone()
|
||||
}
|
||||
|
||||
function testInvalidTimeZone() {
|
||||
try {
|
||||
navigator.mozAlarms.add(new Date(), "badTimeZoneArg", {});
|
||||
ok(false, "Expected an exception to be thrown while testing bad time zone arg.");
|
||||
} catch(e) {
|
||||
ok(true, "Exception thrown while testing bad time zone arg.");
|
||||
}
|
||||
SimpleTest.finish();
|
||||
};
|
||||
}
|
||||
|
||||
function startTests() {
|
||||
|
||||
SpecialPowers.pushPrefEnv({"set": [["dom.mozAlarms.enabled", true]]}, function() {
|
||||
|
||||
// Currently applicable only on FxOS
|
||||
if (navigator.userAgent.indexOf("Mobile") != -1 &&
|
||||
navigator.appVersion.indexOf("Android") == -1) {
|
||||
|
||||
navigator.appVersion.indexOf("Android") == -1)
|
||||
{
|
||||
testFutureDate();
|
||||
|
||||
} else {
|
||||
ok(true, "mozAlarms on Firefox OS only.");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user