Bug 765235 - [New Tab Page] test suite should make use of underlying storages; r=gavin
authorTim Taubert <tim.taubert@gmx.de>
Sat, 07 Jul 2012 11:55:06 +0200
changeset 98517 eb12d458e0fbc90e286472d287341461ec004674
parent 98461 874900dd7b775c666b4d333b1e544f262d92da6d
child 98518 d103f74ecd5cb911403d5529af2555a7ee02f662
push id23063
push usertim.taubert@gmx.de
push dateSat, 07 Jul 2012 13:48:22 +0000
treeherdermozilla-central@afbb478ed7a1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs765235
milestone16.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 765235 - [New Tab Page] test suite should make use of underlying storages; r=gavin
browser/base/content/test/newtab/browser_newtab_block.js
browser/base/content/test/newtab/browser_newtab_bug721442.js
browser/base/content/test/newtab/browser_newtab_bug722273.js
browser/base/content/test/newtab/browser_newtab_bug723102.js
browser/base/content/test/newtab/browser_newtab_bug723121.js
browser/base/content/test/newtab/browser_newtab_bug725996.js
browser/base/content/test/newtab/browser_newtab_bug734043.js
browser/base/content/test/newtab/browser_newtab_bug735987.js
browser/base/content/test/newtab/browser_newtab_disable.js
browser/base/content/test/newtab/browser_newtab_drag_drop.js
browser/base/content/test/newtab/browser_newtab_drop_preview.js
browser/base/content/test/newtab/browser_newtab_focus.js
browser/base/content/test/newtab/browser_newtab_private_browsing.js
browser/base/content/test/newtab/browser_newtab_reset.js
browser/base/content/test/newtab/browser_newtab_tabsync.js
browser/base/content/test/newtab/browser_newtab_unpin.js
browser/base/content/test/newtab/head.js
--- a/browser/base/content/test/newtab/browser_newtab_block.js
+++ b/browser/base/content/test/newtab/browser_newtab_block.js
@@ -4,58 +4,58 @@
 /*
  * These tests make sure that blocking/removing sites from the grid works
  * as expected. Pinned tabs should not be moved. Gaps will be re-filled
  * if more sites are available.
  */
 function runTests() {
   // we remove sites and expect the gaps to be filled as long as there still
   // are some sites available
-  setLinks("0,1,2,3,4,5,6,7,8,9");
+  yield setLinks("0,1,2,3,4,5,6,7,8,9");
   setPinnedLinks("");
 
   yield addNewTabPageTab();
   checkGrid("0,1,2,3,4,5,6,7,8");
 
   yield blockCell(4);
   checkGrid("0,1,2,3,5,6,7,8,9");
 
   yield blockCell(4);
   checkGrid("0,1,2,3,6,7,8,9,");
 
   yield blockCell(4);
   checkGrid("0,1,2,3,7,8,9,,");
 
   // we removed a pinned site
   yield restore();
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks(",1");
 
   yield addNewTabPageTab();
   checkGrid("0,1p,2,3,4,5,6,7,8");
 
   yield blockCell(1);
   checkGrid("0,2,3,4,5,6,7,8,");
 
   // we remove the last site on the grid (which is pinned) and expect the gap
   // to be re-filled and the new site to be unpinned
   yield restore();
-  setLinks("0,1,2,3,4,5,6,7,8,9");
+  yield setLinks("0,1,2,3,4,5,6,7,8,9");
   setPinnedLinks(",,,,,,,,8");
 
   yield addNewTabPageTab();
   checkGrid("0,1,2,3,4,5,6,7,8p");
 
   yield blockCell(8);
   checkGrid("0,1,2,3,4,5,6,7,9");
 
   // we remove the first site on the grid with the last one pinned. all cells
   // but the last one should shift to the left and a new site fades in
   yield restore();
-  setLinks("0,1,2,3,4,5,6,7,8,9");
+  yield setLinks("0,1,2,3,4,5,6,7,8,9");
   setPinnedLinks(",,,,,,,,8");
 
   yield addNewTabPageTab();
   checkGrid("0,1,2,3,4,5,6,7,8p");
 
   yield blockCell(0);
   checkGrid("1,2,3,4,5,6,7,9,8p");
 }
