Bug 585152 - Reland Date.now() fractional changes, along with fixed tests. (r=jwalden,dolske,gavin, rs=jwalden)
☠☠ backed out by 6276eb5b2d9c ☠ ☠
authorPaul Biggar <pbiggar>
Fri, 06 Aug 2010 13:35:00 -0700
changeset 67968 b583111a88aa562215eb4f47668d3f94fc09a8f3
parent 67953 d208845094bfd3bb5b02b3de50752cb9c1a26596
child 67969 63ef70c5eeec46892648ca18f31b923b0a8c300e
push id19460
push userjorendorff@mozilla.com
push dateTue, 12 Apr 2011 06:14:14 +0000
treeherdermozilla-central@8aafa888ccd5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalden, dolske, gavin, jwalden
bugs585152
milestone2.2a1pre
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 585152 - Reland Date.now() fractional changes, along with fixed tests. (r=jwalden,dolske,gavin, rs=jwalden) For the tests, I put a Math.floor around anything which looked like it did string concatenation. In principal that was r+ by dolske and gavin, and jwalden r+ed the extension to the rest of the tests. Backout policy: the jsdate.cpp changes can be backed out trivially. The test changes should backout cleanly, but we're not hosed if they don't.
browser/base/content/tabbrowser.xml
browser/base/content/test/browser_inspector_domPanel.js
browser/components/places/tests/unit/test_placesTxn.js
browser/components/sessionstore/src/nsSessionStore.js
browser/components/sessionstore/test/browser/browser_248970_b.js
browser/components/sessionstore/test/browser/browser_345898.js
browser/components/sessionstore/test/browser/browser_346337.js
browser/components/sessionstore/test/browser/browser_350525.js
browser/components/sessionstore/test/browser/browser_393716.js
browser/components/sessionstore/test/browser/browser_394759.js
browser/components/sessionstore/test/browser/browser_394759_privatebrowsing.js
browser/components/sessionstore/test/browser/browser_448741.js
browser/components/sessionstore/test/browser/browser_459906.js
browser/components/sessionstore/test/browser/browser_465215.js
browser/components/sessionstore/test/browser/browser_465223.js
browser/components/sessionstore/test/browser/browser_476161.js
browser/components/sessionstore/test/browser/browser_477657.js
browser/components/sessionstore/test/browser/browser_524745.js
browser/components/sessionstore/test/browser/browser_586068-cascaded_restore.js
browser/components/sessionstore/test/browser/browser_590268.js
browser/components/sessionstore/test/browser/browser_607016.js
browser/components/sessionstore/test/browser/head.js
content/base/test/test_CrossSiteXHR_cache.html
content/html/content/test/test_bug209275.xhtml
content/html/content/test/test_bug481335.xhtml
docshell/test/bug413310-post.sjs
dom/tests/mochitest/whatwg/test_bug500328.html
extensions/cookie/test/unit/test_permmanager_expiration.js
extensions/cookie/test/unit/test_permmanager_notifications.js
js/src/jsdate.cpp
layout/tools/reftest/reftest.js
toolkit/components/console/hudservice/HUDService.jsm
toolkit/components/console/hudservice/tests/browser/browser_webconsole_basic_net_logging.js
toolkit/components/console/hudservice/tests/browser/browser_webconsole_bug_583816_tab_focus.js
toolkit/components/downloads/test/unit/test_bug_401430.js
toolkit/content/widgets/toolbar.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -1260,17 +1260,17 @@
             // Add the Message and the Browser to the box
             var notificationbox = document.createElementNS(
                                     "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
                                     "notificationbox");
             notificationbox.setAttribute("flex", "1");
             notificationbox.appendChild(stack);
 
             var position = this.tabs.length - 1;
-            var uniqueId = "panel" + Date.now() + position;
+            var uniqueId = "panel" + Math.floor(Date.now()) + position;
             notificationbox.id = uniqueId;
             t.linkedPanel = uniqueId;
             t.linkedBrowser = b;
             t._tPos = position;
             if (t.previousSibling.selected)
               t.setAttribute("afterselected", true);
 
             // NB: this appendChild call causes us to run constructors for the
