Bug 1265836 - Part 1: Replace PlacesUtils.toTime with PlacesUtils.toDate. r=mak, r=aswan
authorBob Silverberg <bsilverberg@mozilla.com>
Tue, 24 May 2016 08:56:10 -0400
changeset 339198 50edd919870a15dd9e2bd31441882ad18111c1c4
parent 339197 79031b5fc3cac79bd7b5b6fd37049a4adb0c1ed1
child 339199 e83eea3e0b6a99fa52c1c5db4b2db91f2029cf12
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak, aswan
bugs1265836
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1265836 - Part 1: Replace PlacesUtils.toTime with PlacesUtils.toDate. r=mak, r=aswan MozReview-Commit-ID: FZTfDJpjEt1
browser/components/extensions/ext-history.js
browser/components/extensions/test/browser/browser_ext_history.js
toolkit/components/places/PlacesUtils.jsm
--- a/browser/components/extensions/ext-history.js
+++ b/browser/components/extensions/ext-history.js
@@ -19,17 +19,17 @@ const {
  *
  * https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsINavHistoryResultNode
  */
 function convertNavHistoryResultNode(node) {
   return {
     id: node.pageGuid,
     url: node.uri,
     title: node.title,
-    lastVisitTime: PlacesUtils.toTime(node.time),
+    lastVisitTime: PlacesUtils.toDate(node.time).getTime(),
     visitCount: node.accessCount,
   };
 }
 
 /*
  * Converts a nsINavHistoryContainerResultNode into an array of objects
  *
  * https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsINavHistoryContainerResultNode
--- a/browser/components/extensions/test/browser/browser_ext_history.js
+++ b/browser/components/extensions/test/browser/browser_ext_history.js
@@ -66,30 +66,30 @@ add_task(function* test_delete() {
   let testUrl = visits[6].uri.spec;
   ok(yield PlacesTestUtils.isPageInDB(testUrl), "expected url found in history database");
 
   extension.sendMessage("delete-url", testUrl);
   yield extension.awaitMessage("url-deleted");
   is(yield PlacesTestUtils.isPageInDB(testUrl), false, "expected url not found in history database");
 
   let filter = {
-    startTime: PlacesUtils.toTime(visits[1].visitDate),
-    endTime: PlacesUtils.toTime(visits[3].visitDate),
+    startTime: PlacesUtils.toDate(visits[1].visitDate).valueOf(),
+    endTime: PlacesUtils.toDate(visits[3].visitDate).valueOf(),
   };
 
   extension.sendMessage("delete-range", filter);
   yield extension.awaitMessage("range-deleted");
 
   ok(yield PlacesTestUtils.isPageInDB(visits[0].uri), "expected uri found in history database");
   is(yield PlacesTestUtils.visitsInDB(visits[0].uri), 2, "2 visits for uri found in history database");
   ok(yield PlacesTestUtils.isPageInDB(visits[5].uri), "expected uri found in history database");
   is(yield PlacesTestUtils.visitsInDB(visits[5].uri), 1, "1 visit for uri found in history database");
 
-  filter.startTime = PlacesUtils.toTime(visits[0].visitDate);
-  filter.endTime = PlacesUtils.toTime(visits[5].visitDate);
+  filter.startTime = PlacesUtils.toDate(visits[0].visitDate).valueOf();
+  filter.endTime = PlacesUtils.toDate(visits[5].visitDate).valueOf();
 
   extension.sendMessage("delete-range", filter);
   yield extension.awaitMessage("range-deleted");
 
   is(yield PlacesTestUtils.isPageInDB(visits[0].uri), false, "expected uri not found in history database");
   is(yield PlacesTestUtils.visitsInDB(visits[0].uri), 0, "0 visits for uri found in history database");
   is(yield PlacesTestUtils.isPageInDB(visits[5].uri), false, "expected uri not found in history database");
   is(yield PlacesTestUtils.visitsInDB(visits[5].uri), 0, "0 visits for uri found in history database");
--- a/toolkit/components/places/PlacesUtils.jsm
+++ b/toolkit/components/places/PlacesUtils.jsm
@@ -267,25 +267,24 @@ this.PlacesUtils = {
    *        the Date object to convert.
    * @return microseconds from the epoch.
    */
   toPRTime(date) {
     return date * 1000;
   },
 
   /**
-   * Convert a PRTime to a time.
+   * Convert a PRTime to a Date object.
    *
    * @param time
    *        microseconds from the epoch.
-   * @return time
-   *        milliseconds from the epoch.
+   * @return a Date object.
    */
-  toTime(time) {
-    return time / 1000;
+  toDate(time) {
+    return new Date(parseInt(time / 1000));
   },
 
   /**
    * Wraps a string in a nsISupportsString wrapper.
    * @param   aString
    *          The string to wrap.
    * @returns A nsISupportsString object containing a string.
    */