Bug 1454023 - Port |Bug 1431050 - "remove NS_ASSERT / debug.js"| to SeaMonkey trunk. r=frg
This commit is contained in:
Родитель
3a85b83d06
Коммит
ac150434f5
|
@ -5,7 +5,6 @@
|
|||
|
||||
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/debug.js");
|
||||
|
||||
const TYPE_MAYBE_FEED = "application/vnd.mozilla.maybe.feed";
|
||||
const TYPE_MAYBE_VIDEO_FEED = "application/vnd.mozilla.maybe.video.feed";
|
||||
|
@ -416,8 +415,10 @@ FeedResultService.prototype = {
|
|||
* See nsIFeedResultService.idl
|
||||
*/
|
||||
addFeedResult: function addFeedResult(feedResult) {
|
||||
NS_ASSERT(feedResult != null, "null feedResult!");
|
||||
NS_ASSERT(feedResult.uri != null, "null URI!");
|
||||
if (feedResult == null)
|
||||
throw new Error("null feedResult!");
|
||||
if (feedResult.uri == null)
|
||||
throw new Error("null URI!");
|
||||
var spec = feedResult.uri.spec;
|
||||
if (!this._results[spec])
|
||||
this._results[spec] = [];
|
||||
|
@ -428,7 +429,8 @@ FeedResultService.prototype = {
|
|||
* See nsIFeedResultService.idl
|
||||
*/
|
||||
getFeedResult: function getFeedResult(uri) {
|
||||
NS_ASSERT(uri != null, "null URI!");
|
||||
if (uri == null)
|
||||
throw new Error("null URI!");
|
||||
var resultList = this._results[uri.spec];
|
||||
for (let i = 0; i < resultList.length; ++i) {
|
||||
if (resultList[i].uri == uri)
|
||||
|
@ -441,7 +443,8 @@ FeedResultService.prototype = {
|
|||
* See nsIFeedResultService.idl
|
||||
*/
|
||||
removeFeedResult: function removeFeedResult(uri) {
|
||||
NS_ASSERT(uri != null, "null URI!");
|
||||
if (uri == null)
|
||||
throw new Error("null URI!");
|
||||
var resultList = this._results[uri.spec];
|
||||
if (!resultList)
|
||||
return;
|
||||
|
|
|
@ -132,7 +132,8 @@ var BookmarkPropertiesPanel = {
|
|||
return this._strings.getString("dialogTitleAddLivemark");
|
||||
|
||||
// add folder
|
||||
NS_ASSERT(this._itemType == BOOKMARK_FOLDER, "Unknown item type");
|
||||
if (this._itemType != BOOKMARK_FOLDER)
|
||||
throw new Error("Unknown item type");
|
||||
if (this._URIs.length)
|
||||
return this._strings.getString("dialogTitleAddMulti");
|
||||
|
||||
|
@ -152,7 +153,8 @@ var BookmarkPropertiesPanel = {
|
|||
this._action = dialogInfo.action == "add" ? ACTION_ADD : ACTION_EDIT;
|
||||
this._hiddenRows = dialogInfo.hiddenRows ? dialogInfo.hiddenRows : [];
|
||||
if (this._action == ACTION_ADD) {
|
||||
NS_ASSERT("type" in dialogInfo, "missing type property for add action");
|
||||
if (!("type" in dialogInfo))
|
||||
throw new Error("missing type property for add action");
|
||||
|
||||
if ("title" in dialogInfo)
|
||||
this._title = dialogInfo.title;
|
||||
|
@ -171,8 +173,8 @@ var BookmarkPropertiesPanel = {
|
|||
case "bookmark":
|
||||
this._itemType = BOOKMARK_ITEM;
|
||||
if ("uri" in dialogInfo) {
|
||||
NS_ASSERT(dialogInfo.uri instanceof Ci.nsIURI,
|
||||
"uri property should be a uri object");
|
||||
if (!(dialogInfo.uri instanceof Ci.nsIURI))
|
||||
throw new Error("uri property should be a uri object");
|
||||
this._uri = dialogInfo.uri;
|
||||
if (typeof(this._title) != "string") {
|
||||
this._title = await PlacesUtils.history.fetch(this._uri) ||
|
||||
|
|
|
@ -650,15 +650,6 @@ PlacesController.prototype = {
|
|||
}, window.top);
|
||||
},
|
||||
|
||||
/**
|
||||
* This method can be run on a URI parameter to ensure that it didn't
|
||||
* receive a string instead of an nsIURI object.
|
||||
*/
|
||||
_assertURINotString: function PC__assertURINotString(value) {
|
||||
NS_ASSERT((typeof(value) == "object") && !(value instanceof String),
|
||||
"This method should be passed a URI as a nsIURI object, not as a string.");
|
||||
},
|
||||
|
||||
/**
|
||||
* Reloads the selected livemark if any.
|
||||
*/
|
||||
|
@ -791,7 +782,8 @@ PlacesController.prototype = {
|
|||
* @return {Integer} The total number of items affected.
|
||||
*/
|
||||
async _removeRange(range, transactions, removedFolders) {
|
||||
NS_ASSERT(transactions instanceof Array, "Must pass a transactions array");
|
||||
if (!(transactions instanceof Array))
|
||||
throw new Error("Must pass a transactions array");
|
||||
if (!removedFolders)
|
||||
removedFolders = [];
|
||||
|
||||
|
@ -859,12 +851,7 @@ PlacesController.prototype = {
|
|||
return totalItems;
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the set of selected ranges from bookmarks.
|
||||
* @param txnName
|
||||
* See |remove|.
|
||||
*/
|
||||
async _removeRowsFromBookmarks(txnName) {
|
||||
async _removeRowsFromBookmarks() {
|
||||
let ranges = this._view.removableSelectionRanges;
|
||||
let transactions = [];
|
||||
let removedFolders = [];
|
||||
|
@ -919,8 +906,8 @@ PlacesController.prototype = {
|
|||
let query = aContainerNode.getQueries()[0];
|
||||
let beginTime = query.beginTime;
|
||||
let endTime = query.endTime;
|
||||
NS_ASSERT(query && beginTime && endTime,
|
||||
"A valid date container query should exist!");
|
||||
if (!query || !beginTime || !endTime)
|
||||
throw new Error("A valid date container query should exist!");
|
||||
// We want to exclude beginTime from the removal because
|
||||
// removePagesByTimeframe includes both extremes, while date containers
|
||||
// exclude the lower extreme. So, if we would not exclude it, we would
|
||||
|
@ -931,31 +918,26 @@ PlacesController.prototype = {
|
|||
|
||||
/**
|
||||
* Removes the selection
|
||||
* @param aTxnName
|
||||
* A name for the transaction if this is being performed
|
||||
* as part of another operation.
|
||||
*/
|
||||
async remove(aTxnName) {
|
||||
async remove() {
|
||||
if (!this._hasRemovableSelection())
|
||||
return;
|
||||
|
||||
NS_ASSERT(aTxnName !== undefined, "Must supply Transaction Name");
|
||||
|
||||
var root = this._view.result.root;
|
||||
|
||||
if (PlacesUtils.nodeIsFolder(root)) {
|
||||
await this._removeRowsFromBookmarks(aTxnName);
|
||||
await this._removeRowsFromBookmarks();
|
||||
} else if (PlacesUtils.nodeIsQuery(root)) {
|
||||
var queryType = PlacesUtils.asQuery(root).queryOptions.queryType;
|
||||
if (queryType == Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS) {
|
||||
await this._removeRowsFromBookmarks(aTxnName);
|
||||
await this._removeRowsFromBookmarks();
|
||||
} else if (queryType == Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY) {
|
||||
this._removeRowsFromHistory();
|
||||
} else {
|
||||
NS_ASSERT(false, "implement support for QUERY_TYPE_UNIFIED");
|
||||
throw new Error("implement support for QUERY_TYPE_UNIFIED");
|
||||
}
|
||||
} else
|
||||
NS_ASSERT(false, "unexpected root");
|
||||
throw new Error("unexpected root");
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1251,7 +1233,8 @@ PlacesController.prototype = {
|
|||
* The container were we are want to drop
|
||||
*/
|
||||
disallowInsertion(container) {
|
||||
NS_ASSERT(container, "empty container");
|
||||
if (!container)
|
||||
throw new Error("empty container");
|
||||
// Allow dropping into Tag containers and editable folders.
|
||||
return !PlacesUtils.nodeIsTagQuery(container) &&
|
||||
(!PlacesUtils.nodeIsFolder(container) ||
|
||||
|
|
|
@ -967,21 +967,21 @@ var ViewMenu = {
|
|||
* null if the caller should just append to the popup.
|
||||
*/
|
||||
_clean: function VM__clean(popup, startID, endID) {
|
||||
if (endID)
|
||||
NS_ASSERT(startID, "meaningless to have valid endID and null startID");
|
||||
if (endID && !startID)
|
||||
throw new Error("meaningless to have valid endID and null startID");
|
||||
if (startID) {
|
||||
var startElement = document.getElementById(startID);
|
||||
NS_ASSERT(startElement.parentNode ==
|
||||
popup, "startElement is not in popup");
|
||||
NS_ASSERT(startElement,
|
||||
"startID does not correspond to an existing element");
|
||||
if (!startElement)
|
||||
throw new Error("startID does not correspond to an existing element");
|
||||
if (startElement.parentNode != popup)
|
||||
throw new Error("startElement is not in popup");
|
||||
var endElement = null;
|
||||
if (endID) {
|
||||
endElement = document.getElementById(endID);
|
||||
NS_ASSERT(endElement.parentNode == popup,
|
||||
"endElement is not in popup");
|
||||
NS_ASSERT(endElement,
|
||||
"endID does not correspond to an existing element");
|
||||
if (!endElement)
|
||||
throw new Error("endID does not correspond to an existing element");
|
||||
if (endElement.parentNode != popup)
|
||||
throw new Error("endElement is not in popup");
|
||||
}
|
||||
while (startElement.nextSibling != endElement)
|
||||
popup.removeChild(startElement.nextSibling);
|
||||
|
|
|
@ -203,7 +203,7 @@
|
|||
}
|
||||
|
||||
var container = this.result.root;
|
||||
NS_ASSERT(container, "No result, cannot select place URI!");
|
||||
console.assert(container, "No result, cannot select place URI!");
|
||||
if (!container)
|
||||
return;
|
||||
|
||||
|
@ -473,7 +473,7 @@
|
|||
var resultview = this.view;
|
||||
var container = result.root;
|
||||
var dropNearNode = null;
|
||||
NS_ASSERT(container, "null container");
|
||||
console.assert(container, "null container");
|
||||
// When there's no selection, assume the container is the container
|
||||
// the view is populated from (i.e. the result's itemId).
|
||||
if (index != -1) {
|
||||
|
|
|
@ -651,7 +651,7 @@ PlacesTreeView.prototype = {
|
|||
|
||||
// nsINavHistoryResultObserver
|
||||
nodeInserted: function PTV_nodeInserted(aParentNode, aNode, aNewIndex) {
|
||||
NS_ASSERT(this._result, "Got a notification but have no result!");
|
||||
console.assert(this._result, "Got a notification but have no result!");
|
||||
if (!this._tree || !this._result)
|
||||
return;
|
||||
|
||||
|
@ -725,7 +725,7 @@ PlacesTreeView.prototype = {
|
|||
* change for visits, and date sorting is the only time things are collapsed.
|
||||
*/
|
||||
nodeRemoved: function PTV_nodeRemoved(aParentNode, aNode, aOldIndex) {
|
||||
NS_ASSERT(this._result, "Got a notification but have no result!");
|
||||
console.assert(this._result, "Got a notification but have no result!");
|
||||
if (!this._tree || !this._result)
|
||||
return;
|
||||
|
||||
|
@ -780,7 +780,7 @@ PlacesTreeView.prototype = {
|
|||
|
||||
nodeMoved:
|
||||
function PTV_nodeMoved(aNode, aOldParent, aOldIndex, aNewParent, aNewIndex) {
|
||||
NS_ASSERT(this._result, "Got a notification but have no result!");
|
||||
console.assert(this._result, "Got a notification but have no result!");
|
||||
if (!this._tree || !this._result)
|
||||
return;
|
||||
|
||||
|
@ -829,7 +829,7 @@ PlacesTreeView.prototype = {
|
|||
|
||||
_invalidateCellValue: function PTV__invalidateCellValue(aNode,
|
||||
aColumnType) {
|
||||
NS_ASSERT(this._result, "Got a notification but have no result!");
|
||||
console.assert(this._result, "Got a notification but have no result!");
|
||||
if (!this._tree || !this._result)
|
||||
return;
|
||||
|
||||
|
@ -976,7 +976,7 @@ PlacesTreeView.prototype = {
|
|||
},
|
||||
|
||||
invalidateContainer: function PTV_invalidateContainer(aContainer) {
|
||||
NS_ASSERT(this._result, "Need to have a result to update");
|
||||
console.assert(this._result, "Need to have a result to update");
|
||||
if (!this._tree)
|
||||
return;
|
||||
|
||||
|
|
|
@ -80,8 +80,6 @@ const TAB_EVENTS = ["TabOpen", "TabClose", "TabSelect", "TabShow", "TabHide"];
|
|||
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
||||
// debug.js adds NS_ASSERT. cf. bug 669196
|
||||
const {debug} = ChromeUtils.import("resource://gre/modules/debug.js");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "SecMan",
|
||||
"@mozilla.org/scriptsecuritymanager;1", "nsIScriptSecurityManager");
|
||||
|
@ -1476,8 +1474,8 @@ SessionStoreService.prototype = {
|
|||
// First Focus the window & tab we're having trouble with.
|
||||
aTab.ownerDocument.defaultView.focus();
|
||||
aTab.ownerDocument.defaultView.getBrowser().selectedTab = aTab;
|
||||
NS_ASSERT(false, "SessionStore failed gathering complete history " +
|
||||
"for the focused window/tab. See bug 669196.");
|
||||
debug("SessionStore failed gathering complete history " +
|
||||
"for the focused window/tab. See bug 669196.");
|
||||
aTab.__SS_broken_history = true;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче