summaryrefslogtreecommitdiffstats
path: root/comm/mail/base/test/browser/files/tree-element-test-common.js
diff options
context:
space:
mode:
Diffstat (limited to 'comm/mail/base/test/browser/files/tree-element-test-common.js')
-rw-r--r--comm/mail/base/test/browser/files/tree-element-test-common.js73
1 files changed, 73 insertions, 0 deletions
diff --git a/comm/mail/base/test/browser/files/tree-element-test-common.js b/comm/mail/base/test/browser/files/tree-element-test-common.js
new file mode 100644
index 0000000000..6f22962aca
--- /dev/null
+++ b/comm/mail/base/test/browser/files/tree-element-test-common.js
@@ -0,0 +1,73 @@
+/* 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/. */
+
+// FIXME: Wrap the whole method around the document load listener to prevent the
+// undefined state of the "tree-view-table-row" element. This is due to the .mjs
+// nature of the class file.
+window.addEventListener("load", () => {
+ class AlternativeCardRow extends customElements.get("tree-view-table-row") {
+ static ROW_HEIGHT = 80;
+
+ connectedCallback() {
+ if (this.hasConnected) {
+ return;
+ }
+
+ super.connectedCallback();
+
+ this.cell = this.appendChild(document.createElement("td"));
+ }
+
+ get index() {
+ return super.index;
+ }
+
+ set index(index) {
+ super.index = index;
+ this.cell.textContent = this.view.getCellText(index, {
+ id: "GeneratedName",
+ });
+ }
+ }
+ customElements.define("alternative-row", AlternativeCardRow, {
+ extends: "tr",
+ });
+
+ class TestView {
+ values = [];
+
+ constructor(start, count) {
+ for (let i = start; i < start + count; i++) {
+ this.values.push(i);
+ }
+ }
+
+ get rowCount() {
+ return this.values.length;
+ }
+
+ getCellText(index, column) {
+ return `${column.id} ${this.values[index]}`;
+ }
+
+ isContainer() {
+ return false;
+ }
+
+ isContainerOpen() {
+ return false;
+ }
+
+ selectionChanged() {}
+
+ setTree() {}
+ }
+
+ const tree = document.getElementById("testTree");
+ tree.table.setBodyID("testBody");
+ tree.addEventListener("select", () => {
+ console.log("select event, selected indices:", tree.selectedIndices);
+ });
+ tree.view = new TestView(0, 150);
+});