From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../test/browser/files/tree-element-test-common.js | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 comm/mail/base/test/browser/files/tree-element-test-common.js (limited to 'comm/mail/base/test/browser/files/tree-element-test-common.js') 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); +}); -- cgit v1.2.3