Bug 1647532 - Fix Provided/Not Provided text in about:webrtc renderConfiguration(). r=ng
authorJan-Ivar Bruaroey <jib@mozilla.com>
Wed, 01 Jul 2020 00:03:20 +0000
changeset 538128 74aed250da9ec95e466416556bbd42022c0bb43b
parent 538127 76b4a3462fc94af88711a5c9c7f35bc8459f9e3d
child 538129 df91fb44b2d4bd8cf55cb2a5360094feb2c6ca6b
push id37558
push userdluca@mozilla.com
push dateWed, 01 Jul 2020 09:30:12 +0000
treeherdermozilla-central@e950bdd669d4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersng
bugs1647532
milestone80.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1647532 - Fix Provided/Not Provided text in about:webrtc renderConfiguration(). r=ng Depends on D81412 Differential Revision: https://phabricator.services.mozilla.com/D81789
toolkit/content/aboutwebrtc/aboutWebrtc.js
--- a/toolkit/content/aboutwebrtc/aboutWebrtc.js
+++ b/toolkit/content/aboutwebrtc/aboutWebrtc.js
@@ -514,64 +514,55 @@ function renderRawIceTable(caption, cand
     [string(caption)],
     [...new Set(candidates.sort())].filter(i => i).map(i => [i])
   );
   table.className = "raw-candidate";
   return table;
 }
 
 function renderConfiguration(c) {
-  const provided = () => {
-    const italics = document.createElement("i");
-    italics.textContent = string("configuration_element_provided");
-    return italics;
-  };
-  const notProvided = () => {
-    const italics = document.createElement("i");
-    italics.textContent = string("configuration_element_not_provided");
-    return italics;
-  };
-  const br = () => document.createElement("br");
+  const provided = string("configuration_element_provided");
+  const notProvided = string("configuration_element_not_provided");
 
-  const div = document.createElement("div");
-  div.classList = "peer-connection-config";
   // Create the text for a configuration field
-  const cfg = (obj, key, elem) => {
-    elem.append(br(), `${key}: `, key in obj ? `${obj[key]}` : notProvided());
-  };
+  const cfg = (obj, key) => [
+    renderElement("br"),
+    `${key}: `,
+    key in obj ? obj[key] : renderText("i", notProvided),
+  ];
+
   // Create the text for a fooProvided configuration field
-  const pro = (obj, key, elem) => {
-    elem.append(
-      br(),
-      `${key}(`,
-      provided(),
-      "/",
-      notProvided(),
-      "): ",
-      `${key}Provided` in obj ? provided() : notProvided()
-    );
-  };
+  const pro = (obj, key) => [
+    renderElement("br"),
+    `${key}(`,
+    renderText("i", provided),
+    `/`,
+    renderText("i", notProvided),
+    `): `,
+    renderText("i", obj[`${key}Provided`] ? provided : notProvided),
+  ];
 
-  div.append("RTCConfiguration");
-  cfg(c, "bundlePolicy", div);
-  cfg(c, "iceTransportPolicy", div);
-  pro(c, "peerIdentity", div);
-  cfg(c, "sdpSemantics", div);
-  div.append(br(), "iceServers: ");
-  if (!c.iceServers) {
-    div.append(notProvided());
-  }
-  for (const i of c.iceServers) {
-    const inner = document.createElement("div");
-    div.append(inner);
-    inner.append(`urls: ${JSON.stringify(i.urls)}`);
-    pro(i, "credential", inner);
-    pro(i, "userName", inner);
-  }
-  return div;
+  return renderElements("div", { classList: "peer-connection-config" }, [
+    "RTCConfiguration",
+    ...cfg(c, "bundlePolicy"),
+    ...cfg(c, "iceTransportPolicy"),
+    ...pro(c, "peerIdentity"),
+    ...cfg(c, "sdpSemantics"),
+    renderElement("br"),
+    "iceServers: ",
+    ...(!c.iceServers
+      ? [renderText("i", notProvided)]
+      : c.iceServers.map(i =>
+          renderElements("div", {}, [
+            `urls: ${JSON.stringify(i.urls)}`,
+            ...pro(i, "credential"),
+            ...pro(i, "userName"),
+          ])
+        )),
+  ]);
 }
 
 function renderICEStats(report) {
   const iceDiv = renderElements("div", {}, [
     renderText("h4", string("ice_stats_heading")),
   ]);
 
   // Render ICECandidate table