Bug 1209654 - Modify the type of the threshold of addAlarm() and getAllAlarms() to long long from long, and add test cases. r=ettseng, r=bz

This commit is contained in:
Tim Huang committed 2015-11-12 19:01:00 +01:00
1 parent ce3a7c006d
commit c6ecd7be04
6 files changed
+52 -7

No files matched your search

@@ -6,7 +6,7 @@
interface nsIDOMDOMRequest;
[scriptable, uuid(ceb874cd-cc1a-4e65-b404-cc2d3e42425f)]
[scriptable, uuid(72c4e583-389d-4d1b-9424-702feabb6055)]
interface nsIDOMMozNetworkStatsManager : nsISupports
{
/**
@@ -40,7 +40,7 @@ interface nsIDOMMozNetworkStatsManager : nsISupports
* If success, the |result| field of the DOMRequest keeps the alarm Id.
*/
nsIDOMDOMRequest addAlarm(in nsISupports network,
in long threshold,
in long long threshold,
[optional] in jsval options /* NetworkStatsAlarmOptions */);
/**
@@ -147,6 +147,51 @@ var steps = [
ok(false, "getAllAlarms() shouldn't fail.");
}
},
// Bug 1209654 - Test threshold value will overflow or not for 2^32.
function () {
ok(true, "Calling addAlarm() with threshold greater than 4GiB");
req = navigator.mozNetworkStats
.addAlarm(new window.MozNetworkStatsInterface(wifi), 5000000000);
req.onsuccess = function () {
ok(true, "Succeeded to add alarm. AlarmId: " + req.result);
next();
};
req.onerror = function () {
ok(false, "addAlarm() shouldn't fail.");
};
},
function () {
ok(true, "Calling getAllAlarms() and check threshold.");
req = navigator.mozNetworkStats.getAllAlarms();
req.onsuccess = function () {
ok(Array.isArray(req.result) && req.result[0].threshold == 5000000000,
"Succeeded to check threshold.");
next();
};
req.onerror = function () {
ok(false, "getAllAlarms() shouldn't fail.");
}
},
// Bug 1209654 - Test threshold value will overflow or not for signed long.
function () {
ok(true, "Calling addAlarm() with threshold 3 Gib");
req = navigator.mozNetworkStats
.addAlarm(new window.MozNetworkStatsInterface(wifi), 3000000000);
req.onsuccess = function () {
ok(true, "Succeeded to add alarm. AlarmId: " + req.result);
next();
};
req.onerror = function () {
ok(false, "addAlarm() shouldn't fail.");
};
},
function () {
ok(true, "all done!\n");
SimpleTest.finish();
+1 -1
View File
@@ -734,7 +734,7 @@ void NetworkUtils::setAlarm(CommandChain* aChain,
NetworkResultOptions& aResult)
{
char command[MAX_COMMAND_SIZE];
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth setinterfacealert %s %ld", GET_CHAR(mIfname), GET_FIELD(mThreshold));
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "bandwidth setinterfacealert %s %lld", GET_CHAR(mIfname), GET_FIELD(mThreshold));
doCommand(command, aChain, aCallback);
}
+2 -2
View File
@@ -157,7 +157,7 @@ interface nsIDhcpRequestCallback : nsISupports
/**
* Provide network services.
*/
[scriptable, uuid(8f689d9f-30c0-4809-8bf6-87120e71f3ee)]
[scriptable, uuid(bb929ae3-4a42-4a63-8388-97c4de69200e)]
interface nsINetworkService : nsISupports
{
const long MODIFY_ROUTE_ADD = 0;
@@ -228,7 +228,7 @@ interface nsINetworkService : nsISupports
* @return false if there is no interface registered for the networkType param.
*/
boolean setNetworkInterfaceAlarm(in DOMString networkName,
in long threshold,
in long long threshold,
in nsINetworkUsageAlarmCallback callback);
/**
+1 -1
View File
@@ -9,6 +9,6 @@
interface MozNetworkStatsAlarm {
readonly attribute unsigned long alarmId;
readonly attribute MozNetworkStatsInterface network;
readonly attribute long threshold;
readonly attribute long long threshold;
readonly attribute any data;
};
+1 -1
View File
@@ -38,7 +38,7 @@ dictionary NetworkCommandOptions
DOMString usbEndIp; // for "setWifiTethering".
DOMString dns1; // for "setWifiTethering".
DOMString dns2; // for "setWifiTethering".
long threshold; // for "setNetworkInterfaceAlarm",
long long threshold; // for "setNetworkInterfaceAlarm",
// "enableNetworkInterfaceAlarm".
DOMString startIp; // for "setDhcpServer".
DOMString endIp; // for "setDhcpServer".