зеркало из https://github.com/mozilla/gecko-dev.git
Merge fx-team to m-c. a=merge
This commit is contained in:
Коммит
65df1a024e
|
@ -1522,7 +1522,7 @@ pref("browser.newtabpage.enhanced", false);
|
|||
pref("browser.newtabpage.rows", 3);
|
||||
|
||||
// number of columns of newtab grid
|
||||
pref("browser.newtabpage.columns", 3);
|
||||
pref("browser.newtabpage.columns", 8);
|
||||
|
||||
// directory tiles download URL
|
||||
pref("browser.newtabpage.directory.source", "chrome://global/content/directoryLinks.json");
|
||||
|
|
|
@ -1677,8 +1677,15 @@ nsContextMenu.prototype = {
|
|||
// Store searchTerms in context menu item so we know what to search onclick
|
||||
menuItem.searchTerms = selectedText;
|
||||
|
||||
if (selectedText.length > 15)
|
||||
selectedText = selectedText.substr(0,15) + this.ellipsis;
|
||||
// If the JS character after our truncation point is a trail surrogate,
|
||||
// include it in the truncated string to avoid splitting a surrogate pair.
|
||||
if (selectedText.length > 15) {
|
||||
let truncLength = 15;
|
||||
let truncChar = selectedText[15].charCodeAt(0);
|
||||
if (truncChar >= 0xDC00 && truncChar <= 0xDFFF)
|
||||
truncLength++;
|
||||
selectedText = selectedText.substr(0,truncLength) + this.ellipsis;
|
||||
}
|
||||
|
||||
// Use the current engine if the search bar is visible, the default
|
||||
// engine otherwise.
|
||||
|
|
|
@ -108,6 +108,13 @@ function test() {
|
|||
expectedLabelContents: "A partial link " + ellipsis,
|
||||
});
|
||||
|
||||
testElement({
|
||||
id: "surrogatePair",
|
||||
isSelected: true,
|
||||
shouldBeShown: true,
|
||||
expectedLabelContents: "This character\uD83D\uDD25" + ellipsis,
|
||||
});
|
||||
|
||||
// cleanup
|
||||
document.popupNode = null;
|
||||
gBrowser.removeCurrentTab();
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<body>
|
||||
<a href="http://mozilla.org" id="link">I'm a link!</a>
|
||||
<a href="http://mozilla.org" id="longLink">I'm a really long link and I should be truncated.</a>
|
||||
<body>
|
||||
<a href="http://mozilla.org" id="link">I'm a link!</a>
|
||||
<a href="http://mozilla.org" id="longLink">I'm a really long link and I should be truncated.</a>
|
||||
|
||||
<span id="plainText">
|
||||
Right clicking me when I'm selected should show the menu item.
|
||||
</span>
|
||||
<span id="mixedContent">
|
||||
I'm some text, and <a href="http://mozilla.org">I'm a link!</a>
|
||||
</span>
|
||||
<span id="plainText">
|
||||
Right clicking me when I'm selected should show the menu item.
|
||||
</span>
|
||||
<span id="mixedContent">
|
||||
I'm some text, and <a href="http://mozilla.org">I'm a link!</a>
|
||||
</span>
|
||||
|
||||
<a href="http://mozilla.org">A partial <span id="partialLink">link selection</span></a>
|
||||
</body>
|
||||
<a href="http://mozilla.org">A partial <span id="partialLink">link selection</span></a>
|
||||
|
||||
<span id="surrogatePair">
|
||||
This character🔥 shouldn't be truncated.
|
||||
</span>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -18,8 +18,7 @@ function runTests() {
|
|||
Services.prefs.setBoolPref(CAPTURE_PREF, true);
|
||||
|
||||
// Make sure the thumbnail doesn't exist yet.
|
||||
let siteName = "newtab_background_captures";
|
||||
let url = "http://example.com/#" + siteName;
|
||||
let url = "http://example.com/";
|
||||
let path = imports.PageThumbsStorage.getFilePathForURL(url);
|
||||
let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
|
||||
file.initWithPath(path);
|
||||
|
@ -29,7 +28,7 @@ function runTests() {
|
|||
catch (err) {}
|
||||
|
||||
// Add a top site.
|
||||
yield setLinks(siteName);
|
||||
yield setLinks("-1");
|
||||
|
||||
// We need a handle to a hidden, pre-loaded newtab so we can verify that it
|
||||
// doesn't allow background captures. Add a newtab, which triggers creation
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
function runTests() {
|
||||
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"}
|
||||
{url: "http://example7.com/", title: ""},
|
||||
{url: "http://example8.com/", title: "title"},
|
||||
{url: "http://example9.com/", title: "http://example9.com/"}
|
||||
]);
|
||||
|
||||
yield addNewTabPageTab();
|
||||
checkGrid("7p,8p,9p,0,1,2,3,4,5");
|
||||
|
||||
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");
|
||||
checkTooltip(0, "http://example7.com/", "1st tooltip is correct");
|
||||
checkTooltip(1, "title\nhttp://example8.com/", "2nd tooltip is correct");
|
||||
checkTooltip(2, "http://example9.com/", "3rd tooltip is correct");
|
||||
}
|
||||
|
||||
function checkTooltip(aIndex, aExpected, aMessage) {
|
||||
|
|
|
@ -10,14 +10,14 @@ function runTests() {
|
|||
|
||||
let cell = getCell(0).node;
|
||||
|
||||
sendDragEvent("drop", cell, "http://example.com/#99\nblank");
|
||||
is(NewTabUtils.pinnedLinks.links[0].url, "http://example.com/#99",
|
||||
sendDragEvent("drop", cell, "http://example99.com/\nblank");
|
||||
is(NewTabUtils.pinnedLinks.links[0].url, "http://example99.com/",
|
||||
"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, "http://example.com/#99",
|
||||
is(NewTabUtils.pinnedLinks.links[0].url, "http://example99.com/",
|
||||
"first cell is still pinned with the site we dropped before");
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ function runTests() {
|
|||
// Expected length of grid
|
||||
let expectedValues = [1, 1, 1, 1, 8, 10];
|
||||
|
||||
// Values before setting new pref values (9 is the default value -> 3 x 3)
|
||||
let previousValues = [9, 1, 1, 1, 1, 8];
|
||||
// Values before setting new pref values (24 is the default value -> 8 x 3)
|
||||
let previousValues = [24, 1, 1, 1, 1, 8];
|
||||
|
||||
let existingTab, existingTabGridLength, newTab, newTabGridLength;
|
||||
yield addNewTabPageTab();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const BAD_DRAG_DATA = "javascript:alert('h4ck0rz');\nbad stuff";
|
||||
const GOOD_DRAG_DATA = "http://example.com/#99\nsite 99";
|
||||
const GOOD_DRAG_DATA = "http://example99.com/\nsite 99";
|
||||
|
||||
function runTests() {
|
||||
yield setLinks("0,1,2,3,4,5,6,7,8");
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function runTests() {
|
||||
yield setLinks("0");
|
||||
yield setLinks("-1");
|
||||
yield addNewTabPageTab();
|
||||
|
||||
// Remember if the click handler was triggered
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const PREF_NEWTAB_COLUMNS = "browser.newtabpage.columns";
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
@ -10,6 +12,8 @@
|
|||
* to decrease test run time, focusing on external sites.
|
||||
*/
|
||||
function runTests() {
|
||||
registerCleanupFunction(_ => Services.prefs.clearUserPref(PREF_NEWTAB_COLUMNS));
|
||||
|
||||
// drag a new site onto the very first cell
|
||||
yield setLinks("0,1,2,3,4,5,6,7,8");
|
||||
setPinnedLinks(",,,,,,,7,8");
|
||||
|
@ -28,6 +32,8 @@ function runTests() {
|
|||
yield addNewTabPageTab();
|
||||
checkGrid("0,1,2,3,4,5,6,7p,8p");
|
||||
|
||||
// force the grid to be small enough that a pinned cell could be pushed out
|
||||
Services.prefs.setIntPref(PREF_NEWTAB_COLUMNS, 3);
|
||||
yield simulateExternalDrop(7);
|
||||
checkGrid("0,1,2,3,4,5,7p,99p,8p");
|
||||
|
||||
|
@ -52,4 +58,4 @@ function runTests() {
|
|||
|
||||
yield simulateExternalDrop(1);
|
||||
checkGrid("0p,99p,1p,2p,3,4,5,6,7");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,10 @@ function runTests() {
|
|||
Services.prefs.setBoolPref(PRELOAD_PREF, false);
|
||||
|
||||
function getData(cellNum) {
|
||||
let siteNode = getCell(cellNum).site.node;
|
||||
let cell = getCell(cellNum);
|
||||
if (!cell.site)
|
||||
return null;
|
||||
let siteNode = cell.site.node;
|
||||
return {
|
||||
type: siteNode.getAttribute("type"),
|
||||
enhanced: siteNode.querySelector(".enhanced-content").style.backgroundImage,
|
||||
|
@ -29,7 +32,7 @@ function runTests() {
|
|||
}
|
||||
|
||||
// Make the page have a directory link followed by a history link
|
||||
yield setLinks("1");
|
||||
yield setLinks("-1");
|
||||
|
||||
// Test with enhanced = false
|
||||
NewTabUtils.allPages.enhanced = false;
|
||||
|
@ -38,9 +41,7 @@ function runTests() {
|
|||
is(type, "organic", "directory link is organic");
|
||||
isnot(enhanced, "", "directory link has enhanced image");
|
||||
|
||||
let {type, enhanced} = getData(1);
|
||||
is(type, "history", "history link is history");
|
||||
is(enhanced, "", "history link has no enhanced image");
|
||||
is(getData(1), null, "history link pushed out by directory link");
|
||||
|
||||
// Test with enhanced = true
|
||||
NewTabUtils.allPages.enhanced = true;
|
||||
|
@ -49,7 +50,14 @@ function runTests() {
|
|||
is(type, "organic", "directory link is still organic");
|
||||
isnot(enhanced, "", "directory link still has enhanced image");
|
||||
|
||||
let {type, enhanced} = getData(1);
|
||||
is(type, "enhanced", "history link now is enhanced");
|
||||
isnot(enhanced, "", "history link now has enhanced image");
|
||||
is(getData(1), null, "history link still pushed out by directory link");
|
||||
|
||||
// Test with a pinned link
|
||||
setPinnedLinks("-1");
|
||||
yield addNewTabPageTab();
|
||||
let {type, enhanced} = getData(0);
|
||||
is(type, "enhanced", "pinned history link is enhanced");
|
||||
isnot(enhanced, "", "pinned history link has enhanced image");
|
||||
|
||||
is(getData(1), null, "directory link pushed out by pinned history link");
|
||||
}
|
||||
|
|
|
@ -47,5 +47,5 @@ function runTests() {
|
|||
}
|
||||
|
||||
function link(id) {
|
||||
return { url: "http://example.com/#" + id, title: "site#" + id };
|
||||
return { url: "http://example" + id + ".com/", title: "site#" + id };
|
||||
}
|
||||
|
|
|
@ -203,17 +203,20 @@ function getCell(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: "http://example.com/#1", title: "site#1"},
|
||||
* {url: "http://example.com/#2", title: "site#2"}
|
||||
* {url: "http://example.com/#3", title: "site#3"}]
|
||||
* Example: setLinks("-1,0,1,2,3")
|
||||
* Result: [{url: "http://example.com/", title: "site#-1"},
|
||||
* {url: "http://example0.com/", title: "site#0"},
|
||||
* {url: "http://example1.com/", title: "site#1"},
|
||||
* {url: "http://example2.com/", title: "site#2"},
|
||||
* {url: "http://example3.com/", title: "site#3"}]
|
||||
*/
|
||||
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};
|
||||
return {url: "http://example" + (id != "-1" ? id : "") + ".com/",
|
||||
title: "site#" + id};
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -284,7 +287,7 @@ function fillHistory(aLinks, aCallback) {
|
|||
* @param aLinksPattern the pattern (see below)
|
||||
*
|
||||
* Example: setPinnedLinks("3,,1")
|
||||
* Result: 'http://example.com/#3' is pinned in the first cell. 'http://example.com/#1' is
|
||||
* Result: 'http://example3.com/' is pinned in the first cell. 'http://example1.com/' is
|
||||
* pinned in the third cell.
|
||||
*/
|
||||
function setPinnedLinks(aLinks) {
|
||||
|
@ -293,7 +296,8 @@ function setPinnedLinks(aLinks) {
|
|||
if (typeof links == "string") {
|
||||
links = aLinks.split(/\s*,\s*/).map(function (id) {
|
||||
if (id)
|
||||
return {url: "http://example.com/#" + id, title: "site#" + id};
|
||||
return {url: "http://example" + (id != "-1" ? id : "") + ".com/",
|
||||
title: "site#" + id};
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -355,9 +359,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 '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'.
|
||||
* Result: We expect the first cell to contain the pinned site 'http://example3.com/'.
|
||||
* The second cell contains 'http://example2.com/'. The third cell is empty.
|
||||
* The fourth cell contains the pinned site 'http://example4.com/'.
|
||||
*/
|
||||
function checkGrid(aSitesPattern, aSites) {
|
||||
let length = aSitesPattern.split(",").length;
|
||||
|
@ -372,7 +376,7 @@ function checkGrid(aSitesPattern, aSites) {
|
|||
if (pinned != hasPinnedAttr)
|
||||
ok(false, "invalid state (site.isPinned() != site[pinned])");
|
||||
|
||||
return aSite.url.replace(/^http:\/\/example\.com\/#(\d+)$/, "$1") + (pinned ? "p" : "");
|
||||
return aSite.url.replace(/^http:\/\/example(\d+)\.com\/$/, "$1") + (pinned ? "p" : "");
|
||||
});
|
||||
|
||||
is(current, aSitesPattern, "grid status = " + aSitesPattern);
|
||||
|
@ -489,7 +493,7 @@ function startAndCompleteDragOperation(aSource, aDest, aCallback) {
|
|||
*/
|
||||
function createExternalDropIframe() {
|
||||
const url = "data:text/html;charset=utf-8," +
|
||||
"<a id='link' href='http://example.com/%2399'>link</a>";
|
||||
"<a id='link' href='http://example99.com/'>link</a>";
|
||||
|
||||
let deferred = Promise.defer();
|
||||
let doc = getContentDocument();
|
||||
|
|
|
@ -36,14 +36,6 @@ function runTests() {
|
|||
{scheme: "https", cacheControl: "private", diskCacheSSL: false}
|
||||
];
|
||||
|
||||
let urls = positive.map((combi) => {
|
||||
let url = combi.scheme + URL;
|
||||
if (combi.cacheControl)
|
||||
url += "?" + combi.cacheControl;
|
||||
return url;
|
||||
});
|
||||
yield addVisitsAndRepopulateNewTabLinks(urls, next);
|
||||
|
||||
yield checkCombinations(positive, true);
|
||||
yield checkCombinations(negative, false);
|
||||
}
|
||||
|
@ -60,6 +52,13 @@ function checkCombinations(aCombinations, aResult) {
|
|||
url += "?" + combi.cacheControl;
|
||||
Services.prefs.setBoolPref(PREF_DISK_CACHE_SSL, combi.diskCacheSSL);
|
||||
|
||||
// Add the test page as a top link so it has a chance to be thumbnailed
|
||||
addVisitsAndRepopulateNewTabLinks(url, _ => {
|
||||
testCombination(combi, url, aCombinations, aResult);
|
||||
});
|
||||
}
|
||||
|
||||
function testCombination(combi, url, aCombinations, aResult) {
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab(url);
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
|
||||
|
|
|
@ -829,8 +829,34 @@ let Links = {
|
|||
let pinnedLinks = Array.slice(PinnedLinks.links);
|
||||
let links = this._getMergedProviderLinks();
|
||||
|
||||
// Filter blocked and pinned links.
|
||||
function getBaseDomain(url) {
|
||||
let uri;
|
||||
try {
|
||||
uri = Services.io.newURI(url, null, null);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return Services.eTLD.getBaseDomain(uri);
|
||||
} catch (e) {
|
||||
return uri.asciiHost;
|
||||
}
|
||||
}
|
||||
|
||||
let baseDomains = new Set();
|
||||
for (let link of pinnedLinks) {
|
||||
if (link)
|
||||
baseDomains.add(getBaseDomain(link.url));
|
||||
}
|
||||
|
||||
// Filter blocked and pinned links and duplicate base domains.
|
||||
links = links.filter(function (link) {
|
||||
let baseDomain = getBaseDomain(link.url);
|
||||
if (baseDomain == null || baseDomains.has(baseDomain))
|
||||
return false;
|
||||
baseDomains.add(baseDomain);
|
||||
|
||||
return !BlockedLinks.isBlocked(link) && !PinnedLinks.isPinned(link);
|
||||
});
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ function makeLinks(frecRangeStart, frecRangeEnd, step) {
|
|||
|
||||
function makeLink(frecency) {
|
||||
return {
|
||||
url: "http://example.com/" + frecency,
|
||||
url: "http://example" + frecency + ".com/",
|
||||
title: "My frecency is " + frecency,
|
||||
frecency: frecency,
|
||||
lastVisitDate: 0,
|
||||
|
|
Загрузка…
Ссылка в новой задаче