--- a/browser/base/content/test/newtab/browser_newtab_bug721442.js
+++ b/browser/base/content/test/newtab/browser_newtab_bug721442.js
@@ -1,23 +1,23 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function runTests() {
-  setLinks("0,1,2,3,4,5,6,7,8");
-  NewTabUtils.pinnedLinks._links = [
-    {url: "about:blank#7", title: ""},
-    {url: "about:blank#8", title: "title"},
-    {url: "about:blank#9", title: "about:blank#9"}
-  ];
+  yield setLinks("0,1,2,3,4,5,6,7,8");
+  setPinnedLinks([
+    {url: "http://example.com/#7", title: ""},
+    {url: "http://example.com/#8", title: "title"},
+    {url: "http://example.com/#9", title: "http://example.com/#9"}
+  ]);
 
   yield addNewTabPageTab();
   checkGrid("7p,8p,9p,0,1,2,3,4,5");
 
-  checkTooltip(0, "about:blank#7", "1st tooltip is correct");
-  checkTooltip(1, "title\nabout:blank#8", "2nd tooltip is correct");
-  checkTooltip(2, "about:blank#9", "3rd tooltip is correct");
+  checkTooltip(0, "http://example.com/#7", "1st tooltip is correct");
+  checkTooltip(1, "title\nhttp://example.com/#8", "2nd tooltip is correct");
+  checkTooltip(2, "http://example.com/#9", "3rd tooltip is correct");
 }
 
 function checkTooltip(aIndex, aExpected, aMessage) {
   let link = getCell(aIndex).node.querySelector(".newtab-link");
   is(link.getAttribute("title"), aExpected, aMessage);
 }
--- a/browser/base/content/test/newtab/browser_newtab_bug722273.js
+++ b/browser/base/content/test/newtab/browser_newtab_bug722273.js
@@ -1,59 +1,60 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 const NOW = Date.now() * 1000;
 const URL = "http://fake-site.com/";
 
 let tmp = {};
-Cu.import("resource:///modules/NewTabUtils.jsm", tmp);
 Cc["@mozilla.org/moz/jssubscript-loader;1"]
   .getService(Ci.mozIJSSubScriptLoader)
   .loadSubScript("chrome://browser/content/sanitize.js", tmp);
 
-let {NewTabUtils, Sanitizer} = tmp;
-
-let bhist = Cc["@mozilla.org/browser/global-history;2"]
-  .getService(Ci.nsIBrowserHistory);
+let {Sanitizer} = tmp;
 
 function runTests() {
-  clearHistory();
-  yield fillHistory();
+  sanitizeHistory();
+  yield addFakeVisits();
   yield addNewTabPageTab();
 
   is(getCell(0).site.url, URL, "first site is our fake site");
 
   whenPagesUpdated();
-  yield clearHistory();
+  yield sanitizeHistory();
 
   ok(!getCell(0).site, "the fake site is gone");
 }
 
