mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
Backout 79e1475e5b35 (bug 1131457) for more bc failures.
This commit is contained in:
parent
88798b3c1f
commit
1dbad789bb
@ -10,34 +10,15 @@ XPCOMUtils.defineLazyModuleGetter(this, "ReadingList",
|
||||
const READINGLIST_COMMAND_ID = "readingListSidebar";
|
||||
|
||||
let ReadingListUI = {
|
||||
/**
|
||||
* Frame-script messages we want to listen to.
|
||||
* @type {[string]}
|
||||
*/
|
||||
MESSAGES: [
|
||||
"ReadingList:GetVisibility",
|
||||
"ReadingList:ToggleVisibility",
|
||||
],
|
||||
|
||||
/**
|
||||
* Add-to-ReadingList toolbar button in the URLbar.
|
||||
* @type {Element}
|
||||
*/
|
||||
toolbarButton: null,
|
||||
|
||||
/**
|
||||
* Whether this object is currently registered as a listener with ReadingList.
|
||||
* Used to avoid inadvertantly loading the ReadLingList.jsm module on startup.
|
||||
* @type {Boolean}
|
||||
*/
|
||||
listenerRegistered: false,
|
||||
|
||||
/**
|
||||
* Initialize the ReadingList UI.
|
||||
*/
|
||||
init() {
|
||||
this.toolbarButton = document.getElementById("readinglist-addremove-button");
|
||||
|
||||
Preferences.observe("browser.readinglist.enabled", this.updateUI, this);
|
||||
|
||||
const mm = window.messageManager;
|
||||
@ -82,18 +63,7 @@ let ReadingListUI = {
|
||||
*/
|
||||
updateUI() {
|
||||
let enabled = this.enabled;
|
||||
if (enabled) {
|
||||
// This is a no-op if we're already registered.
|
||||
ReadingList.addListener(this);
|
||||
this.listenerRegistered = true;
|
||||
} else {
|
||||
if (this.listenerRegistered) {
|
||||
// This is safe to call if we're not currently registered, but we don't
|
||||
// want to forcibly load the normally lazy-loaded module on startup.
|
||||
ReadingList.removeListener(this);
|
||||
this.listenerRegistered = true;
|
||||
}
|
||||
|
||||
if (!enabled) {
|
||||
this.hideSidebar();
|
||||
}
|
||||
|
||||
@ -119,11 +89,6 @@ let ReadingListUI = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Re-refresh the ReadingList bookmarks submenu when it opens.
|
||||
*
|
||||
* @param {Element} target - Menu element opening.
|
||||
*/
|
||||
onReadingListPopupShowing: Task.async(function* (target) {
|
||||
if (target.id == "BMB_readingListPopup") {
|
||||
// Setting this class in the .xul file messes with the way
|
||||
@ -219,92 +184,4 @@ let ReadingListUI = {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles toolbar button styling based on page proxy state changes.
|
||||
*
|
||||
* @see SetPageProxyState()
|
||||
*
|
||||
* @param {string} state - New state. Either "valid" or "invalid".
|
||||
*/
|
||||
onPageProxyStateChanged: Task.async(function* (state) {
|
||||
if (!this.enabled || state == "invalid") {
|
||||
this.toolbarButton.setAttribute("hidden", true);
|
||||
return;
|
||||
}
|
||||
|
||||
let isInList = yield ReadingList.containsURL(gBrowser.currentURI);
|
||||
this.setToolbarButtonState(isInList);
|
||||
}),
|
||||
|
||||
/**
|
||||
* Set the state of the ReadingList toolbar button in the urlbar.
|
||||
* If the current tab's page is in the ReadingList (active), sets the button
|
||||
* to allow removing the page. Otherwise, sets the button to allow adding the
|
||||
* page (not active).
|
||||
*
|
||||
* @param {boolean} active - True if the button should be active (page is
|
||||
* already in the list).
|
||||
*/
|
||||
setToolbarButtonState(active) {
|
||||
this.toolbarButton.setAttribute("already-added", active);
|
||||
|
||||
let type = (active ? "remove" : "add");
|
||||
let tooltip = gNavigatorBundle.getString(`readingList.urlbar.${type}`);
|
||||
this.toolbarButton.setAttribute("tooltiptext", tooltip);
|
||||
|
||||
this.toolbarButton.removeAttribute("hidden");
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle a page (from a browser) in the ReadingList, adding if it's not already added, or
|
||||
* removing otherwise.
|
||||
*
|
||||
* @param {<xul:browser>} browser - Browser with page to toggle.
|
||||
* @returns {Promise} Promise resolved when operation has completed.
|
||||
*/
|
||||
togglePageByBrowser: Task.async(function* (browser) {
|
||||
let item = yield ReadingList.getItemForURL(browser.currentURI);
|
||||
if (item) {
|
||||
yield item.delete();
|
||||
} else {
|
||||
yield ReadingList.addItemFromBrowser(browser);
|
||||
}
|
||||
}),
|
||||
|
||||
/**
|
||||
* Checks if a given item matches the current tab in this window.
|
||||
*
|
||||
* @param {ReadingListItem} item - Item to check
|
||||
* @returns True if match, false otherwise.
|
||||
*/
|
||||
isItemForCurrentBrowser(item) {
|
||||
let currentURL = gBrowser.currentURI.spec;
|
||||
if (item.url == currentURL || item.resolvedURL == currentURL) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* ReadingList event handler for when an item is added.
|
||||
*
|
||||
* @param {ReadingListItem} item - Item added.
|
||||
*/
|
||||
onItemAdded(item) {
|
||||
if (this.isItemForCurrentBrowser(item)) {
|
||||
this.setToolbarButtonState(true);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* ReadingList event handler for when an item is deleted.
|
||||
*
|
||||
* @param {ReadingListItem} item - Item deleted.
|
||||
*/
|
||||
onItemDeleted(item) {
|
||||
if (this.isItemForCurrentBrowser(item)) {
|
||||
this.setToolbarButtonState(false);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -1022,7 +1022,6 @@ var gBrowserInit = {
|
||||
CombinedStopReload.init();
|
||||
gPrivateBrowsingUI.init();
|
||||
TabsInTitlebar.init();
|
||||
ReadingListUI.init();
|
||||
|
||||
#ifdef XP_WIN
|
||||
if (window.matchMedia("(-moz-os-version: windows-win8)").matches &&
|
||||
@ -1380,6 +1379,7 @@ var gBrowserInit = {
|
||||
|
||||
SocialUI.init();
|
||||
TabView.init();
|
||||
ReadingListUI.init();
|
||||
|
||||
// Telemetry for master-password - we do this after 5 seconds as it
|
||||
// can cause IO if NSS/PSM has not already initialized.
|
||||
@ -2421,7 +2421,6 @@ function UpdatePageProxyState()
|
||||
function SetPageProxyState(aState)
|
||||
{
|
||||
BookmarkingUI.onPageProxyStateChanged(aState);
|
||||
ReadingListUI.onPageProxyStateChanged(aState);
|
||||
|
||||
if (!gURLBar)
|
||||
return;
|
||||
|
@ -827,10 +827,6 @@
|
||||
hidden="true"
|
||||
tooltiptext="&pageReportIcon.tooltip;"
|
||||
onclick="gPopupBlockerObserver.onReportButtonClick(event);"/>
|
||||
<toolbarbutton id="readinglist-addremove-button"
|
||||
class="tabbable urlbar-icon"
|
||||
hidden="true"
|
||||
oncommand="ReadingListUI.togglePageByBrowser(gBrowser.selectedBrowser);"/>
|
||||
<toolbarbutton id="reader-mode-button"
|
||||
class="tabbable"
|
||||
hidden="true"
|
||||
|
@ -1017,12 +1017,12 @@ addEventListener("pageshow", function(event) {
|
||||
});
|
||||
|
||||
let PageMetadataMessenger = {
|
||||
init() {
|
||||
init: function() {
|
||||
addMessageListener("PageMetadata:GetPageData", this);
|
||||
addMessageListener("PageMetadata:GetMicrodata", this);
|
||||
},
|
||||
receiveMessage(message) {
|
||||
switch(message.name) {
|
||||
receiveMessage: function(aMessage) {
|
||||
switch(aMessage.name) {
|
||||
case "PageMetadata:GetPageData": {
|
||||
let result = PageMetadata.getData(content.document);
|
||||
sendAsyncMessage("PageMetadata:PageDataResult", result);
|
||||
@ -1030,7 +1030,7 @@ let PageMetadataMessenger = {
|
||||
}
|
||||
|
||||
case "PageMetadata:GetMicrodata": {
|
||||
let target = message.objects;
|
||||
let target = aMessage.objects;
|
||||
let result = PageMetadata.getMicrodata(content.document, target);
|
||||
sendAsyncMessage("PageMetadata:MicrodataResult", result);
|
||||
break;
|
||||
|
@ -129,38 +129,6 @@ ReadingListImpl.prototype = {
|
||||
return (yield this._store.count(...optsList));
|
||||
}),
|
||||
|
||||
/**
|
||||
* Checks whether a given URL is in the ReadingList already.
|
||||
*
|
||||
* @param {String/nsIURI} url - URL to check.
|
||||
* @returns {Promise} Promise that is fulfilled with a boolean indicating
|
||||
* whether the URL is in the list or not.
|
||||
*/
|
||||
containsURL: Task.async(function* (url) {
|
||||
url = normalizeURI(url).spec;
|
||||
|
||||
// This is used on every tab switch and page load of the current tab, so we
|
||||
// want it to be quick and avoid a DB query whenever possible.
|
||||
|
||||
// First check if any cached items have a direct match.
|
||||
if (this._itemsByURL.has(url)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Then check if any cached items may have a different resolved URL
|
||||
// that matches.
|
||||
for (let itemWeakRef of this._itemsByURL.values()) {
|
||||
let item = itemWeakRef.get();
|
||||
if (item && item.resolvedURL == url) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, fall back to the DB.
|
||||
let count = yield this.count({url: url}, {resolvedURL: url});
|
||||
return (count > 0);
|
||||
}),
|
||||
|
||||
/**
|
||||
* Enumerates the items in the list that match the given options.
|
||||
*
|
||||
@ -222,7 +190,6 @@ ReadingListImpl.prototype = {
|
||||
*/
|
||||
addItem: Task.async(function* (obj) {
|
||||
obj = stripNonItemProperties(obj);
|
||||
normalizeReadingListProperties(obj);
|
||||
yield this._store.addItem(obj);
|
||||
this._invalidateIterators();
|
||||
let item = this._itemFromObject(obj);
|
||||
@ -281,38 +248,11 @@ ReadingListImpl.prototype = {
|
||||
* @param {String/nsIURI} uri - URI to match against. This will be normalized.
|
||||
*/
|
||||
getItemForURL: Task.async(function* (uri) {
|
||||
let url = normalizeURI(uri).spec;
|
||||
let url = this._normalizeURI(uri).spec;
|
||||
let [item] = yield this.iterator({url: url}, {resolvedURL: url}).items(1);
|
||||
return item;
|
||||
}),
|
||||
|
||||
/**
|
||||
* Add to the ReadingList the page that is loaded in a given browser.
|
||||
*
|
||||
* @param {<xul:browser>} browser - Browser element for the document.
|
||||
* @return {Promise} Promise that is fullfilled with the added item.
|
||||
*/
|
||||
addItemFromBrowser: Task.async(function* (browser) {
|
||||
let metadata = yield getMetadataFromBrowser(browser);
|
||||
let itemData = {
|
||||
url: browser.currentURI,
|
||||
title: metadata.title,
|
||||
resolvedURL: metadata.url,
|
||||
excerpt: metadata.description,
|
||||
};
|
||||
|
||||
if (metadata.description) {
|
||||
itemData.exerpt = metadata.description;
|
||||
}
|
||||
|
||||
if (metadata.previews.length > 0) {
|
||||
itemData.image = metadata.previews[0];
|
||||
}
|
||||
|
||||
let item = yield ReadingList.addItem(itemData);
|
||||
return item;
|
||||
}),
|
||||
|
||||
/**
|
||||
* Adds a listener that will be notified when the list changes. Listeners
|
||||
* are objects with the following optional methods:
|
||||
@ -364,6 +304,22 @@ ReadingListImpl.prototype = {
|
||||
// A Set containing listener objects.
|
||||
_listeners: null,
|
||||
|
||||
/**
|
||||
* Normalize a URI, stripping away extraneous parts we don't want to store
|
||||
* or compare against.
|
||||
*
|
||||
* @param {nsIURI/String} uri - URI to normalize.
|
||||
* @returns {nsIURI} Cloned and normalized version of the input URI.
|
||||
*/
|
||||
_normalizeURI(uri) {
|
||||
if (typeof uri == "string") {
|
||||
uri = Services.io.newURI(uri, "", null);
|
||||
}
|
||||
uri = uri.cloneIgnoringRef();
|
||||
uri.userPass = "";
|
||||
return uri;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the ReadingListItem represented by the given simple object. If
|
||||
* the item doesn't exist yet, it's created first.
|
||||
@ -419,26 +375,12 @@ ReadingListImpl.prototype = {
|
||||
},
|
||||
|
||||
_ensureItemBelongsToList(item) {
|
||||
if (!item || !item._ensureBelongsToList) {
|
||||
throw new Error("The item is not a ReadingListItem");
|
||||
if (item.list != this) {
|
||||
throw new Error("The item does not belong to this list");
|
||||
}
|
||||
item._ensureBelongsToList();
|
||||
},
|
||||
};
|
||||
|
||||
/*
|
||||
* normalize the properties of a "regular" object that reflects a ReadingListItem
|
||||
*/
|
||||
function normalizeReadingListProperties(obj) {
|
||||
if (obj.url) {
|
||||
obj.url = normalizeURI(obj.url).spec;
|
||||
}
|
||||
if (obj.resolvedURL) {
|
||||
obj.resolvedURL = normalizeURI(obj.resolvedURL).spec;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let _unserializable = () => {}; // See comments in the ReadingListItem ctor.
|
||||
|
||||
/**
|
||||
@ -489,6 +431,9 @@ ReadingListItem.prototype = {
|
||||
},
|
||||
set guid(val) {
|
||||
this._properties.guid = val;
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -502,6 +447,9 @@ ReadingListItem.prototype = {
|
||||
},
|
||||
set lastModified(val) {
|
||||
this._properties.lastModified = val.valueOf();
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -512,7 +460,10 @@ ReadingListItem.prototype = {
|
||||
return this._properties.url;
|
||||
},
|
||||
set url(val) {
|
||||
this._properties.url = normalizeURI(val).spec;
|
||||
this._properties.url = val;
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -525,7 +476,10 @@ ReadingListItem.prototype = {
|
||||
undefined;
|
||||
},
|
||||
set uri(val) {
|
||||
this.url = normalizeURI(val).spec;
|
||||
this.url = val.spec;
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -548,7 +502,10 @@ ReadingListItem.prototype = {
|
||||
return this._properties.resolvedURL;
|
||||
},
|
||||
set resolvedURL(val) {
|
||||
this._properties.resolvedURL = normalizeURI(val).spec;
|
||||
this._properties.resolvedURL = val;
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -562,6 +519,9 @@ ReadingListItem.prototype = {
|
||||
},
|
||||
set resolvedURI(val) {
|
||||
this.resolvedURL = val.spec;
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -573,6 +533,9 @@ ReadingListItem.prototype = {
|
||||
},
|
||||
set title(val) {
|
||||
this._properties.title = val;
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -584,6 +547,9 @@ ReadingListItem.prototype = {
|
||||
},
|
||||
set resolvedTitle(val) {
|
||||
this._properties.resolvedTitle = val;
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -595,6 +561,9 @@ ReadingListItem.prototype = {
|
||||
},
|
||||
set excerpt(val) {
|
||||
this._properties.excerpt = val;
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -606,6 +575,9 @@ ReadingListItem.prototype = {
|
||||
},
|
||||
set status(val) {
|
||||
this._properties.status = val;
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -617,6 +589,9 @@ ReadingListItem.prototype = {
|
||||
},
|
||||
set favorite(val) {
|
||||
this._properties.favorite = !!val;
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -628,6 +603,9 @@ ReadingListItem.prototype = {
|
||||
},
|
||||
set isArticle(val) {
|
||||
this._properties.isArticle = !!val;
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -639,6 +617,9 @@ ReadingListItem.prototype = {
|
||||
},
|
||||
set wordCount(val) {
|
||||
this._properties.wordCount = val;
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -650,6 +631,9 @@ ReadingListItem.prototype = {
|
||||
},
|
||||
set unread(val) {
|
||||
this._properties.unread = !!val;
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -663,6 +647,9 @@ ReadingListItem.prototype = {
|
||||
},
|
||||
set addedOn(val) {
|
||||
this._properties.addedOn = val.valueOf();
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -676,6 +663,9 @@ ReadingListItem.prototype = {
|
||||
},
|
||||
set storedOn(val) {
|
||||
this._properties.storedOn = val.valueOf();
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -687,6 +677,9 @@ ReadingListItem.prototype = {
|
||||
},
|
||||
set markedReadBy(val) {
|
||||
this._properties.markedReadBy = val;
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -700,6 +693,9 @@ ReadingListItem.prototype = {
|
||||
},
|
||||
set markedReadOn(val) {
|
||||
this._properties.markedReadOn = val.valueOf();
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -711,24 +707,25 @@ ReadingListItem.prototype = {
|
||||
},
|
||||
set readPosition(val) {
|
||||
this._properties.readPosition = val;
|
||||
if (this.list) {
|
||||
this.commit();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the given properties of the item, optionally calling list.updateItem().
|
||||
* Sets the given properties of the item, optionally calling commit().
|
||||
*
|
||||
* @param props A simple object containing the properties to set.
|
||||
* @param update If true, updateItem() is called for this item.
|
||||
* @return Promise<null> If update is true, resolved when the update
|
||||
* @param commit If true, commit() is called.
|
||||
* @return Promise<null> If commit is true, resolved when the commit
|
||||
* completes; otherwise resolved immediately.
|
||||
*/
|
||||
setProperties: Task.async(function* (props, update=true) {
|
||||
setProperties: Task.async(function* (props, commit=true) {
|
||||
for (let name in props) {
|
||||
this._properties[name] = props[name];
|
||||
}
|
||||
// make sure everything is normalized.
|
||||
normalizeReadingListProperties(this._properties);
|
||||
if (update) {
|
||||
yield this.list.updateItem(this);
|
||||
if (commit) {
|
||||
yield this.commit();
|
||||
}
|
||||
}),
|
||||
|
||||
@ -743,6 +740,17 @@ ReadingListItem.prototype = {
|
||||
this.delete = () => Promise.reject("The item has already been deleted");
|
||||
}),
|
||||
|
||||
/**
|
||||
* Notifies the item's list that the item has changed so that the list can
|
||||
* update itself.
|
||||
*
|
||||
* @return Promise<null> Resolved when the list has been updated.
|
||||
*/
|
||||
commit: Task.async(function* () {
|
||||
this._ensureBelongsToList();
|
||||
yield this.list.updateItem(this);
|
||||
}),
|
||||
|
||||
toJSON() {
|
||||
return this._properties;
|
||||
},
|
||||
@ -847,23 +855,6 @@ ReadingListItemIterator.prototype = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Normalize a URI, stripping away extraneous parts we don't want to store
|
||||
* or compare against.
|
||||
*
|
||||
* @param {nsIURI/String} uri - URI to normalize.
|
||||
* @returns {nsIURI} Cloned and normalized version of the input URI.
|
||||
*/
|
||||
function normalizeURI(uri) {
|
||||
if (typeof uri == "string") {
|
||||
uri = Services.io.newURI(uri, "", null);
|
||||
}
|
||||
uri = uri.cloneIgnoringRef();
|
||||
try {
|
||||
uri.userPass = "";
|
||||
} catch (ex) {} // nsSimpleURI etc don't support .userPass
|
||||
return uri;
|
||||
};
|
||||
|
||||
function stripNonItemProperties(item) {
|
||||
let obj = {};
|
||||
@ -894,24 +885,6 @@ function clone(obj) {
|
||||
return Cu.cloneInto(obj, {}, { cloneFunctions: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Get page metadata from the content document in a given <xul:browser>.
|
||||
* @see PageMetadata.jsm
|
||||
*
|
||||
* @param {<xul:browser>} browser - Browser element for the document.
|
||||
* @returns {Promise} Promise that is fulfilled with an object describing the metadata.
|
||||
*/
|
||||
function getMetadataFromBrowser(browser) {
|
||||
let mm = browser.messageManager;
|
||||
return new Promise(resolve => {
|
||||
function handleResult(msg) {
|
||||
mm.removeMessageListener("PageMetadata:PageDataResult", handleResult);
|
||||
resolve(msg.json);
|
||||
}
|
||||
mm.addMessageListener("PageMetadata:PageDataResult", handleResult);
|
||||
mm.sendAsyncMessage("PageMetadata:GetPageData");
|
||||
});
|
||||
}
|
||||
|
||||
Object.defineProperty(this, "ReadingList", {
|
||||
get() {
|
||||
|
@ -122,11 +122,10 @@ add_task(function* constraints() {
|
||||
checkError(err);
|
||||
|
||||
// update an item with an existing url
|
||||
let rlitem = yield gList.getItemForURL(gItems[0].url);
|
||||
rlitem.guid = gItems[1].guid;
|
||||
item.guid = gItems[1].guid;
|
||||
err = null;
|
||||
try {
|
||||
yield gList.updateItem(rlitem);
|
||||
yield gList.updateItem(item);
|
||||
}
|
||||
catch (e) {
|
||||
err = e;
|
||||
@ -146,11 +145,10 @@ add_task(function* constraints() {
|
||||
checkError(err);
|
||||
|
||||
// update an item with an existing resolvedURL
|
||||
rlitem = yield gList.getItemForURL(gItems[0].url);
|
||||
rlitem.url = gItems[1].url;
|
||||
item.url = gItems[1].url;
|
||||
err = null;
|
||||
try {
|
||||
yield gList.updateItem(rlitem);
|
||||
yield gList.updateItem(item);
|
||||
}
|
||||
catch (e) {
|
||||
err = e;
|
||||
@ -161,33 +159,35 @@ add_task(function* constraints() {
|
||||
item = kindOfClone(gItems[0]);
|
||||
delete item.guid;
|
||||
err = null;
|
||||
let rlitem1;
|
||||
try {
|
||||
rlitem1 = yield gList.addItem(item);
|
||||
yield gList.addItem(item);
|
||||
}
|
||||
catch (e) {
|
||||
err = e;
|
||||
}
|
||||
Assert.ok(!err, err ? err.message : undefined);
|
||||
let item1 = item;
|
||||
|
||||
// add a second item with no guid, which is allowed
|
||||
item = kindOfClone(gItems[1]);
|
||||
delete item.guid;
|
||||
err = null;
|
||||
let rlitem2;
|
||||
try {
|
||||
rlitem2 = yield gList.addItem(item);
|
||||
yield gList.addItem(item);
|
||||
}
|
||||
catch (e) {
|
||||
err = e;
|
||||
}
|
||||
Assert.ok(!err, err ? err.message : undefined);
|
||||
let item2 = item;
|
||||
|
||||
// Delete both items since other tests assume the store contains only gItems.
|
||||
yield gList.deleteItem(rlitem1);
|
||||
yield gList.deleteItem(rlitem2);
|
||||
item1.list = gList;
|
||||
item2.list = gList;
|
||||
yield gList.deleteItem(item1);
|
||||
yield gList.deleteItem(item2);
|
||||
let items = [];
|
||||
yield gList.forEachItem(i => items.push(i), { url: [rlitem1.url, rlitem2.url] });
|
||||
yield gList.forEachItem(i => items.push(i), { url: [item1.url, item2.url] });
|
||||
Assert.equal(items.length, 0);
|
||||
|
||||
// add a new item with no url
|
||||
@ -513,12 +513,15 @@ add_task(function* updateItem() {
|
||||
guid: gItems[0].guid,
|
||||
});
|
||||
Assert.equal(items.length, 1);
|
||||
let item = items[0];
|
||||
let item = {
|
||||
_properties: items[0]._properties,
|
||||
list: items[0].list,
|
||||
};
|
||||
|
||||
// update its title
|
||||
let newTitle = "updateItem new title";
|
||||
Assert.notEqual(item.title, newTitle);
|
||||
item.title = newTitle;
|
||||
item._properties.title = newTitle;
|
||||
yield gList.updateItem(item);
|
||||
|
||||
// get the item again
|
||||
@ -539,7 +542,7 @@ add_task(function* item_setProperties() {
|
||||
let item = (yield iter.items(1))[0];
|
||||
Assert.ok(item);
|
||||
|
||||
// item.setProperties(update=false). After fetching the item again, its title
|
||||
// item.setProperties(commit=false). After fetching the item again, its title
|
||||
// should be the old title.
|
||||
let oldTitle = item.title;
|
||||
let newTitle = "item_setProperties title 1";
|
||||
@ -553,7 +556,7 @@ add_task(function* item_setProperties() {
|
||||
Assert.ok(item === sameItem);
|
||||
Assert.equal(sameItem.title, oldTitle);
|
||||
|
||||
// item.setProperties(update=true). After fetching the item again, its title
|
||||
// item.setProperties(commit=true). After fetching the item again, its title
|
||||
// should be the new title.
|
||||
newTitle = "item_setProperties title 2";
|
||||
item.setProperties({ title: newTitle }, true);
|
||||
@ -569,7 +572,6 @@ add_task(function* item_setProperties() {
|
||||
// be the new title.
|
||||
newTitle = "item_setProperties title 3";
|
||||
item.title = newTitle;
|
||||
gList.updateItem(item);
|
||||
Assert.equal(item.title, newTitle);
|
||||
iter = gList.iterator({
|
||||
sort: "guid",
|
||||
@ -580,7 +582,6 @@ add_task(function* item_setProperties() {
|
||||
});
|
||||
|
||||
add_task(function* listeners() {
|
||||
Assert.equal((yield gList.count()), gItems.length);
|
||||
// add an item
|
||||
let resolve;
|
||||
let listenerPromise = new Promise(r => resolve = r);
|
||||
@ -593,7 +594,6 @@ add_task(function* listeners() {
|
||||
Assert.ok(items[0]);
|
||||
Assert.ok(items[0] === items[1]);
|
||||
gList.removeListener(listener);
|
||||
Assert.equal((yield gList.count()), gItems.length + 1);
|
||||
|
||||
// update an item
|
||||
listenerPromise = new Promise(r => resolve = r);
|
||||
@ -602,12 +602,10 @@ add_task(function* listeners() {
|
||||
};
|
||||
gList.addListener(listener);
|
||||
items[0].title = "listeners new title";
|
||||
gList.updateItem(items[0]);
|
||||
let listenerItem = yield listenerPromise;
|
||||
Assert.ok(listenerItem);
|
||||
Assert.ok(listenerItem === items[0]);
|
||||
gList.removeListener(listener);
|
||||
Assert.equal((yield gList.count()), gItems.length + 1);
|
||||
|
||||
// delete an item
|
||||
listenerPromise = new Promise(r => resolve = r);
|
||||
@ -620,7 +618,6 @@ add_task(function* listeners() {
|
||||
Assert.ok(listenerItem);
|
||||
Assert.ok(listenerItem === items[0]);
|
||||
gList.removeListener(listener);
|
||||
Assert.equal((yield gList.count()), gItems.length);
|
||||
});
|
||||
|
||||
// This test deletes items so it should probably run last.
|
||||
@ -641,7 +638,7 @@ add_task(function* deleteItem() {
|
||||
checkItems(items, gItems.slice(1));
|
||||
|
||||
// delete second item with list.deleteItem()
|
||||
yield gList.deleteItem(items[0]);
|
||||
yield gList.deleteItem(gItems[1]);
|
||||
gItems[1].list = null;
|
||||
Assert.equal((yield gList.count()), gItems.length - 2);
|
||||
items = [];
|
||||
@ -651,7 +648,7 @@ add_task(function* deleteItem() {
|
||||
checkItems(items, gItems.slice(2));
|
||||
|
||||
// delete third item with list.deleteItem()
|
||||
yield gList.deleteItem(items[0]);
|
||||
yield gList.deleteItem(gItems[2]);
|
||||
gItems[2].list = null;
|
||||
Assert.equal((yield gList.count()), gItems.length - 3);
|
||||
items = [];
|
||||
@ -676,7 +673,7 @@ function checkItems(actualItems, expectedItems) {
|
||||
|
||||
function checkError(err) {
|
||||
Assert.ok(err);
|
||||
Assert.ok(err instanceof Cu.getGlobalForObject(Sqlite).Error, err);
|
||||
Assert.ok(err instanceof Cu.getGlobalForObject(Sqlite).Error);
|
||||
}
|
||||
|
||||
function kindOfClone(item) {
|
||||
|
@ -60,12 +60,12 @@ let ReaderParent = {
|
||||
break;
|
||||
}
|
||||
case "Reader:ListStatusRequest":
|
||||
ReadingList.containsURL(message.data.url).then(inList => {
|
||||
ReadingList.count(message.data).then(count => {
|
||||
let mm = message.target.messageManager
|
||||
// Make sure the target browser is still alive before trying to send data back.
|
||||
if (mm) {
|
||||
mm.sendAsyncMessage("Reader:ListStatusData",
|
||||
{ inReadingList: inList, url: message.data.url });
|
||||
{ inReadingList: !!count, url: message.data.url });
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
@ -1629,8 +1629,6 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-
|
||||
list-style-image: url("chrome://browser/skin/Info.png");
|
||||
}
|
||||
|
||||
%include ../shared/readinglist.inc.css
|
||||
|
||||
/* Reader mode button */
|
||||
|
||||
#reader-mode-button {
|
||||
|
@ -91,7 +91,6 @@ browser.jar:
|
||||
skin/classic/browser/tab-crashed.svg (../shared/incontent-icons/tab-crashed.svg)
|
||||
skin/classic/browser/welcome-back.svg (../shared/incontent-icons/welcome-back.svg)
|
||||
skin/classic/browser/reader-mode-16.png (../shared/reader/reader-mode-16.png)
|
||||
skin/classic/browser/readinglist/icons.svg (../shared/readinglist/icons.svg)
|
||||
skin/classic/browser/readinglist/readinglist-icon.svg (../shared/readinglist/readinglist-icon.svg)
|
||||
skin/classic/browser/readinglist/sidebar.css (../shared/readinglist/sidebar.css)
|
||||
skin/classic/browser/webRTC-shareDevice-16.png
|
||||
|
@ -2523,8 +2523,6 @@ richlistitem[type~="action"][actiontype="switchtab"][selected="true"] > .ac-url-
|
||||
}
|
||||
}
|
||||
|
||||
%include ../shared/readinglist.inc.css
|
||||
|
||||
/* Reader mode button */
|
||||
|
||||
#reader-mode-button {
|
||||
|
@ -142,7 +142,6 @@ browser.jar:
|
||||
skin/classic/browser/welcome-back.svg (../shared/incontent-icons/welcome-back.svg)
|
||||
skin/classic/browser/reader-mode-16.png (../shared/reader/reader-mode-16.png)
|
||||
skin/classic/browser/reader-mode-16@2x.png (../shared/reader/reader-mode-16@2x.png)
|
||||
skin/classic/browser/readinglist/icons.svg (../shared/readinglist/icons.svg)
|
||||
skin/classic/browser/readinglist/readinglist-icon.svg (../shared/readinglist/readinglist-icon.svg)
|
||||
skin/classic/browser/readinglist/sidebar.css (../shared/readinglist/sidebar.css)
|
||||
skin/classic/browser/webRTC-shareDevice-16.png
|
||||
|
@ -1,38 +0,0 @@
|
||||
/* Reading List button */
|
||||
|
||||
#readinglist-addremove-button {
|
||||
-moz-appearance: none;
|
||||
border: none;
|
||||
list-style-image: url("chrome://browser/skin/readinglist/icons.svg#addpage");
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
#readinglist-addremove-button:hover {
|
||||
border: none;
|
||||
}
|
||||
|
||||
#readinglist-addremove-button > .toolbarbutton-icon {
|
||||
width: 16px;
|
||||
height: 16px
|
||||
}
|
||||
|
||||
#readinglist-addremove-button:not([already-added="true"]):hover {
|
||||
list-style-image: url("chrome://browser/skin/readinglist/icons.svg#addpage-hover");
|
||||
}
|
||||
|
||||
#readinglist-addremove-button:not([already-added="true"]):active {
|
||||
list-style-image: url("chrome://browser/skin/readinglist/icons.svg#addpage-active");
|
||||
}
|
||||
|
||||
#readinglist-addremove-button[already-added="true"] {
|
||||
list-style-image: url("chrome://browser/skin/readinglist/icons.svg#alreadyadded");
|
||||
}
|
||||
|
||||
#readinglist-addremove-button[already-added="true"]:hover {
|
||||
list-style-image: url("chrome://browser/skin/readinglist/icons.svg#alreadyadded-hover");
|
||||
}
|
||||
|
||||
#readinglist-addremove-button[already-added="true"]:active {
|
||||
list-style-image: url("chrome://browser/skin/readinglist/icons.svg#alreadyadded-active");
|
||||
}
|
||||
|
@ -1,57 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
viewBox="0 0 16 16"
|
||||
xml:space="preserve">
|
||||
|
||||
<defs>
|
||||
<style type="text/css">
|
||||
use:not(:target) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#addpage {
|
||||
fill: #808080;
|
||||
}
|
||||
#addpage-hover {
|
||||
fill: #555555;
|
||||
}
|
||||
#addpage-active {
|
||||
fill: #0095DD;
|
||||
}
|
||||
|
||||
#alreadyadded {
|
||||
fill: #0095DD;
|
||||
}
|
||||
#alreadyadded-hover {
|
||||
fill: #555555;
|
||||
}
|
||||
#alreadyadded-active {
|
||||
fill: #808080;
|
||||
}
|
||||
</style>
|
||||
|
||||
<mask id="plus-mask">
|
||||
<rect width="100%" height="100%" fill="white"/>
|
||||
<rect x="4" y="7.5" width="8" height="1"/>
|
||||
<rect x="7.5" y="4" width="1" height="8"/>
|
||||
</mask>
|
||||
|
||||
<g id="addpage-shape">
|
||||
<circle cx="8" cy="8" r="7" mask="url(#plus-mask)"/>
|
||||
</g>
|
||||
|
||||
</defs>
|
||||
|
||||
<use id="addpage" xlink:href="#addpage-shape"/>
|
||||
<use id="addpage-hover" xlink:href="#addpage-shape"/>
|
||||
<use id="addpage-active" xlink:href="#addpage-shape"/>
|
||||
|
||||
<use id="alreadyadded" xlink:href="#addpage-shape"/>
|
||||
<use id="alreadyadded-hover" xlink:href="#addpage-shape"/>
|
||||
<use id="alreadyadded-active" xlink:href="#addpage-shape"/>
|
||||
|
||||
</svg>
|
Before Width: | Height: | Size: 1.5 KiB |
@ -1576,8 +1576,6 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-
|
||||
-moz-image-region: rect(0, 48px, 16px, 32px);
|
||||
}
|
||||
|
||||
%include ../shared/readinglist.inc.css
|
||||
|
||||
/* Reader mode button */
|
||||
|
||||
#reader-mode-button {
|
||||
|
@ -110,7 +110,6 @@ browser.jar:
|
||||
skin/classic/browser/tab-crashed.svg (../shared/incontent-icons/tab-crashed.svg)
|
||||
skin/classic/browser/welcome-back.svg (../shared/incontent-icons/welcome-back.svg)
|
||||
skin/classic/browser/reader-mode-16.png (../shared/reader/reader-mode-16.png)
|
||||
skin/classic/browser/readinglist/icons.svg (../shared/readinglist/icons.svg)
|
||||
skin/classic/browser/readinglist/readinglist-icon.svg (../shared/readinglist/readinglist-icon.svg)
|
||||
skin/classic/browser/readinglist/sidebar.css (../shared/readinglist/sidebar.css)
|
||||
skin/classic/browser/notification-pluginNormal.png (../shared/plugins/notification-pluginNormal.png)
|
||||
@ -578,7 +577,6 @@ browser.jar:
|
||||
skin/classic/aero/browser/tab-crashed.svg (../shared/incontent-icons/tab-crashed.svg)
|
||||
skin/classic/aero/browser/welcome-back.svg (../shared/incontent-icons/welcome-back.svg)
|
||||
skin/classic/aero/browser/reader-mode-16.png (../shared/reader/reader-mode-16.png)
|
||||
skin/classic/aero/browser/readinglist/icons.svg (../shared/readinglist/icons.svg)
|
||||
skin/classic/aero/browser/readinglist/readinglist-icon.svg (../shared/readinglist/readinglist-icon.svg)
|
||||
skin/classic/aero/browser/readinglist/sidebar.css (../shared/readinglist/sidebar.css)
|
||||
skin/classic/aero/browser/notification-pluginNormal.png (../shared/plugins/notification-pluginNormal.png)
|
||||
|
Loading…
Reference in New Issue
Block a user