зеркало из https://github.com/mozilla/gecko-dev.git
Bug 765235 - [New Tab Page] test suite should make use of underlying storages; r=gavin
This commit is contained in:
Родитель
d712821491
Коммит
0403d4a2d4
|
@ -9,7 +9,7 @@
|
|||
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();
|
||||
|
@ -26,7 +26,7 @@ function runTests() {
|
|||
|
||||
// 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();
|
||||
|
@ -38,7 +38,7 @@ function runTests() {
|
|||
// 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();
|
||||
|
@ -50,7 +50,7 @@ function runTests() {
|
|||
// 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();
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
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) {
|
||||
|
|
|
@ -5,30 +5,26 @@ 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({
|
||||
|
@ -42,13 +38,18 @@ function fillHistory() {
|
|||
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.";
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
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();
|
||||
|
@ -12,7 +12,7 @@ function runTests() {
|
|||
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");
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
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();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
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();
|
||||
|
@ -10,14 +10,14 @@ function runTests() {
|
|||
|
||||
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");
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
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();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
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();
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
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();
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
*/
|
||||
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();
|
||||
|
@ -19,7 +19,7 @@ function runTests() {
|
|||
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();
|
||||
|
@ -29,7 +29,7 @@ function runTests() {
|
|||
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();
|
||||
|
@ -40,7 +40,7 @@ function runTests() {
|
|||
|
||||
// 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();
|
||||
|
@ -51,7 +51,7 @@ function runTests() {
|
|||
|
||||
// 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();
|
||||
|
@ -61,7 +61,7 @@ function runTests() {
|
|||
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();
|
||||
|
@ -71,7 +71,7 @@ function runTests() {
|
|||
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();
|
||||
|
@ -82,7 +82,7 @@ function runTests() {
|
|||
|
||||
// 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();
|
||||
|
@ -93,7 +93,7 @@ function runTests() {
|
|||
|
||||
// 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();
|
||||
|
@ -104,7 +104,7 @@ function runTests() {
|
|||
|
||||
// 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();
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
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();
|
||||
|
|
|
@ -15,8 +15,9 @@ function runTests() {
|
|||
}
|
||||
|
||||
// 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();
|
||||
|
||||
|
@ -51,4 +52,4 @@ function countFocus(aExpectedCount) {
|
|||
}, true);
|
||||
|
||||
document.commandDispatcher.advanceFocus();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ let pb = Cc["@mozilla.org/privatebrowsing;1"]
|
|||
|
||||
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();
|
||||
|
|
|
@ -9,7 +9,7 @@ function runTests() {
|
|||
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();
|
||||
|
|
|
@ -11,7 +11,7 @@ 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();
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
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();
|
||||
|
@ -20,7 +20,7 @@ function runTests() {
|
|||
// 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();
|
||||
|
@ -31,7 +31,7 @@ function runTests() {
|
|||
|
||||
// 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();
|
||||
|
@ -45,7 +45,7 @@ function runTests() {
|
|||
|
||||
// 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();
|
||||
|
|
|
@ -7,7 +7,17 @@ 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)
|
||||
|
@ -16,11 +26,6 @@ registerCleanupFunction(function () {
|
|||
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.
|
||||
*/
|
||||
|
@ -58,9 +63,7 @@ let TestRunner = {
|
|||
*/
|
||||
finish: function () {
|
||||
function cleanupAndFinish() {
|
||||
// Restore the old provider.
|
||||
NewTabUtils.links._provider = originalProvider;
|
||||
|
||||
clearHistory();
|
||||
whenPagesUpdated(finish);
|
||||
NewTabUtils.restore();
|
||||
}
|
||||
|
@ -113,17 +116,52 @@ function getCell(aIndex) {
|
|||
* @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;
|
||||
|
||||
NewTabUtils.links._provider = {getLinks: function (c) c(links)};
|
||||
NewTabUtils.links._links = links;
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,23 +170,22 @@ function setLinks(aLinksPattern) {
|
|||
* @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 = [];
|
||||
function setPinnedLinks(aLinks) {
|
||||
let links = aLinks;
|
||||
|
||||
aLinksPattern.split(/\s*,\s*/).forEach(function (id, index) {
|
||||
let link;
|
||||
if (typeof links == "string") {
|
||||
links = aLinks.split(/\s*,\s*/).map(function (id) {
|
||||
if (id)
|
||||
return {url: "http://example.com/#" + id, title: "site#" + id};
|
||||
});
|
||||
}
|
||||
|
||||
if (id)
|
||||
link = {url: "about:blank#" + 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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -187,9 +224,9 @@ function addNewTabPageTab() {
|
|||
* @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;
|
||||
|
@ -205,7 +242,7 @@ function checkGrid(aSitesPattern, aSites) {
|
|||
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);
|
||||
|
@ -246,7 +283,7 @@ function unpinCell(aIndex) {
|
|||
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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче