From 008c84f69140effe039dafb372befb081828c4dd Mon Sep 17 00:00:00 2001 From: Benjamin Stover Date: Tue, 10 May 2011 11:57:46 -0700 Subject: [PATCH] Bug 651522 permaorange: Cleanup and add some temporary logging r=mfinkle --- mobile/chrome/content/BookmarkHelper.js | 9 ++++++ mobile/chrome/content/bindings.xml | 18 +++++++++-- mobile/chrome/tests/browser_bookmarks_star.js | 32 ++++--------------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/mobile/chrome/content/BookmarkHelper.js b/mobile/chrome/content/BookmarkHelper.js index ec9209ccc8e..06c8a65c8c0 100644 --- a/mobile/chrome/content/BookmarkHelper.js +++ b/mobile/chrome/content/BookmarkHelper.js @@ -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 diff --git a/mobile/chrome/content/bindings.xml b/mobile/chrome/content/bindings.xml index 451df8e3a07..bdb64784cfd 100644 --- a/mobile/chrome/content/bindings.xml +++ b/mobile/chrome/content/bindings.xml @@ -763,22 +763,30 @@ 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; diff --git a/mobile/chrome/tests/browser_bookmarks_star.js b/mobile/chrome/tests/browser_bookmarks_star.js index 441e0b86128..3dfac0eb5ae 100644 --- a/mobile/chrome/tests/browser_bookmarks_star.js +++ b/mobile/chrome/tests/browser_bookmarks_star.js @@ -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