Bug 651522 permaorange: Cleanup and add some temporary logging r=mfinkle

This commit is contained in:
Benjamin Stover 2011-05-10 11:57:46 -07:00
parent 58125e7d17
commit 008c84f691
3 changed files with 30 additions and 29 deletions

View File

@ -1,6 +1,14 @@
var BookmarkHelper = {
_editor: null,
logging: false,
log: function(msg) {
if (this.logging) {
Services.console.logStringMessage(msg);
}
},
get box() {
delete this.box;
this.box = document.getElementById("bookmark-container");
@ -53,6 +61,7 @@ var BookmarkHelper = {
},
close: function BH_close() {
this.log("Bookmark helper: closing");
BrowserUI.updateStar();
// Note: the _editor will have already saved the data, if needed, by the time

View File

@ -763,22 +763,30 @@
<method name="save">
<body>
<![CDATA[
BookmarkHelper.log("bindings.xml: saving");
// Update the tags
if (this.uri && this.type != "folder") {
let currentTags = PlacesUtils.tagging.getTagsForURI(this.uri, {});
let tags = this.tagsAsArray;
BookmarkHelper.log("bindings.xml: current tags length is " + currentTags.length);
if (tags.length > 0 || currentTags.length > 0) {
let tagsToRemove = [];
let tagsToAdd = [];
for (let i = 0; i < currentTags.length; i++) {
if (tags.indexOf(currentTags[i]) == -1)
if (tags.indexOf(currentTags[i]) == -1) {
BookmarkHelper.log("bindings.xml: removing tag " + currentTags[i]);
tagsToRemove.push(currentTags[i]);
}
}
for (let i = 0; i < tags.length; i++) {
if (currentTags.indexOf(tags[i]) == -1)
if (currentTags.indexOf(tags[i]) == -1) {
BookmarkHelper.log("bindings.xml: adding tag " + tags[i]);
tagsToAdd.push(tags[i]);
}
}
BookmarkHelper.log("bindings.xml: tagsToAdd length " + tagsToAdd.length);
BookmarkHelper.log("bindings.xml: tagsToRemove length " + tagsToRemove.length);
if (tagsToAdd.length > 0)
PlacesUtils.tagging.tagURI(this.uri, tagsToAdd);
if (tagsToRemove.length > 0)
@ -791,6 +799,8 @@
let spec = this.spec;
if (spec && this.uri.spec != spec) {
try {
BookmarkHelper.log("bindings.xml: changing uri");
let oldURI = this._uri;
this._uri = Services.io.newURI(spec, null, null);
PlacesUtils.bookmarks.changeBookmarkURI(this.itemId, this.uri);
@ -806,7 +816,9 @@
PlacesUtils.tagging.tagURI(this._uri, tags);
}
}
catch (e) { }
catch (e) {
BookmarkHelper.log("bindings.xml: Error while tagging and moving bookmark: " + e);
}
}
if (spec != this.uri.spec)
this.spec = this.uri.spec;

View File

@ -7,13 +7,9 @@
let testURL_01 = chromeRoot + "browser_blank_01.html";
let testURL_02 = chromeRoot + "browser_blank_02.html";
// A queue to order the tests and a handle for each test
let gTests = [];
let gCurrentTest = null;
//------------------------------------------------------------------------------
// Entry point (must be named "test")
function test() {
BookmarkHelper.logging = true;
// The "runNextTest" approach is async, so we need to call "waitForExplicitFinish()"
// We call "finish()" when the tests are finished
waitForExplicitFinish();
@ -22,26 +18,10 @@ function test() {
runNextTest();
}
//------------------------------------------------------------------------------
// Iterating tests by shifting test out one by one as runNextTest is called.
function runNextTest() {
// Run the next test until all tests completed
if (gTests.length > 0) {
gCurrentTest = gTests.shift();
info(gCurrentTest.desc);
gCurrentTest.run();
}
else {
// Cleanup. All tests are completed at this point
try {
PlacesUtils.bookmarks.removeFolderChildren(BookmarkList.panel.mobileRoot);
}
finally {
// We must finialize the tests
finish();
}
}
}
registerCleanupFunction(function() {
BookmarkHelper.logging = false;
PlacesUtils.bookmarks.removeFolderChildren(BookmarkList.panel.mobileRoot);
});
//------------------------------------------------------------------------------
// Case: Test appearance and behavior of the bookmark popup