summaryrefslogtreecommitdiffstats
path: root/toolkit/components/aboutwindowsmessages/content
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /toolkit/components/aboutwindowsmessages/content
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/aboutwindowsmessages/content')
-rw-r--r--toolkit/components/aboutwindowsmessages/content/aboutWindowsMessages.css15
-rw-r--r--toolkit/components/aboutwindowsmessages/content/aboutWindowsMessages.html42
-rw-r--r--toolkit/components/aboutwindowsmessages/content/aboutWindowsMessages.js70
3 files changed, 127 insertions, 0 deletions
diff --git a/toolkit/components/aboutwindowsmessages/content/aboutWindowsMessages.css b/toolkit/components/aboutwindowsmessages/content/aboutWindowsMessages.css
new file mode 100644
index 0000000000..de29761cc6
--- /dev/null
+++ b/toolkit/components/aboutwindowsmessages/content/aboutWindowsMessages.css
@@ -0,0 +1,15 @@
+/* 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/. */
+
+.card {
+ margin-bottom: 16px;
+}
+
+.window-card-title {
+ display: inline;
+}
+
+.window-card-title:not(.current-window) {
+ font-weight: normal;
+}
diff --git a/toolkit/components/aboutwindowsmessages/content/aboutWindowsMessages.html b/toolkit/components/aboutwindowsmessages/content/aboutWindowsMessages.html
new file mode 100644
index 0000000000..5c3145baf2
--- /dev/null
+++ b/toolkit/components/aboutwindowsmessages/content/aboutWindowsMessages.html
@@ -0,0 +1,42 @@
+<!-- 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/. -->
+
+<!DOCTYPE html>
+
+<html>
+ <head>
+ <title data-l10n-id="windows-messages-page-title"></title>
+ <meta
+ http-equiv="Content-Security-Policy"
+ content="default-src chrome:; object-src 'none'"
+ />
+ <meta name="color-scheme" content="light dark" />
+ <link
+ rel="stylesheet"
+ href="chrome://global/skin/in-content/info-pages.css"
+ />
+ <link
+ rel="stylesheet"
+ href="chrome://global/content/aboutWindowsMessages.css"
+ />
+ <link rel="localization" href="branding/brand.ftl" />
+ <link rel="localization" href="toolkit/about/aboutWindowsMessages.ftl" />
+ <script src="chrome://global/content/aboutWindowsMessages.js"></script>
+ </head>
+
+ <body class="wide-container">
+ <h1 data-l10n-id="windows-messages-page-title"></h1>
+ <p data-l10n-id="windows-messages-intro"></p>
+ <div id="windows-div"></div>
+
+ <template name="window-card">
+ <details class="card">
+ <summary>
+ <h3 class="window-card-title"></h3>
+ <button data-l10n-id="windows-messages-copy-to-clipboard"></button>
+ </summary>
+ </details>
+ </template>
+ </body>
+</html>
diff --git a/toolkit/components/aboutwindowsmessages/content/aboutWindowsMessages.js b/toolkit/components/aboutwindowsmessages/content/aboutWindowsMessages.js
new file mode 100644
index 0000000000..0896ae7669
--- /dev/null
+++ b/toolkit/components/aboutwindowsmessages/content/aboutWindowsMessages.js
@@ -0,0 +1,70 @@
+/* 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/. */
+
+"use strict";
+
+let AboutWindowsMessages = null;
+
+function refreshMessages() {
+ let windowMessages = {};
+ let windowTitles = {};
+ AboutWindowsMessages.getMessages(window, windowMessages, windowTitles);
+ let windowsDiv = document.getElementById("windows-div");
+ windowsDiv.innerHTML = "";
+ const templateCard = document.querySelector("template[name=window-card]");
+ for (let i = 0; i < windowTitles.value.length; ++i) {
+ let windowCard = templateCard.content
+ .cloneNode(true)
+ .querySelector("details");
+ // open the current window by default
+ windowCard.open = i === 0;
+ let summary = windowCard.querySelector("summary");
+ let titleSpan = summary.querySelector("h3.window-card-title");
+ titleSpan.appendChild(document.createTextNode(windowTitles.value[i]));
+ titleSpan.classList.toggle("current-window", windowCard.open);
+ let copyButton = summary.querySelector("button");
+ copyButton.addEventListener("click", async e => {
+ e.target.disabled = true;
+ await copyMessagesToClipboard(e);
+ e.target.disabled = false;
+ });
+ let innerUl = document.createElement("ul");
+ for (let j = 0; j < windowMessages.value[i].length; ++j) {
+ let innerLi = document.createElement("li");
+ innerLi.className = "message";
+ innerLi.innerText = windowMessages.value[i][j];
+ innerUl.appendChild(innerLi);
+ }
+ windowCard.appendChild(innerUl);
+ windowsDiv.append(windowCard);
+ }
+}
+
+async function copyMessagesToClipboard(event) {
+ const details = event.target.parentElement.parentElement;
+ // Avoid copying the window name as it is Category 3 data,
+ // and only useful for the user to identify which window
+ // is which.
+ const messagesText =
+ Array.from(details.querySelector("ul").children)
+ .map(li => li.innerText)
+ .join("\n") + "\n";
+
+ await navigator.clipboard.writeText(messagesText);
+}
+
+function onLoad() {
+ refreshMessages();
+}
+
+try {
+ AboutWindowsMessages = Cc["@mozilla.org/about-windowsmessages;1"].getService(
+ Ci.nsIAboutWindowsMessages
+ );
+ document.addEventListener("DOMContentLoaded", onLoad, { once: true });
+} catch (ex) {
+ // Do nothing if we fail to create a singleton instance,
+ // showing the default no-module message.
+ console.error(ex);
+}