Bug 1265836 - Part 1: Replace PlacesUtils.toTime with PlacesUtils.toDate. r=mak, r=aswan
☠☠ backed out by a934331fdba4 ☠ ☠
authorBob Silverberg <bsilverberg@mozilla.com>
Tue, 24 May 2016 08:56:10 -0400
changeset 340130 df90fcacc68caca36628472c0e6450094801e174
parent 340129 46de42653974b623195abc955db67a3e57afe53d
child 340131 800df6b80dc0f1ca053203696e5a9be8722006f3
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [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.
    */