merge mozilla-inbound to mozilla-central a=merge

This commit is contained in:
Carsten "Tomcat" Book
2015-09-28 14:13:24 +02:00
568 changed files with 6536 additions and 3732 deletions

View File

@@ -313,11 +313,18 @@ var gFxAccounts = {
this.panelUILabel.setAttribute("label", profile.displayName);
}
if (profile.avatar) {
this.panelUIFooter.setAttribute("fxaprofileimage", "set");
let bgImage = "url(\"" + profile.avatar + "\")";
this.panelUIAvatar.style.listStyleImage = bgImage;
let img = new Image();
// Make sure the image is available before attempting to display it
img.onload = () => {
this.panelUIFooter.setAttribute("fxaprofileimage", "set");
this.panelUIAvatar.style.listStyleImage = "url('" + profile.avatar + "')";
img.onerror = () => {
// Clear the image if it has trouble loading. Since this callback is asynchronous
// we check to make sure the image is still the same before we clear it.
if (this.panelUIAvatar.style.listStyleImage === bgImage) {
this.panelUIFooter.removeAttribute("fxaprofileimage");
this.panelUIAvatar.style.removeProperty("list-style-image");
}
};
img.src = profile.avatar;
}

View File

@@ -334,13 +334,14 @@ var PlacesCommandHook = {
var title;
var description;
var charset;
let docInfo = yield this._getPageDetails(aBrowser);
try {
let isErrorPage = /^about:(neterror|certerror|blocked)/
.test(aBrowser.contentDocumentAsCPOW.documentURI);
title = isErrorPage ? PlacesUtils.history.getPageTitle(uri)
: aBrowser.contentTitle;
title = docInfo.isErrorPage ? PlacesUtils.history.getPageTitle(uri)
: aBrowser.contentTitle;
title = title || uri.spec;
description = PlacesUIUtils.getDescriptionFromDocument(aBrowser.contentDocumentAsCPOW);
description = docInfo.description;
charset = aBrowser.characterSet;
}
catch (e) { }
@@ -405,14 +406,15 @@ var PlacesCommandHook = {
// Bug 1148838 - Make this code work for full page plugins.
let description = null;
let charset = null;
let docInfo = yield this._getPageDetails(aBrowser);
try {
let isErrorPage = /^about:(neterror|certerror|blocked)/
.test(aBrowser.contentDocumentAsCPOW.documentURI);
info.title = isErrorPage ?
info.title = docInfo.isErrorPage ?
(yield PlacesUtils.promisePlaceInfo(aBrowser.currentURI)).title :
aBrowser.contentTitle;
info.title = info.title || url.href;
description = PlacesUIUtils.getDescriptionFromDocument(aBrowser.contentDocumentAsCPOW);
description = docInfo.description;
charset = aBrowser.characterSet;
}
catch (e) {
@@ -467,6 +469,18 @@ var PlacesCommandHook = {
}
}),
_getPageDetails(browser) {
return new Promise(resolve => {
let mm = browser.messageManager;
mm.addMessageListener("Bookmarks:GetPageDetails:Result", function listener(msg) {
mm.removeMessageListener("Bookmarks:GetPageDetails:Result", listener);
resolve(msg.data);
});
mm.sendAsyncMessage("Bookmarks:GetPageDetails", { })
});
},
/**
* Adds a bookmark to the page loaded in the current tab.
*/
@@ -568,21 +582,18 @@ var PlacesCommandHook = {
* @subtitle subtitle
* A short description of the feed. Optional.
*/
addLiveBookmark: function PCH_addLiveBookmark(url, feedTitle, feedSubtitle) {
var feedURI = makeURI(url);
var doc = gBrowser.contentDocumentAsCPOW;
var title = (arguments.length > 1) ? feedTitle : doc.title;
var description;
if (arguments.length > 2)
description = feedSubtitle;
else
description = PlacesUIUtils.getDescriptionFromDocument(doc);
var toolbarIP = new InsertionPoint(PlacesUtils.toolbarFolderId,
addLiveBookmark: Task.async(function *(url, feedTitle, feedSubtitle) {
let toolbarIP = new InsertionPoint(PlacesUtils.toolbarFolderId,
PlacesUtils.bookmarks.DEFAULT_INDEX,
Components.interfaces.nsITreeView.DROP_ON);
let feedURI = makeURI(url);
let title = feedTitle || gBrowser.contentTitle;
let description = feedSubtitle;
if (!description) {
description = (yield this._getPageDetails(gBrowser.selectedBrowser)).description;
}
PlacesUIUtils.showBookmarkDialog({ action: "add"
, type: "livemark"
, feedURI: feedURI
@@ -594,7 +605,7 @@ var PlacesCommandHook = {
, "siteLocation"
, "description" ]
}, window);
},
}),
/**
* Opens the Places Organizer.

View File

@@ -753,6 +753,14 @@ addMessageListener("ContextMenu:SearchFieldBookmarkData", (message) => {
{ spec, title, description, postData, charset });
});
addMessageListener("Bookmarks:GetPageDetails", (message) => {
let doc = content.document;
let isErrorPage = /^about:(neterror|certerror|blocked)/.test(doc.documentURI);
sendAsyncMessage("Bookmarks:GetPageDetails:Result",
{ isErrorPage: isErrorPage,
description: PlacesUIUtils.getDescriptionFromDocument(doc) });
});
var LightWeightThemeWebInstallListener = {
_previewWindow: null,

View File

@@ -122,6 +122,12 @@ input[type=button] {
pointer-events: none;
}
/*
* If you change the sizes here, make sure you
* change the preferences:
* toolkit.pageThumbs.minWidth
* toolkit.pageThumbs.minHeight
*/
/* CELLS */
.newtab-cell,
.newtab-intro-cell,

View File

@@ -19,30 +19,19 @@ var tests = [
'https://untrusted.example.com/somepage.html']
];
function generatorTest() {
add_task(function* () {
gBrowser.selectedTab = gBrowser.addTab();
let browser = gBrowser.selectedBrowser;
browser.stop(); // stop the about:blank load.
browser.addEventListener("DOMContentLoaded", event => {
if (event.originalTarget != browser.contentDocument ||
event.target.location.href == "about:blank") {
info("skipping spurious load event");
return;
}
nextStep();
}, true);
registerCleanupFunction(function () {
browser.removeEventListener("DOMContentLoaded", nextStep, true);
gBrowser.removeCurrentTab();
});
// Test that a bookmark of each URI gets the corresponding default title.
for (let i = 0; i < tests.length; ++i) {
let [uri, title] = tests[i];
let promiseLoaded = promisePageLoaded(browser);
content.location = uri;
yield undefined;
checkBookmark(uri, title);
yield promiseLoaded;
yield checkBookmark(uri, title);
}
// Network failure test: now that dummy_page.html is in history, bookmarking
@@ -62,20 +51,28 @@ function generatorTest() {
Services.cache2.clear();
let [uri, title] = tests[0];
let promiseLoaded = promisePageLoaded(browser);
content.location = uri;
yield undefined;
yield promiseLoaded;
// The offline mode test is only good if the page failed to load.
is(content.document.documentURI.substring(0, 14), 'about:neterror',
"Offline mode successfully simulated network outage.");
checkBookmark(uri, title);
}
yield checkBookmark(uri, title);
gBrowser.removeCurrentTab();
});
// Bookmark the current page and confirm that the new bookmark has the expected
// title. (Then delete the bookmark.)
function checkBookmark(uri, expected_title) {
function* checkBookmark(uri, expected_title) {
is(gBrowser.selectedBrowser.currentURI.spec, uri,
"Trying to bookmark the expected uri");
let promiseBookmark = promiseOnBookmarkItemAdded(gBrowser.selectedBrowser.currentURI);
PlacesCommandHook.bookmarkCurrentPage(false);
yield promiseBookmark;
let id = PlacesUtils.getMostRecentBookmarkForURI(PlacesUtils._uri(uri));
ok(id > 0, "Found the expected bookmark");
@@ -84,3 +81,21 @@ function checkBookmark(uri, expected_title) {
PlacesUtils.bookmarks.removeItem(id);
}
// BrowserTestUtils.browserLoaded doesn't work for the about pages, so use a
// custom page load listener.
function promisePageLoaded(browser)
{
return new Promise(resolve => {
browser.addEventListener("DOMContentLoaded", function pageLoaded(event) {
browser.removeEventListener("DOMContentLoaded", pageLoaded, true);
if (event.originalTarget != browser.contentDocument ||
event.target.location.href == "about:blank") {
info("skipping spurious load event");
return;
}
resolve();
}, true);
});
}

View File

@@ -24,7 +24,7 @@ add_task(function* test_star_redirect() {
yield promiseStarState(BookmarkingUI.STATUS_UNSTARRED);
let promiseBookmark = promiseOnItemAdded(gBrowser.currentURI);
let promiseBookmark = promiseOnBookmarkItemAdded(gBrowser.currentURI);
BookmarkingUI.star.click();
// This resolves on the next tick, so the star should have already been
// updated at that point.
@@ -83,32 +83,3 @@ function promiseTabLoadEvent(aTab, aURL, aFinalURL)
aTab.linkedBrowser.loadURI(aURL);
return deferred.promise;
}
/**
* Waits for a bookmark to be added for the given uri.
*/
function promiseOnItemAdded(aExpectedURI) {
let defer = Promise.defer();
let bookmarksObserver = {
onItemAdded: function (aItemId, aFolderId, aIndex, aItemType, aURI) {
info("Added a bookmark to " + aURI.spec);
PlacesUtils.bookmarks.removeObserver(bookmarksObserver);
if (aURI.equals(aExpectedURI))
defer.resolve();
else
defer.reject(new Error("Added an unexpected bookmark"));
},
onBeginUpdateBatch: function () {},
onEndUpdateBatch: function () {},
onItemRemoved: function () {},
onItemChanged: function () {},
onItemVisited: function () {},
onItemMoved: function () {},
QueryInterface: XPCOMUtils.generateQI([
Ci.nsINavBookmarkObserver,
])
};
info("Waiting for a bookmark to be added");
PlacesUtils.bookmarks.addObserver(bookmarksObserver, false);
return defer.promise;
}

View File

@@ -1072,3 +1072,34 @@ function isSecurityState(expectedState) {
is(expectedState, actualState, "Expected state " + expectedState + " and the actual state is " + actualState + ".");
}
/**
* Resolves when a bookmark with the given uri is added.
*/
function promiseOnBookmarkItemAdded(aExpectedURI) {
return new Promise((resolve, reject) => {
let bookmarksObserver = {
onItemAdded: function (aItemId, aFolderId, aIndex, aItemType, aURI) {
info("Added a bookmark to " + aURI.spec);
PlacesUtils.bookmarks.removeObserver(bookmarksObserver);
if (aURI.equals(aExpectedURI)) {
resolve();
}
else {
reject(new Error("Added an unexpected bookmark"));
}
},
onBeginUpdateBatch: function () {},
onEndUpdateBatch: function () {},
onItemRemoved: function () {},
onItemChanged: function () {},
onItemVisited: function () {},
onItemMoved: function () {},
QueryInterface: XPCOMUtils.generateQI([
Ci.nsINavBookmarkObserver,
])
};
info("Waiting for a bookmark to be added");
PlacesUtils.bookmarks.addObserver(bookmarksObserver, false);
});
}