summaryrefslogtreecommitdiffstats
path: root/comm/mail/test/browser/shared-modules/ViewHelpers.jsm
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /comm/mail/test/browser/shared-modules/ViewHelpers.jsm
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--comm/mail/test/browser/shared-modules/ViewHelpers.jsm85
1 files changed, 85 insertions, 0 deletions
diff --git a/comm/mail/test/browser/shared-modules/ViewHelpers.jsm b/comm/mail/test/browser/shared-modules/ViewHelpers.jsm
new file mode 100644
index 0000000000..33d39a8e07
--- /dev/null
+++ b/comm/mail/test/browser/shared-modules/ViewHelpers.jsm
@@ -0,0 +1,85 @@
+/* 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/. */
+
+/** Module to help debugging view wrapper issues. */
+
+const EXPORTED_SYMBOLS = ["dump_view_contents", "dump_view_state"];
+
+function dump_view_state(aViewWrapper, aDoNotDumpContents) {
+ if (aViewWrapper.dbView == null) {
+ dump("no nsIMsgDBView instance!\n");
+ return;
+ }
+ if (!aDoNotDumpContents) {
+ dump_view_contents(aViewWrapper);
+ }
+ dump("View: " + aViewWrapper.dbView + "\n");
+ dump(
+ " View Type: " +
+ _lookupValueNameInInterface(
+ aViewWrapper.dbView.viewType,
+ Ci.nsMsgViewType
+ ) +
+ " " +
+ "View Flags: " +
+ aViewWrapper.dbView.viewFlags +
+ "\n"
+ );
+ dump(
+ " Sort Type: " +
+ _lookupValueNameInInterface(
+ aViewWrapper.dbView.sortType,
+ Ci.nsMsgViewSortType
+ ) +
+ " " +
+ "Sort Order: " +
+ _lookupValueNameInInterface(
+ aViewWrapper.dbView.sortOrder,
+ Ci.nsMsgViewSortOrder
+ ) +
+ "\n"
+ );
+ dump(aViewWrapper.search.prettyString());
+}
+
+var WHITESPACE = " ";
+var MSG_VIEW_FLAG_DUMMY = 0x20000000;
+function dump_view_contents(aViewWrapper) {
+ let dbView = aViewWrapper.dbView;
+ let treeView = aViewWrapper.dbView.QueryInterface(Ci.nsITreeView);
+ let rowCount = treeView.rowCount;
+
+ dump("********* Current View Contents\n");
+ for (let iViewIndex = 0; iViewIndex < rowCount; iViewIndex++) {
+ let level = treeView.getLevel(iViewIndex);
+ let flags = dbView.getFlagsAt(iViewIndex);
+ let msgHdr = dbView.getMsgHdrAt(iViewIndex);
+
+ let s = WHITESPACE.substr(0, level * 2);
+ if (treeView.isContainer(iViewIndex)) {
+ s += treeView.isContainerOpen(iViewIndex) ? "- " : "+ ";
+ } else {
+ s += ". ";
+ }
+ // s += treeView.getCellText(iViewIndex, )
+ if (flags & MSG_VIEW_FLAG_DUMMY) {
+ s += "dummy: ";
+ }
+ s += dbView.cellTextForColumn(iViewIndex, "subject");
+ s += " [" + msgHdr.folder.prettyName + "," + msgHdr.messageKey + "]";
+
+ dump(s + "\n");
+ }
+ dump("********* end view contents\n");
+}
+
+function _lookupValueNameInInterface(aValue, aInterface) {
+ for (let key in aInterface) {
+ let value = aInterface[key];
+ if (value == aValue) {
+ return key;
+ }
+ }
+ return "unknown: " + aValue;
+}