-function fillHistory() {
+function addFakeVisits() {
   let visits = [];
   for (let i = 59; i > 0; i--) {
     visits.push({
       visitDate: NOW - i * 60 * 1000000,
       transitionType: Ci.nsINavHistoryService.TRANSITION_LINK
     });
   }
   let place = {
     uri: makeURI(URL),
     title: "fake site",
     visits: visits
   };
   PlacesUtils.asyncHistory.updatePlaces(place, {
-    handleError: function () do_throw("Unexpected error in adding visit."),
-    handleResult: function () { },
-    handleCompletion: function () TestRunner.next()
+    handleError: function () ok(false, "couldn't add visit"),
+    handleResult: function () {},
+    handleCompletion: function () {
+      NewTabUtils.links.populateCache(function () {
+        NewTabUtils.allPages.update();
+        TestRunner.next();
+      }, true);
+    }
   });
 }
 
-function clearHistory() {
+function sanitizeHistory() {
   let s = new Sanitizer();
   s.prefDomain = "privacy.cpd.";
 
   let prefs = gPrefService.getBranch(s.prefDomain);
   prefs.setBoolPref("history", true);
   prefs.setBoolPref("downloads", false);
   prefs.setBoolPref("cache", false);
   prefs.setBoolPref("cookies", false);
--- a/browser/base/content/test/newtab/browser_newtab_bug723102.js
+++ b/browser/base/content/test/newtab/browser_newtab_bug723102.js
@@ -1,18 +1,18 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function runTests() {
   // create a new tab page and hide it.
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks("");
 
   yield addNewTabPageTab();
   let firstTab = gBrowser.selectedTab;
 
   yield addNewTabPageTab();
   gBrowser.removeTab(firstTab);
 
-  ok(NewTabUtils.allPages.enabled, true, "page is enabled");
+  ok(NewTabUtils.allPages.enabled, "page is enabled");
   NewTabUtils.allPages.enabled = false;
   ok(getGrid().node.hasAttribute("page-disabled"), "page is disabled");
 }
--- a/browser/base/content/test/newtab/browser_newtab_bug723121.js
+++ b/browser/base/content/test/newtab/browser_newtab_bug723121.js
@@ -1,13 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function runTests() {
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks("");
 
   yield addNewTabPageTab();
   checkGridLocked(false, "grid is unlocked");
 
   let cell = getCell(0).node;
   let site = getCell(0).site.node;
   let link = site.querySelector(".newtab-link");
--- a/browser/base/content/test/newtab/browser_newtab_bug725996.js
+++ b/browser/base/content/test/newtab/browser_newtab_bug725996.js
@@ -1,23 +1,23 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function runTests() {
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks("");
 
   yield addNewTabPageTab();
   checkGrid("0,1,2,3,4,5,6,7,8");
 
   let cell = getCell(0).node;
 
-  sendDragEvent("drop", cell, "about:blank#99\nblank");
-  is(NewTabUtils.pinnedLinks.links[0].url, "about:blank#99",
+  sendDragEvent("drop", cell, "http://example.com/#99\nblank");
+  is(NewTabUtils.pinnedLinks.links[0].url, "http://example.com/#99",
      "first cell is pinned and contains the dropped site");
 
   yield whenPagesUpdated();
   checkGrid("99p,0,1,2,3,4,5,6,7");
 
   sendDragEvent("drop", cell, "");
-  is(NewTabUtils.pinnedLinks.links[0].url, "about:blank#99",
+  is(NewTabUtils.pinnedLinks.links[0].url, "http://example.com/#99",
      "first cell is still pinned with the site we dropped before");
 }
--- a/browser/base/content/test/newtab/browser_newtab_bug734043.js
+++ b/browser/base/content/test/newtab/browser_newtab_bug734043.js
@@ -1,13 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function runTests() {
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks("");
 
   yield addNewTabPageTab();
   checkGrid("0,1,2,3,4,5,6,7,8");
 
   let receivedError = false;
   let block = getContentDocument().querySelector(".newtab-control-block");
 
--- a/browser/base/content/test/newtab/browser_newtab_bug735987.js
+++ b/browser/base/content/test/newtab/browser_newtab_bug735987.js
@@ -1,13 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function runTests() {
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks("");
 
   yield addNewTabPageTab();
   checkGrid("0,1,2,3,4,5,6,7,8");
 
   yield simulateDrop(1);
   checkGrid("0,99p,1,2,3,4,5,6,7");
 
--- a/browser/base/content/test/newtab/browser_newtab_disable.js
+++ b/browser/base/content/test/newtab/browser_newtab_disable.js
@@ -2,17 +2,17 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /*
  * These tests make sure that the 'New Tab Page' feature can be disabled if the
  * decides not to use it.
  */
 function runTests() {
   // create a new tab page and hide it.
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks("");
 
   yield addNewTabPageTab();
   let gridNode = getGrid().node;
 
   ok(!gridNode.hasAttribute("page-disabled"), "page is not disabled");
 
   NewTabUtils.allPages.enabled = false;
--- a/browser/base/content/test/newtab/browser_newtab_drag_drop.js
+++ b/browser/base/content/test/newtab/browser_newtab_drag_drop.js
@@ -4,112 +4,112 @@
 /*
  * These tests make sure that dragging and dropping sites works as expected.
  * Sites contained in the grid need to shift around to indicate the result
  * of the drag-and-drop operation. If the grid is full and we're dragging
  * a new site into it another one gets pushed out.
  */
 function runTests() {
   // test a simple drag-and-drop scenario
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks("");
 
   yield addNewTabPageTab();
   checkGrid("0,1,2,3,4,5,6,7,8");
 
   yield simulateDrop(1, 0);
   checkGrid("1,0p,2,3,4,5,6,7,8");
 
   // drag a cell to its current cell and make sure it's not pinned afterwards
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks("");
 
   yield addNewTabPageTab();
   checkGrid("0,1,2,3,4,5,6,7,8");
 
   yield simulateDrop(0, 0);
   checkGrid("0,1,2,3,4,5,6,7,8");
 
   // ensure that pinned pages aren't moved if that's not necessary
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks(",1,2");
 
   yield addNewTabPageTab();
   checkGrid("0,1p,2p,3,4,5,6,7,8");
 
   yield simulateDrop(3, 0);
   checkGrid("3,1p,2p,0p,4,5,6,7,8");
 
   // pinned sites should always be moved around as blocks. if a pinned site is
   // moved around, neighboring pinned are affected as well
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks("0,1");
 
   yield addNewTabPageTab();
   checkGrid("0p,1p,2,3,4,5,6,7,8");
 
   yield simulateDrop(0, 2);
   checkGrid("2p,0p,1p,3,4,5,6,7,8");
 
   // pinned sites should not be pushed out of the grid (unless there are only
   // pinned ones left on the grid)
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks(",,,,,,,7,8");
 
   yield addNewTabPageTab();
   checkGrid("0,1,2,3,4,5,6,7p,8p");
 
   yield simulateDrop(8, 2);
   checkGrid("0,1,3,4,5,6,7p,8p,2p");
 
   // make sure that pinned sites are re-positioned correctly
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks("0,1,2,,,5");
 
   yield addNewTabPageTab();
   checkGrid("0p,1p,2p,3,4,5p,6,7,8");
 
   yield simulateDrop(4, 0);
   checkGrid("3,1p,2p,4,0p,5p,6,7,8");
 
   // drag a new site onto the very first cell
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks(",,,,,,,7,8");
 
   yield addNewTabPageTab();
   checkGrid("0,1,2,3,4,5,6,7p,8p");
 
   yield simulateDrop(0);
   checkGrid("99p,0,1,2,3,4,5,7p,8p");
 
   // drag a new site onto the grid and make sure that pinned cells don't get
   // pushed out
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks(",,,,,,,7,8");
 
   yield addNewTabPageTab();
   checkGrid("0,1,2,3,4,5,6,7p,8p");
 
   yield simulateDrop(7);
   checkGrid("0,1,2,3,4,5,7p,99p,8p");
 
   // drag a new site beneath a pinned cell and make sure the pinned cell is
   // not moved
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks(",,,,,,,,8");
 
   yield addNewTabPageTab();
   checkGrid("0,1,2,3,4,5,6,7,8p");
 
   yield simulateDrop(7);
   checkGrid("0,1,2,3,4,5,6,99p,8p");
 
   // drag a new site onto a block of pinned sites and make sure they're shifted
   // around accordingly
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks("0,1,2,,,,,,");
 
   yield addNewTabPageTab();
   checkGrid("0p,1p,2p");
 
   yield simulateDrop(1);
   checkGrid("0p,99p,1p,2p,3,4,5,6,7");
 }
--- a/browser/base/content/test/newtab/browser_newtab_drop_preview.js
+++ b/browser/base/content/test/newtab/browser_newtab_drop_preview.js
@@ -2,17 +2,17 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /*
  * These tests ensure that the drop preview correctly arranges sites when
  * dragging them around.
  */
 function runTests() {
   // the first three sites are pinned - make sure they're re-arranged correctly
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks("0,1,2,,,5");
 
   yield addNewTabPageTab();
   checkGrid("0p,1p,2p,3,4,5p,6,7,8");
 
   let cw = getContentWindow();
   cw.gDrag._draggedSite = getCell(0).site;
   let sites = cw.gDropPreview.rearrange(getCell(4));
--- a/browser/base/content/test/newtab/browser_newtab_focus.js
+++ b/browser/base/content/test/newtab/browser_newtab_focus.js
@@ -10,18 +10,19 @@ function runTests() {
   // and a remove button.
   let FOCUS_COUNT = 28; 
   if ("nsILocalFileMac" in Ci) {
     // 19 = Mac doesn't focus links, so 9 focus targets less than Windows/Linux.
     FOCUS_COUNT = 19;
   }
 
   // Create a new tab page.
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks("");
+
   yield addNewTabPageTab();
   gURLBar.focus();
 
   // Count the focus with the enabled page.
   yield countFocus(FOCUS_COUNT);
 
   // Disable page and count the focus with the disabled page.
   NewTabUtils.allPages.enabled = false;
@@ -46,9 +47,9 @@ function countFocus(aExpectedCount) {
           focusedElement instanceof HTMLElement) {
         focusCount++;
       }
       document.commandDispatcher.advanceFocus();
     }
   }, true);
 
   document.commandDispatcher.advanceFocus();
-}
\ No newline at end of file
+}
--- a/browser/base/content/test/newtab/browser_newtab_private_browsing.js
+++ b/browser/base/content/test/newtab/browser_newtab_private_browsing.js
@@ -7,17 +7,17 @@
  * The private browsing mode should start with the current grid shown in normal
  * mode.
  */
 let pb = Cc["@mozilla.org/privatebrowsing;1"]
          .getService(Ci.nsIPrivateBrowsingService);
 
 function runTests() {
   // prepare the grid
-  setLinks("0,1,2,3,4,5,6,7,8,9");
+  yield setLinks("0,1,2,3,4,5,6,7,8,9");
   ok(!pb.privateBrowsingEnabled, "private browsing is disabled");
 
   yield addNewTabPageTab();
   pinCell(0);
   checkGrid("0p,1,2,3,4,5,6,7,8");
 
   // enter private browsing mode
   yield togglePrivateBrowsing();
--- a/browser/base/content/test/newtab/browser_newtab_reset.js
+++ b/browser/base/content/test/newtab/browser_newtab_reset.js
@@ -4,17 +4,17 @@
 /*
  * These tests make sure that resetting the 'New Tage Page' works as expected.
  */
 function runTests() {
   // Disabled until bug 716543 is fixed.
   return;
 
   // create a new tab page and check its modified state after blocking a site
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks("");
 
   yield addNewTabPageTab();
   let resetButton = getContentDocument().getElementById("toolbar-button-reset");
 
   checkGrid("0,1,2,3,4,5,6,7,8");
   ok(!resetButton.hasAttribute("modified"), "page is not modified");
 
--- a/browser/base/content/test/newtab/browser_newtab_tabsync.js
+++ b/browser/base/content/test/newtab/browser_newtab_tabsync.js
@@ -6,17 +6,17 @@
  * 'New Tab Page' are synchronized with all other open 'New Tab Pages'
  * automatically. All about:newtab pages should always be in the same
  * state.
  */
 function runTests() {
   // Disabled until bug 716543 is fixed.
   return;
 
-  setLinks("0,1,2,3,4,5,6,7,8,9");
+  yield setLinks("0,1,2,3,4,5,6,7,8,9");
   setPinnedLinks(",1");
 
   yield addNewTabPageTab();
   checkGrid("0,1p,2,3,4,5,6,7,8");
 
   let resetButton = getContentDocument().getElementById("toolbar-button-reset");
   ok(!resetButton.hasAttribute("modified"), "page is not modified");
 
--- a/browser/base/content/test/newtab/browser_newtab_unpin.js
+++ b/browser/base/content/test/newtab/browser_newtab_unpin.js
@@ -3,54 +3,54 @@
 
 /*
  * These tests make sure that when a site gets unpinned it is either moved to
  * its actual place in the grid or removed in case it's not on the grid anymore.
  */
 function runTests() {
   // we have a pinned link that didn't change its position since it was pinned.
   // nothing should happend when we unpin it.
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks(",1");
 
   yield addNewTabPageTab();
   checkGrid("0,1p,2,3,4,5,6,7,8");
 
   yield unpinCell(1);
   checkGrid("0,1,2,3,4,5,6,7,8");
 
   // we have a pinned link that is not anymore in the list of the most-visited
   // links. this should disappear, the remaining links adjust their positions
   // and a new link will appear at the end of the grid.
-  setLinks("0,1,2,3,4,5,6,7,8");
+  yield setLinks("0,1,2,3,4,5,6,7,8");
   setPinnedLinks(",99");
 
   yield addNewTabPageTab();
   checkGrid("0,99p,1,2,3,4,5,6,7");
 
   yield unpinCell(1);
   checkGrid("0,1,2,3,4,5,6,7,8");
 
   // we have a pinned link that changed its position since it was pinned. it
   // should be moved to its new position after being unpinned.
-  setLinks("0,1,2,3,4,5,6,7");
+  yield setLinks("0,1,2,3,4,5,6,7");
   setPinnedLinks(",1,,,,,,,0");
 
   yield addNewTabPageTab();
   checkGrid("2,1p,3,4,5,6,7,,0p");
 
   yield unpinCell(1);
   checkGrid("1,2,3,4,5,6,7,,0p");
 
   yield unpinCell(8);
   checkGrid("0,1,2,3,4,5,6,7,");
 
   // we have pinned link that changed its position since it was pinned. the
   // link will disappear from the grid because it's now a much lower priority
-  setLinks("0,1,2,3,4,5,6,7,8,9");
+  yield setLinks("0,1,2,3,4,5,6,7,8,9");
   setPinnedLinks("9");
 
   yield addNewTabPageTab();
   checkGrid("9p,0,1,2,3,4,5,6,7");
 
   yield unpinCell(0);
   checkGrid("0,1,2,3,4,5,6,7,8");
 }
--- a/browser/base/content/test/newtab/head.js
+++ b/browser/base/content/test/newtab/head.js
@@ -2,31 +2,36 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 const PREF_NEWTAB_ENABLED = "browser.newtabpage.enabled";
 
 Services.prefs.setBoolPref(PREF_NEWTAB_ENABLED, true);
 
 let tmp = {};
 Cu.import("resource:///modules/NewTabUtils.jsm", tmp);
-let NewTabUtils = tmp.NewTabUtils;
+Cc["@mozilla.org/moz/jssubscript-loader;1"]
+  .getService(Ci.mozIJSSubScriptLoader)
+  .loadSubScript("chrome://browser/content/sanitize.js", tmp);
+
+let {NewTabUtils, Sanitizer} = tmp;
+
+let uri = Services.io.newURI("about:newtab", null, null);
+let principal = Services.scriptSecurityManager.getCodebasePrincipal(uri);
+
+let sm = Services.domStorageManager;
+let storage = sm.getLocalStorageForPrincipal(principal, "");
 
 registerCleanupFunction(function () {
   while (gBrowser.tabs.length > 1)
     gBrowser.removeTab(gBrowser.tabs[1]);
 
   Services.prefs.clearUserPref(PREF_NEWTAB_ENABLED);
 });
 
 /**
- * We'll want to restore the original links provider later.
- */
-let originalProvider = NewTabUtils.links._provider;
-
-/**
  * Provide the default test function to start our test runner.
  */
 function test() {
   TestRunner.run();
 }
 
 /**
  * The test runner that controls the execution flow of our tests.
@@ -53,19 +58,17 @@ let TestRunner = {
     }
   },
 
   /**
    * Finishes all tests and cleans up.
    */
   finish: function () {
     function cleanupAndFinish() {
-      // Restore the old provider.
-      NewTabUtils.links._provider = originalProvider;
-
+      clearHistory();
       whenPagesUpdated(finish);
       NewTabUtils.restore();
     }
 
     let callbacks = NewTabUtils.links._populateCallbacks;
     let numCallbacks = callbacks.length;
 
     if (numCallbacks)
@@ -108,52 +111,86 @@ function getCell(aIndex) {
   return getGrid().cells[aIndex];
 }
 
 /**
  * Allows to provide a list of links that is used to construct the grid.
  * @param aLinksPattern the pattern (see below)
  *
  * Example: setLinks("1,2,3")
- * Result: [{url: "about:blank#1", title: "site#1"},
- *          {url: "about:blank#2", title: "site#2"}
- *          {url: "about:blank#3", title: "site#3"}]
+ * Result: [{url: "http://example.com/#1", title: "site#1"},
+ *          {url: "http://example.com/#2", title: "site#2"}
+ *          {url: "http://example.com/#3", title: "site#3"}]
  */
-function setLinks(aLinksPattern) {
-  let links = aLinksPattern.split(/\s*,\s*/).map(function (id) {
-    return {url: "about:blank#" + id, title: "site#" + id};
+function setLinks(aLinks) {
+  let links = aLinks;
+
+  if (typeof links == "string") {
+    links = aLinks.split(/\s*,\s*/).map(function (id) {
+      return {url: "http://example.com/#" + id, title: "site#" + id};
+    });
+  }
+
+  clearHistory();
+  fillHistory(links, function () {
+    NewTabUtils.links.populateCache(function () {
+      NewTabUtils.allPages.update();
+      TestRunner.next();
+    }, true);
   });
+}
 
-  NewTabUtils.links._provider = {getLinks: function (c) c(links)};
-  NewTabUtils.links._links = links;
+function clearHistory() {
+  PlacesUtils.history.removeAllPages();
+}
+
+function fillHistory(aLinks, aCallback) {
+  let numLinks = aLinks.length;
+  let transitionLink = Ci.nsINavHistoryService.TRANSITION_LINK;
+
+  for (let link of aLinks.reverse()) {
+    let place = {
+      uri: makeURI(link.url),
+      title: link.title,
+      visits: [{visitDate: Date.now() * 1000, transitionType: transitionLink}]
+    };
+
+    PlacesUtils.asyncHistory.updatePlaces(place, {
+      handleError: function () ok(false, "couldn't add visit to history"),
+      handleResult: function () {},
+      handleCompletion: function () {
+        if (--numLinks == 0)
+          aCallback();
+      }
+    });
+  }
 }
 
 /**
  * Allows to specify the list of pinned links (that have a fixed position in
  * the grid.
  * @param aLinksPattern the pattern (see below)
  *
  * Example: setPinnedLinks("3,,1")
- * Result: 'about:blank#3' is pinned in the first cell. 'about:blank#1' is
+ * Result: 'http://example.com/#3' is pinned in the first cell. 'http://example.com/#1' is
  *         pinned in the third cell.
  */
-function setPinnedLinks(aLinksPattern) {
-  let pinnedLinks = [];
-
-  aLinksPattern.split(/\s*,\s*/).forEach(function (id, index) {
-    let link;
+function setPinnedLinks(aLinks) {
+  let links = aLinks;
 
-    if (id)
-      link = {url: "about:blank#" + id, title: "site#" + id};
+  if (typeof links == "string") {
+    links = aLinks.split(/\s*,\s*/).map(function (id) {
+      if (id)
+        return {url: "http://example.com/#" + id, title: "site#" + id};
+    });
+  }
 
-    pinnedLinks[index] = link;
-  });
-
-  // Inject the list of pinned links to work with.
-  NewTabUtils.pinnedLinks._links = pinnedLinks;
+  storage.setItem("pinnedLinks", JSON.stringify(links));
+  NewTabUtils.pinnedLinks.resetCache();
+  NewTabUtils.allPages.update();
 }
 
 /**
  * Restore the grid state.
  */
 function restore() {
   whenPagesUpdated();
   NewTabUtils.restore();
@@ -182,35 +219,35 @@ function addNewTabPageTab() {
 }
 
 /**
  * Compares the current grid arrangement with the given pattern.
  * @param the pattern (see below)
  * @param the array of sites to compare with (optional)
  *
  * Example: checkGrid("3p,2,,1p")
- * Result: We expect the first cell to contain the pinned site 'about:blank#3'.
- *         The second cell contains 'about:blank#2'. The third cell is empty.
- *         The fourth cell contains the pinned site 'about:blank#4'.
+ * Result: We expect the first cell to contain the pinned site 'http://example.com/#3'.
+ *         The second cell contains 'http://example.com/#2'. The third cell is empty.
+ *         The fourth cell contains the pinned site 'http://example.com/#4'.
  */
 function checkGrid(aSitesPattern, aSites) {
   let length = aSitesPattern.split(",").length;
   let sites = (aSites || getGrid().sites).slice(0, length);
   let current = sites.map(function (aSite) {
     if (!aSite)
       return "";
 
     let pinned = aSite.isPinned();
     let pinButton = aSite.node.querySelector(".newtab-control-pin");
     let hasPinnedAttr = pinButton.hasAttribute("pinned");
 
     if (pinned != hasPinnedAttr)
       ok(false, "invalid state (site.isPinned() != site[pinned])");
 
-    return aSite.url.replace(/^about:blank#(\d+)$/, "$1") + (pinned ? "p" : "");
+    return aSite.url.replace(/^http:\/\/example\.com\/#(\d+)$/, "$1") + (pinned ? "p" : "");
   });
 
   is(current, aSitesPattern, "grid status = " + aSitesPattern);
 }
 
 /**
  * Blocks a site from the grid.
  * @param aIndex The cell index.
@@ -241,17 +278,17 @@ function unpinCell(aIndex) {
 /**
  * Simulates a drop and drop operation.
  * @param aDropIndex The cell index of the drop target.
  * @param aDragIndex The cell index containing the dragged site (optional).
  */
 function simulateDrop(aDropIndex, aDragIndex) {
   let draggedSite;
   let {gDrag: drag, gDrop: drop} = getContentWindow();
-  let event = createDragEvent("drop", "about:blank#99\nblank");
+  let event = createDragEvent("drop", "http://example.com/#99\nblank");
 
   if (typeof aDragIndex != "undefined")
     draggedSite = getCell(aDragIndex).site;
 
   if (draggedSite)
     drag.start(draggedSite, event);
 
   whenPagesUpdated();