@@ -2403,17 +2403,17 @@
       </method>
 
       <constructor>
         <![CDATA[
           this.mCurrentBrowser = this.mPanelContainer.childNodes[0].firstChild.firstChild;
           this.mCurrentTab = this.tabContainer.firstChild;
           document.addEventListener("keypress", this, false);
 
-          var uniqueId = "panel" + Date.now();
+          var uniqueId = "panel" + Math.floor(Date.now());
           this.mPanelContainer.childNodes[0].id = uniqueId;
           this.mCurrentTab.linkedPanel = uniqueId;
           this.mCurrentTab._tPos = 0;
           this.mCurrentTab.linkedBrowser = this.mCurrentBrowser;
 
           // set up the shared autoscroll popup
           this._autoScrollPopup = this.mCurrentBrowser._createAutoScrollPopup();
           this._autoScrollPopup.id = "autoscroller";
--- a/browser/base/content/test/browser_inspector_domPanel.js
+++ b/browser/base/content/test/browser_inspector_domPanel.js
@@ -60,35 +60,35 @@ function createDocument()
   doc.title = "Inspector DOM Test";
   Services.obs.addObserver(runDOMTests, "inspector-opened", false);
   InspectorUI.openInspectorUI();
 }
 
 function nodeGenerator()
 {
   let body = doc.body;
-  newProperty = "rand" + Date.now();
+  newProperty = "rand" + Math.floor(Date.now());
   body[newProperty] = Math.round(Math.random() * 100);
   InspectorUI.inspectNode(body);
   yield;
 
   let h1 = doc.querySelector("h1");
-  newProperty = "rand2" + Date.now();
+  newProperty = "rand2" + Math.floor(Date.now());
   h1[newProperty] = "test" + Math.random();
   InspectorUI.inspectNode(h1);
   yield;
 
   let first = doc.getElementById("first");
-  newProperty = "rand3" + Date.now();
+  newProperty = "rand3" + Math.floor(Date.now());
   first[newProperty] = null;
   InspectorUI.inspectNode(first);
   yield;
 
   let closing = doc.getElementById("closing");
-  newProperty = "bazbaz" + Date.now();
+  newProperty = "bazbaz" + Math.floor(Date.now());
   closing[newProperty] = false;
   InspectorUI.inspectNode(closing);
   yield;
 }
 
 function runDOMTests()
 {
   InspectorUI._log("runDOMtests");
--- a/browser/components/places/tests/unit/test_placesTxn.js
+++ b/browser/components/places/tests/unit/test_placesTxn.js
@@ -95,16 +95,21 @@ var observer = {
   }
 };
 bmsvc.addObserver(observer, false);
 
 // index at which items should begin
 var bmStartIndex = 0;
 
 // main
+
+function time() {
+    return (new Date()).getTime();
+}
+
 function run_test() {
   // get bookmarks root index
   var root = bmsvc.bookmarksMenuFolder;
 
   //Test creating a folder with a description
   const TEST_DESCRIPTION = "this is my test description";
   var annos = [{ name: PlacesUIUtils.DESCRIPTION_ANNO,
                  type: annosvc.TYPE_STRING,
@@ -532,17 +537,17 @@ function run_test() {
   // Test generic page annotation
   var pageAnnoObj = { name: "testAnno/testInt",
                       type: Ci.nsIAnnotationService.TYPE_INT32,
                       flags: 0,
                       value: 123,
                       expires: Ci.nsIAnnotationService.EXPIRE_NEVER };
   var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
            getService(Ci.nsINavHistoryService);
-  hs.addVisit(uri("http://www.mozilla.org/"), Date.now() * 1000, null,
+  hs.addVisit(uri("http://www.mozilla.org/"), time() * 1000, null,
               hs.TRANSITION_TYPED, false, 0);
   var genPageAnnoTxn = ptSvc.setPageAnnotation(uri("http://www.mozilla.org/"), pageAnnoObj);
   genPageAnnoTxn.doTransaction();
   do_check_true(annosvc.pageHasAnnotation(uri("http://www.mozilla.org/"), "testAnno/testInt"));
   genPageAnnoTxn.undoTransaction();
   do_check_false(annosvc.pageHasAnnotation(uri("http://www.mozilla.org/"), "testAnno/testInt"));
   genPageAnnoTxn.redoTransaction();
   do_check_true(annosvc.pageHasAnnotation(uri("http://www.mozilla.org/"), "testAnno/testInt"));
@@ -607,26 +612,26 @@ function run_test() {
   postDataTxn.doTransaction();
   do_check_true(annosvc.itemHasAnnotation(postDataId, POST_DATA_ANNO))
   do_check_eq(annosvc.getItemAnnotation(postDataId, POST_DATA_ANNO), postData);
   postDataTxn.undoTransaction();
   do_check_false(annosvc.itemHasAnnotation(postDataId, POST_DATA_ANNO))
 
   // Test editing item date added
   var oldAdded = bmsvc.getItemDateAdded(bkmk1Id);
-  var newAdded = Date.now();
+  var newAdded = time();
   var eidaTxn = ptSvc.editItemDateAdded(bkmk1Id, newAdded);
   eidaTxn.doTransaction();
   do_check_eq(newAdded, bmsvc.getItemDateAdded(bkmk1Id));
   eidaTxn.undoTransaction();
   do_check_eq(oldAdded, bmsvc.getItemDateAdded(bkmk1Id));
 
   // Test editing item last modified 
   var oldModified = bmsvc.getItemLastModified(bkmk1Id);
-  var newModified = Date.now();
+  var newModified = time();
   var eilmTxn = ptSvc.editItemLastModified(bkmk1Id, newModified);
   eilmTxn.doTransaction();
   do_check_eq(newModified, bmsvc.getItemLastModified(bkmk1Id));
   eilmTxn.undoTransaction();
   do_check_eq(oldModified, bmsvc.getItemLastModified(bkmk1Id));
 
   // Test tagURI/untagURI
   var tagURI = uri("http://foo.tld");
@@ -724,17 +729,17 @@ function run_test() {
   do_check_eq(bmsvc.getItemType(newBkmk3_3Id), bmsvc.TYPE_FOLDER);
   do_check_eq(bmsvc.getItemTitle(newBkmk3_3Id), "folder");
   // Check last added back item id.
   // Notice items are restored in reverse order.
   do_check_eq(observer._itemAddedId, newBkmk1Id);
 
   // Test creating an item with child transactions.
   var childTxns = [];
-  var newDateAdded = Date.now() - 20000;
+  var newDateAdded = time() - 20000;
   childTxns.push(ptSvc.editItemDateAdded(null, newDateAdded));
   var itemChildAnnoObj = { name: "testAnno/testInt",
                            type: Ci.nsIAnnotationService.TYPE_INT32,
                            flags: 0,
                            value: 123,
                            expires: Ci.nsIAnnotationService.EXPIRE_NEVER };
   childTxns.push(ptSvc.setItemAnnotation(null, itemChildAnnoObj));
   var itemWChildTxn = ptSvc.createItem(uri("http://www.example.com"), root,
--- a/browser/components/sessionstore/src/nsSessionStore.js
+++ b/browser/components/sessionstore/src/nsSessionStore.js
@@ -708,17 +708,17 @@ SessionStoreService.prototype = {
       return;
 
     // ignore non-browser windows and windows opened while shutting down
     if (aWindow.document.documentElement.getAttribute("windowtype") != "navigator:browser" ||
         this._loadState == STATE_QUITTING)
       return;
 
     // assign it a unique identifier (timestamp)
-    aWindow.__SSi = "window" + Date.now();
+    aWindow.__SSi = "window" + Math.floor(Date.now());
 
     // and create its data object
     this._windows[aWindow.__SSi] = { tabs: [], selected: 0, _closedTabs: [] };
     if (!this._isWindowLoaded(aWindow))
       this._windows[aWindow.__SSi]._restoring = true;
     if (!aWindow.toolbar.visible)
       this._windows[aWindow.__SSi].isPopup = true;
     
@@ -3746,17 +3746,17 @@ SessionStoreService.prototype = {
         // - _closedTabs
         // - extData
         // - isPopup
         // - hidden
 
         // Assign a unique ID to correlate the window to be opened with the
         // remaining data
         window.__lastSessionWindowID = pinnedWindowState.__lastSessionWindowID
-                                     = "" + Date.now() + Math.random();
+                                     = "" + Math.floor(Date.now()) + Math.random();
 
         // Extract the cookies that belong with each pinned tab
         this._splitCookiesFromWindow(window, pinnedWindowState);
 
         // Actually add this window to our defaultState
         defaultState.windows.push(pinnedWindowState);
         // Remove the window from the state if it doesn't have any tabs
         if (!window.tabs.length) {
--- a/browser/components/sessionstore/test/browser/browser_248970_b.js
+++ b/browser/components/sessionstore/test/browser/browser_248970_b.js
@@ -46,17 +46,17 @@ function test() {
   }
 
   var file = Components.classes["@mozilla.org/file/directory_service;1"]
              .getService(Components.interfaces.nsIProperties)
              .get("TmpD", Components.interfaces.nsIFile);
   filePath = file.path;
 
   let fieldList = {
-    "//input[@name='input']":     Date.now().toString(),
+    "//input[@name='input']":     Math.floor(Date.now()).toString(),
     "//input[@name='spaced 1']":  Math.random().toString(),
     "//input[3]":                 "three",
     "//input[@type='checkbox']":  true,
     "//input[@name='uncheck']":   false,
     "//input[@type='radio'][1]":  false,
     "//input[@type='radio'][2]":  true,
     "//input[@type='radio'][3]":  false,
     "//select":                   2,
--- a/browser/components/sessionstore/test/browser/browser_345898.js
+++ b/browser/components/sessionstore/test/browser/browser_345898.js
@@ -73,13 +73,13 @@ function test() {
   ok(test(function() ss.getWindowValue({}, "")),
      "Invalid window for getWindowValue throws");
   ok(test(function() ss.getWindowValue({}, "")),
      "Invalid window for getWindowValue throws");
   ok(test(function() ss.getWindowValue({}, "", "")),
      "Invalid window for setWindowValue throws");
   ok(test(function() ss.deleteWindowValue({}, "")),
      "Invalid window for deleteWindowValue throws");
-  ok(test(function() ss.deleteWindowValue(window, Date.now().toString())),
+  ok(test(function() ss.deleteWindowValue(window, Math.floor(Date.now()).toString())),
      "Nonexistent value for deleteWindowValue throws");
-  ok(test(function() ss.deleteTabValue(gBrowser.selectedTab, Date.now().toString())),
+  ok(test(function() ss.deleteTabValue(gBrowser.selectedTab, Math.floor(Date.now()).toString())),
      "Nonexistent value for deleteTabValue throws");
 }
--- a/browser/components/sessionstore/test/browser/browser_346337.js
+++ b/browser/components/sessionstore/test/browser/browser_346337.js
@@ -46,17 +46,17 @@ function test() {
   file = Components.classes["@mozilla.org/file/directory_service;1"]
              .getService(Components.interfaces.nsIProperties)
              .get("TmpD", Components.interfaces.nsILocalFile);
   file.append("346337_test2.file");
   file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0666);
   filePath2 = file.path;
   
   let fieldList = {
-    "//input[@name='input']":     Date.now().toString(),
+    "//input[@name='input']":     Math.floor(Date.now()).toString(),
     "//input[@name='spaced 1']":  Math.random().toString(),
     "//input[3]":                 "three",
     "//input[@type='checkbox']":  true,
     "//input[@name='uncheck']":   false,
     "//input[@type='radio'][1]":  false,
     "//input[@type='radio'][2]":  true,
     "//input[@type='radio'][3]":  false,
     "//select":                   2,
--- a/browser/components/sessionstore/test/browser/browser_350525.js
+++ b/browser/components/sessionstore/test/browser/browser_350525.js
@@ -19,17 +19,17 @@ function test() {
   
   // service
   let ss = test(function() ssComponent.getService(Ci.nsISessionStore));
   ok(ss, "reference the sessionstore service");
   
   ////////////////////////////
   // setWindowValue, et al. //
   ////////////////////////////
-  let key = "Unique name: " + Date.now();
+  let key = "Unique name: " + Math.floor(Date.now());
   let value = "Unique value: " + Math.random();
   
   // test adding
   ok(test(function() ss.setWindowValue(window, key, value)), "set a window value");
   
   // test retrieving
   is(ss.getWindowValue(window, key), value, "stored window value matches original");
   
@@ -38,17 +38,17 @@ function test() {
   
   // value should not exist post-delete
   is(ss.getWindowValue(window, key), "", "window value was deleted");
   
   /////////////////////////
   // setTabValue, et al. //
   /////////////////////////
   key = "Unique name: " + Math.random();
-  value = "Unique value: " + Date.now();
+  value = "Unique value: " + Math.floor(Date.now());
   let tab = tabbrowser.addTab();
   tab.linkedBrowser.stop();
   
   // test adding
   ok(test(function() ss.setTabValue(tab, key, value)), "store a tab value");
   
   // test retrieving
   is(ss.getTabValue(tab, key), value, "stored tab value match original");
--- a/browser/components/sessionstore/test/browser/browser_393716.js
+++ b/browser/components/sessionstore/test/browser/browser_393716.js
@@ -8,17 +8,17 @@ function test() {
   catch (ex) { }
   ok(ss, "SessionStore service is available");
   let tabbrowser = gBrowser;
   waitForExplicitFinish();
   
   /////////////////
   // getTabState //
   /////////////////
-  let key = "Unique key: " + Date.now();
+  let key = "Unique key: " + Math.floor(Date.now());
   let value = "Unique value: " + Math.random();
   let testURL = "about:config";
   
   // create a new tab
   let tab = tabbrowser.addTab(testURL);
   ss.setTabValue(tab, key, value);
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     this.removeEventListener("load", arguments.callee, true);
@@ -39,17 +39,17 @@ function test() {
     tabbrowser.removeTab(tab);
   }, true);
   
   //////////////////////////////////
   // setTabState and duplicateTab //
   //////////////////////////////////
   let key2 = "key2";
   let value2 = "Value " + Math.random();
-  let value3 = "Another value: " + Date.now();
+  let value3 = "Another value: " + Math.floor(Date.now());
   let state = { entries: [{ url: testURL }], extData: { key2: value2 } };
   
   // create a new tab
   let tab2 = tabbrowser.addTab();
   // set the tab's state
   ss.setTabState(tab2, JSON.stringify(state));
   tab2.linkedBrowser.addEventListener("load", function(aEvent) {
     this.removeEventListener("load", arguments.callee, true);
--- a/browser/components/sessionstore/test/browser/browser_394759.js
+++ b/browser/components/sessionstore/test/browser/browser_394759.js
@@ -55,17 +55,17 @@ function test() {
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
   let pb = Cc["@mozilla.org/privatebrowsing;1"].getService(Ci.nsIPrivateBrowsingService);
   waitForExplicitFinish();
   
   function test_basic(callback) {
   
     let testURL = "about:config";
     let uniqueKey = "bug 394759";
-    let uniqueValue = "unik" + Date.now();
+    let uniqueValue = "unik" + Math.floor(Date.now());
     let uniqueText = "pi != " + Math.random();
   
   
     // make sure that the next closed window will increase getClosedWindowCount
     let max_windows_undo = gPrefService.getIntPref("browser.sessionstore.max_windows_undo");
     gPrefService.setIntPref("browser.sessionstore.max_windows_undo", max_windows_undo + 1);
     let closedWindowCount = ss.getClosedWindowCount();
   
--- a/browser/components/sessionstore/test/browser/browser_394759_privatebrowsing.js
+++ b/browser/components/sessionstore/test/browser/browser_394759_privatebrowsing.js
@@ -100,17 +100,17 @@ function continue_test() {
   ok(!pb.privateBrowsingEnabled, "Private Browsing is disabled");
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].
            getService(Ci.nsISessionStore);
 
   let closedWindowCount = ss.getClosedWindowCount();
   is(closedWindowCount, 0, "Correctly set window count");
 
   // Prevent VM timers issues, cache now and increment it manually.
-  let now = Date.now();
+  let now = Math.floor(Date.now());
   const TESTS = [
     { url: "about:config",
       key: "bug 394759 Non-PB",
       value: "uniq" + (++now) },
     { url: "about:mozilla",
       key: "bug 394759 PB",
       value: "uniq" + (++now) },
   ];
--- a/browser/components/sessionstore/test/browser/browser_448741.js
+++ b/browser/components/sessionstore/test/browser/browser_448741.js
@@ -37,17 +37,17 @@
 function test() {
   /** Test for Bug 448741 **/
 
   // test setup
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
   waitForExplicitFinish();
 
   let uniqueName = "bug 448741";
-  let uniqueValue = "as good as unique: " + Date.now();
+  let uniqueValue = "as good as unique: " + Math.floor(Date.now());
 
   // set a unique value on a new, blank tab
   var tab = gBrowser.addTab();
   tab.linkedBrowser.stop();
   ss.setTabValue(tab, uniqueName, uniqueValue);
   let valueWasCleaned = false;
 
   // prevent our value from being written to disk
--- a/browser/components/sessionstore/test/browser/browser_459906.js
+++ b/browser/components/sessionstore/test/browser/browser_459906.js
@@ -36,17 +36,17 @@
 
 function test() {
   /** Test for Bug 459906 **/
 
   waitForExplicitFinish();
 
   let testURL = "http://mochi.test:8888/browser/" +
     "browser/components/sessionstore/test/browser/browser_459906_sample.html";
-  let uniqueValue = "<b>Unique:</b> " + Date.now();
+  let uniqueValue = "<b>Unique:</b> " + Math.floor(Date.now());
 
   var frameCount = 0;
   let tab = gBrowser.addTab(testURL);
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     // wait for all frames to load completely
     if (frameCount++ < 2)
       return;
     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
--- a/browser/components/sessionstore/test/browser/browser_465215.js
+++ b/browser/components/sessionstore/test/browser/browser_465215.js
@@ -36,17 +36,17 @@
 
 function test() {
   /** Test for Bug 465215 **/
   
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
   waitForExplicitFinish();
   
   let uniqueName = "bug 465215";
-  let uniqueValue1 = "as good as unique: " + Date.now();
+  let uniqueValue1 = "as good as unique: " + Math.floor(Date.now());
   let uniqueValue2 = "as good as unique: " + Math.random();
   
   // set a unique value on a new, blank tab
   let tab1 = gBrowser.addTab();
   tab1.linkedBrowser.addEventListener("load", function() {
     tab1.linkedBrowser.removeEventListener("load", arguments.callee, true);
     ss.setTabValue(tab1, uniqueName, uniqueValue1);
     
--- a/browser/components/sessionstore/test/browser/browser_465223.js
+++ b/browser/components/sessionstore/test/browser/browser_465223.js
@@ -49,17 +49,17 @@ function test() {
   is(browserWindowsCount(), 1, "Only one browser window should be open initially");
   
   // test setup
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
   waitForExplicitFinish();
   
   let uniqueKey1 = "bug 465223.1";
   let uniqueKey2 = "bug 465223.2";
-  let uniqueValue1 = "unik" + Date.now();
+  let uniqueValue1 = "unik" + Math.floor(Date.now());
   let uniqueValue2 = "pi != " + Math.random();
   
   // open a window and set a value on it
   let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
   newWin.addEventListener("load", function(aEvent) {
     ss.setWindowValue(newWin, uniqueKey1, uniqueValue1);
     
     let newState = { windows: [{ tabs:[{ entries: [] }], extData: {} }] };
--- a/browser/components/sessionstore/test/browser/browser_476161.js
+++ b/browser/components/sessionstore/test/browser/browser_476161.js
@@ -42,17 +42,17 @@ function test() {
   let testURL = "http://mochi.test:8888/browser/" +
     "browser/components/sessionstore/test/browser/browser_476161_sample.html";
   let tab = gBrowser.addTab(testURL);
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
     let doc = tab.linkedBrowser.contentDocument;
     
     doc.getElementById("modify1").value += Math.random();
-    doc.getElementById("modify2").value += " " + Date.now();
+    doc.getElementById("modify2").value += " " + Math.floor(Date.now());
     
     let tab2 = gBrowser.duplicateTab(tab);
     tab2.linkedBrowser.addEventListener("load", function(aEvent) {
       tab2.linkedBrowser.removeEventListener("load", arguments.callee, true);
       let doc = tab2.linkedBrowser.contentDocument;
       let changed = doc.getElementById("changed").textContent.trim().split();
       
       is(changed.sort().join(" "), "modify1 modify2",
--- a/browser/components/sessionstore/test/browser/browser_477657.js
+++ b/browser/components/sessionstore/test/browser/browser_477657.js
@@ -62,17 +62,17 @@ function test() {
       _closedTabs: [{
         state: { entries: [{ url: "about:" }]},
         title: "About:"
       }],
       sizemode: "maximized"
     }] };
     
     let uniqueKey = "bug 477657";
-    let uniqueValue = "unik" + Date.now();
+    let uniqueValue = "unik" + Math.floor(Date.now());
   
     ss.setWindowValue(newWin, uniqueKey, uniqueValue);
     is(ss.getWindowValue(newWin, uniqueKey), uniqueValue,
        "window value was set before the window was overwritten");
     ss.setWindowState(newWin, JSON.stringify(newState), true);
     
     // use setTimeout(..., 0) to mirror sss_restoreWindowFeatures
     setTimeout(function() {
--- a/browser/components/sessionstore/test/browser/browser_524745.js
+++ b/browser/components/sessionstore/test/browser/browser_524745.js
@@ -47,17 +47,17 @@ function browserWindowsCount() {
 
 function test() {
   /** Test for Bug 524745 **/
   is(browserWindowsCount(), 1, "Only one browser window should be open initially");
 
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].
            getService(Ci.nsISessionStore);
   let uniqKey = "bug524745";
-  let uniqVal = Date.now();
+  let uniqVal = Math.floor(Date.now());
 
   waitForExplicitFinish();
 
   let window_B = openDialog(location, "_blank", "chrome,all,dialog=no");
   window_B.addEventListener("load", function(aEvent) {
     window_B.removeEventListener("load", arguments.callee, false);
 
       waitForFocus(function() {
--- a/browser/components/sessionstore/test/browser/browser_586068-cascaded_restore.js
+++ b/browser/components/sessionstore/test/browser/browser_586068-cascaded_restore.js
@@ -756,10 +756,10 @@ function countTabs() {
       else
         wasRestored++;
     }
   }
   return [needsRestore, isRestoring, wasRestored];
 }
 
 function r() {
-  return "" + Date.now() + Math.random();
+  return "" + Math.floor(Date.now()) + Math.random();
 }
--- a/browser/components/sessionstore/test/browser/browser_590268.js
+++ b/browser/components/sessionstore/test/browser/browser_590268.js
@@ -1,9 +1,10 @@
 /* ***** BEGIN LICENSE BLOCK *****
+ *
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla Public License Version
  * 1.1 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  * http://www.mozilla.org/MPL/
  *
  * Software distributed under the License is distributed on an "AS IS" basis,
@@ -168,10 +169,10 @@ function test() {
   gBrowser.tabContainer.addEventListener("SSTabRestored", onSSTabRestored, true);
   gBrowser.tabContainer.addEventListener("TabOpen", onTabOpen, false);
   // Restore state
   ss.setBrowserState(JSON.stringify(state));
 }
 
 // Helper function to create a random value
 function r() {
-  return "" + Date.now() + Math.random();
+  return "" + Math.floor(Date.now()) + Math.random();
 }
--- a/browser/components/sessionstore/test/browser/browser_607016.js
+++ b/browser/components/sessionstore/test/browser/browser_607016.js
@@ -145,10 +145,10 @@ function test() {
   }
 
   window.gBrowser.addTabsProgressListener(progressListener);
   ss.setBrowserState(JSON.stringify(state));
 }
 
 // Helper function to create a random value
 function r() {
-  return "" + Date.now() + Math.random();
+  return "" + Math.floor(Date.now()) + Math.random();
 }
--- a/browser/components/sessionstore/test/browser/head.js
+++ b/browser/components/sessionstore/test/browser/head.js
@@ -95,10 +95,10 @@ function waitForSaveState(aSaveStateCall
   let topic = "sessionstore-state-write";
   Services.obs.addObserver(function() {
     Services.obs.removeObserver(arguments.callee, topic, false);
     executeSoon(aSaveStateCallback);
   }, topic, false);
 };
 
 function r() {
-  return Date.now() + Math.random();
+  return Math.floor(Date.now()) + Math.random();
 }
--- a/content/base/test/test_CrossSiteXHR_cache.html
+++ b/content/base/test/test_CrossSiteXHR_cache.html
@@ -418,17 +418,17 @@ function runTest() {
              method: "DELETE"
            },
            ];
 
   baseURL = "http://mochi.test:8888/tests/content/base/test/" +
              "file_CrossSiteXHR_cache_server.sjs?";
   setStateURL = baseURL + "setState=";
 
-  var unique = Date.now();
+  var unique = Math.floor(Date.now());
   for each (test in tests) {
     if (test.newTest) {
       unique++;
       continue;
     }
     if (test.pause) {
       setTimeout(function() { gen.next() }, test.pause * 1000);
       yield;
--- a/content/html/content/test/test_bug209275.xhtml
+++ b/content/html/content/test/test_bug209275.xhtml
@@ -108,17 +108,17 @@ function run() {
   var iframeCw = iframe.contentWindow;
 
   // First, set the visited/unvisited link/ellipse colors.
   const unvisitedColor = "rgb(0, 0, 238)";
   const visitedColor = "rgb(85, 26, 139)";
   const unvisitedFill = "rgb(0, 0, 255)";
   const visitedFill = "rgb(128, 0, 128)";
 
-  const rand = Date.now() + "-" + Math.random();
+  const rand = Math.floor(Date.now()) + "-" + Math.random();
 
   // Now we can start the tests in earnest.
 
   var loc = location;
   // everything from the location up to and including the final forward slash
   var path = /(.*\/)[^\/]*/.exec(location)[1];
 
   // Set colorlink's href so we can check that it changes colors after we
--- a/content/html/content/test/test_bug481335.xhtml
+++ b/content/html/content/test/test_bug481335.xhtml
@@ -21,17 +21,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <p id="newparent" xml:base="http://www.example.com/"></p>
 <div id="content" style="display: none"></div>
 <pre id="test">
 <script type="application/javascript;version=1.7">
 <![CDATA[
 
 /** Test for Bug 481335 **/
 SimpleTest.waitForExplicitFinish();
-var rand = Date.now() + "-" + Math.random();
+var rand = Math.floor(Date.now()) + "-" + Math.random();
 
 is($("t").href, "",
    "Unexpected href before set");
 is($("t").href, "",
    "Unexpected cached href before set");
 
 $("t").setAttribute("href", rand);
 is($("t").href,
--- a/docshell/test/bug413310-post.sjs
+++ b/docshell/test/bug413310-post.sjs
@@ -1,7 +1,7 @@
 function handleRequest(request, response) {
   response.setHeader("Content-Type", "text/html");
   response.write("<body onload='window.parent.onloadCount++'>" +
                  request.method + " " +
-		 Date.now() +
+		 Math.floor(Date.now()) +
 		 "</body>");
 }
--- a/dom/tests/mochitest/whatwg/test_bug500328.html
+++ b/dom/tests/mochitest/whatwg/test_bug500328.html
@@ -341,17 +341,17 @@ function runTest() {
   yield;
   enableChildLoadCallback();
   iframeCw.location = "file_bug500328_1.html";
   yield;
   noPopStateExpected("No popstate after re-loading file_bug500328_1.html");
   statusMsg("Done loading file_bug500328_1.html for the second time.");
 
   var ifLink = iframeCw.document.getElementById("link-anchor1");
-  var rand = Date.now() + "-" + Math.random();
+  var rand = Math.floor(Date.now()) + "-" + Math.random();
   ifLink.href = rand;
 
   // Poll the document until the link has the correct color, or this test times
   // out.  Unfortunately I can't come up with a more elegant way to do this.
   // We could listen to MozAfterPaint, but that doesn't guarantee that we'll
   // observe the new color.
   while (getColor(ifLink) != unvisitedColor) {
     // Dump so something shows up in the mochitest logs if we spin here.
--- a/extensions/cookie/test/unit/test_permmanager_expiration.js
+++ b/extensions/cookie/test/unit/test_permmanager_expiration.js
@@ -16,17 +16,17 @@ function continue_test()
 }
 
 function do_run_test() {
   // Set up a profile.
   let profile = do_get_profile();
 
   let pm = Services.permissions;
   let permURI = NetUtil.newURI("http://example.com");
-  let now = Number(Date.now());
+  let now = Math.floor(Date.now());
 
   // add a permission with *now* expiration
   pm.add(permURI, "test/expiration-perm-exp", 1, pm.EXPIRE_TIME, now);
 
   // add a permission with future expiration (100 milliseconds)
   pm.add(permURI, "test/expiration-perm-exp2", 1, pm.EXPIRE_TIME, now + 100);
 
   // add a permission with future expiration (1000 seconds)
--- a/extensions/cookie/test/unit/test_permmanager_notifications.js
+++ b/extensions/cookie/test/unit/test_permmanager_notifications.js
@@ -17,17 +17,17 @@ function continue_test()
 }
 
 function do_run_test() {
   // Set up a profile.
   let profile = do_get_profile();
 
   let pm = Services.permissions;
   let permURI = NetUtil.newURI("http://example.com");
-  let now = Number(Date.now());
+  let now = (new Date()).getTime();
   let permType = "test/expiration-perm";
 
   let observer = new permission_observer(test_generator, now, permType);
   Services.obs.addObserver(observer, "perm-changed", false);
 
   // Add a permission, to test the 'add' notification. Note that we use
   // do_execute_soon() so that we can use our generator to continue the test
   // where we left off.
--- a/js/src/jsdate.cpp
+++ b/js/src/jsdate.cpp
@@ -1184,28 +1184,34 @@ date_parse(JSContext *cx, uintN argc, Va
 }
 
 static inline jsdouble
 NowAsMillis()
 {
     return (jsdouble) (PRMJ_Now() / PRMJ_USEC_PER_MSEC);
 }
 
+static inline jsdouble
+NowAsFractionalsMillis()
+{
+    return (jsdouble) (PRMJ_Now() / double(PRMJ_USEC_PER_MSEC));
+}
+
 static JSBool
 date_now(JSContext *cx, uintN argc, Value *vp)
 {
-    vp->setDouble(NowAsMillis());
+    vp->setDouble(NowAsFractionalsMillis());
     return JS_TRUE;
 }
 
 #ifdef JS_TRACER
 static jsdouble FASTCALL
 date_now_tn(JSContext*)
 {
-    return NowAsMillis();
+    return NowAsFractionalsMillis();
 }
 #endif
 
 /*
  * Get UTC time from the date object. Returns false if the object is not
  * Date type.
  */
 static JSBool
--- a/layout/tools/reftest/reftest.js
+++ b/layout/tools/reftest/reftest.js
@@ -773,17 +773,17 @@ function ServeFiles(manifestURL, depth, 
     var dirPath = "/";
     while (depth > 0) {
         dirPath = "/" + directory.leafName + dirPath;
         directory = directory.parent;
         --depth;
     }
 
     gCount++;
-    var path = "/" + Date.now() + "/" + gCount;
+    var path = "/" + Math.floor(Date.now()) + "/" + gCount;
     gServer.registerDirectory(path + "/", directory);
 
     var secMan = CC[NS_SCRIPTSECURITYMANAGER_CONTRACTID]
                      .getService(CI.nsIScriptSecurityManager);
 
     var testbase = gIOService.newURI("http://localhost:" + HTTP_SERVER_PORT +
                                          path + dirPath,
                                      null, null);
--- a/toolkit/components/console/hudservice/HUDService.jsm
+++ b/toolkit/components/console/hudservice/HUDService.jsm
@@ -4958,17 +4958,17 @@ ConsoleUtils = {
 
   /**
    * Generates a millisecond resolution timestamp.
    *
    * @returns integer
    */
   timestamp: function ConsoleUtils_timestamp()
   {
-    return Date.now();
+    return Math.floor(Date.now());
   },
 
   /**
    * Generates a formatted timestamp string for displaying in console messages.
    *
    * @param integer [ms] Optional, allows you to specify the timestamp in
    * milliseconds since the UNIX epoch.
    * @returns string The timestamp formatted for display.
--- a/toolkit/components/console/hudservice/tests/browser/browser_webconsole_basic_net_logging.js
+++ b/toolkit/components/console/hudservice/tests/browser/browser_webconsole_basic_net_logging.js
@@ -36,17 +36,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 // Tests that the page's resources are displayed in the console as they're
 // loaded
 
-const TEST_NETWORK_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-network.html" + "?_date=" + Date.now();
+const TEST_NETWORK_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-network.html" + "?_date=" + Math.floor(Date.now());
 
 function test() {
   addTab("data:text/html,Web Console basic network logging test");
   browser.addEventListener("load", onLoad, true);
 }
 
 function onLoad(aEvent) {
   browser.removeEventListener(aEvent.type, arguments.callee, true);
--- a/toolkit/components/console/hudservice/tests/browser/browser_webconsole_bug_583816_tab_focus.js
+++ b/toolkit/components/console/hudservice/tests/browser/browser_webconsole_bug_583816_tab_focus.js
@@ -35,17 +35,17 @@ function tabLoad(aEvent) {
 }
 
 function firstTab(aEvent) {
   this.removeEventListener(aEvent.type, arguments.callee, false);
 
   is(inputNode.getAttribute("focused"), "true", "inputNode is still focused");
   isnot(this.value, "doc", "input autocompleted");
 
-  HUD.jsterm.setInputValue("foobarbaz" + Date.now());
+  HUD.jsterm.setInputValue("foobarbaz" + Math.floor(Date.now()));
 
   EventUtils.synthesizeKey("VK_TAB", {});
 
   executeSoon(secondTab);
 }
 
 function secondTab() {
   isnot(inputNode.getAttribute("focused"), "true",
--- a/toolkit/components/downloads/test/unit/test_bug_401430.js
+++ b/toolkit/components/downloads/test/unit/test_bug_401430.js
@@ -39,17 +39,17 @@
 
 const nsIDownloadManager = Ci.nsIDownloadManager;
 const dm = Cc["@mozilla.org/download-manager;1"].getService(nsIDownloadManager);
 
 // Make sure Unicode is supported:
 // U+00E3 : LATIN SMALL LETTER A WITH TILDE
 // U+041B : CYRILLIC CAPITAL LETTER EL
 // U+3056 : HIRAGANA LETTER ZA
-const resultFileName = "test\u00e3\u041b\u3056" + Date.now() + ".doc";
+const resultFileName = "test\u00e3\u041b\u3056" + Math.floor(Date.now()) + ".doc";
 
 // Milliseconds between polls.
 const POLL_REGISTRY_TIMEOUT = 200;
 // Max number of polls.
 const POLL_REGISTRY_MAX_LOOPS = 25;
 
 function checkResult() {
   // delete the saved file (this doesn't affect the "recent documents" list)
--- a/toolkit/content/widgets/toolbar.xml
+++ b/toolkit/content/widgets/toolbar.xml
@@ -291,17 +291,17 @@
               // Handle special cases
               case "separator":
               case "spring":
               case "spacer":
                 newItem = document.createElementNS(XUL_NS, "toolbar" + aId);
                 // Due to timers resolution Date.now() can be the same for
                 // elements created in small timeframes.  So ids are
                 // differentiated through a unique count suffix.
-                newItem.id = aId + Date.now() + (++this._newElementCount);
+                newItem.id = aId + Math.floor(Date.now()) + (++this._newElementCount);
                 if (aId == "spring")
                   newItem.flex = 1;
                 break;
               default:
                 var toolbox = this.toolbox;
                 if (!toolbox)
                   break;