diff options
author | skerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 17:38:24 +0000 |
---|---|---|
committer | skerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 17:38:24 +0000 |
commit | dc971bf9d33739884185bf29903eb52f107f4e5c (patch) | |
tree | 45fca8205cdf925310f18ec3bf2e3da44a047233 | |
parent | 6bf115b22a259d1a86fb405320c4ce793d583e57 (diff) | |
download | chromium_src-dc971bf9d33739884185bf29903eb52f107f4e5c.zip chromium_src-dc971bf9d33739884185bf29903eb52f107f4e5c.tar.gz chromium_src-dc971bf9d33739884185bf29903eb52f107f4e5c.tar.bz2 |
History APIs that parse a time as a number of milliseconds need to allow integer numbers.
BUG=38994
TEST=ExtensionApiTest.FLAKY_History
Review URL: http://codereview.chromium.org/1221001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42486 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/extensions/extension_history_api.cc | 9 | ||||
-rw-r--r-- | chrome/test/data/extensions/api_test/history/test.js | 13 |
2 files changed, 19 insertions, 3 deletions
diff --git a/chrome/browser/extensions/extension_history_api.cc b/chrome/browser/extensions/extension_history_api.cc index 08c6cec..7edbf14 100644 --- a/chrome/browser/extensions/extension_history_api.cc +++ b/chrome/browser/extensions/extension_history_api.cc @@ -168,13 +168,16 @@ bool HistoryFunction::GetUrlFromValue(Value* value, GURL* url) { } bool HistoryFunction::GetTimeFromValue(Value* value, base::Time* time) { - double ms_from_epoch = 0; + double ms_from_epoch = 0.0; if (!value->GetAsReal(&ms_from_epoch)) { - return false; + int ms_from_epoch_as_int = 0; + if (!value->GetAsInteger(&ms_from_epoch_as_int)) + return false; + ms_from_epoch = static_cast<double>(ms_from_epoch_as_int); } // The history service has seconds resolution, while javascript Date() has // milliseconds resolution. - double seconds_from_epoch = ms_from_epoch / 1000; + double seconds_from_epoch = ms_from_epoch / 1000.0; *time = base::Time::FromDoubleT(seconds_from_epoch); return true; } diff --git a/chrome/test/data/extensions/api_test/history/test.js b/chrome/test/data/extensions/api_test/history/test.js index 8f7bed4..250da5c 100644 --- a/chrome/test/data/extensions/api_test/history/test.js +++ b/chrome/test/data/extensions/api_test/history/test.js @@ -188,6 +188,19 @@ chrome.test.runTests([ }); }, + function searchWithIntegerTimes() { + chrome.experimental.history.deleteAll(function() { + // Search with an integer time range. + var query = { 'text': '', + 'startTime': 0, + 'endTime': 12345678 }; + chrome.experimental.history.search(query, function(results) { + assertEq(0, results.length); + chrome.test.succeed(); + }); + }); + }, + // Give time epochs x,y,z and history events A,B which occur in the sequence // x A y B z, this test scopes the search to the interval [y,z] to test that // [x,y) is excluded. The previous test scoped to the interval [x,y]. |