summaryrefslogtreecommitdiffstats
path: root/devtools/client/netmonitor/test/browser_net_charts-04.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /devtools/client/netmonitor/test/browser_net_charts-04.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/netmonitor/test/browser_net_charts-04.js')
-rw-r--r--devtools/client/netmonitor/test/browser_net_charts-04.js117
1 files changed, 117 insertions, 0 deletions
diff --git a/devtools/client/netmonitor/test/browser_net_charts-04.js b/devtools/client/netmonitor/test/browser_net_charts-04.js
new file mode 100644
index 0000000000..686608fb81
--- /dev/null
+++ b/devtools/client/netmonitor/test/browser_net_charts-04.js
@@ -0,0 +1,117 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/**
+ * Makes sure Pie Charts have the right internal structure when
+ * initialized with empty data.
+ */
+
+add_task(async function () {
+ const {
+ L10N,
+ } = require("resource://devtools/client/netmonitor/src/utils/l10n.js");
+
+ const { monitor } = await initNetMonitor(HTTPS_SIMPLE_URL, {
+ requestCount: 1,
+ });
+ info("Starting test... ");
+
+ const { document, windowRequire } = monitor.panelWin;
+ const { Chart } = windowRequire("devtools/client/shared/widgets/Chart");
+
+ const wait = waitForNetworkEvents(monitor, 1);
+ await navigateTo(HTTPS_SIMPLE_URL);
+ await wait;
+
+ const table = Chart.Table(document, {
+ title: "Table title",
+ data: null,
+ totals: {
+ label1: value => "Hello " + L10N.numberWithDecimals(value, 2),
+ label2: value => "World " + L10N.numberWithDecimals(value, 2),
+ },
+ header: {
+ label1: "",
+ label2: "",
+ },
+ });
+
+ const { node } = table;
+ const title = node.querySelector(".table-chart-title");
+ const grid = node.querySelector(".table-chart-grid");
+ const totals = node.querySelector(".table-chart-totals");
+ const rows = grid.querySelectorAll(".table-chart-row");
+ const sums = node.querySelectorAll(".table-chart-summary-label");
+
+ ok(
+ node.classList.contains("table-chart-container") &&
+ node.classList.contains("generic-chart-container"),
+ "A table chart container was created successfully."
+ );
+
+ ok(title, "A title node was created successfully.");
+ is(
+ title.textContent,
+ "Table title",
+ "The title node displays the correct text."
+ );
+
+ is(
+ rows.length,
+ 2,
+ "There should be 1 table chart row and a 1 header created."
+ );
+
+ is(
+ rows[1].querySelectorAll(".table-chart-row-label")[0].getAttribute("name"),
+ "size",
+ "The first column of the first row exists."
+ );
+ is(
+ rows[1].querySelectorAll(".table-chart-row-label")[1].getAttribute("name"),
+ "label",
+ "The second column of the first row exists."
+ );
+ is(
+ rows[1].querySelectorAll(".table-chart-row-label")[0].textContent,
+ "",
+ "The first column of the first row displays the correct text."
+ );
+ is(
+ rows[1].querySelectorAll(".table-chart-row-label")[1].textContent,
+ L10N.getStr("tableChart.loading"),
+ "The second column of the first row displays the correct text."
+ );
+
+ is(sums.length, 2, "There should be 2 total summaries created.");
+
+ is(
+ totals
+ .querySelectorAll(".table-chart-summary-label")[0]
+ .getAttribute("name"),
+ "label1",
+ "The first sum's type is correct."
+ );
+ is(
+ totals.querySelectorAll(".table-chart-summary-label")[0].textContent,
+ "Hello 0",
+ "The first sum's value is correct."
+ );
+
+ is(
+ totals
+ .querySelectorAll(".table-chart-summary-label")[1]
+ .getAttribute("name"),
+ "label2",
+ "The second sum's type is correct."
+ );
+ is(
+ totals.querySelectorAll(".table-chart-summary-label")[1].textContent,
+ "World 0",
+ "The second sum's value is correct."
+ );
+
+ await teardown(monitor);
+});