From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../browser/browser_webconsole_error_with_url.js | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 devtools/client/webconsole/test/browser/browser_webconsole_error_with_url.js (limited to 'devtools/client/webconsole/test/browser/browser_webconsole_error_with_url.js') diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_error_with_url.js b/devtools/client/webconsole/test/browser/browser_webconsole_error_with_url.js new file mode 100644 index 0000000000..8c0c2a51f7 --- /dev/null +++ b/devtools/client/webconsole/test/browser/browser_webconsole_error_with_url.js @@ -0,0 +1,62 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Check if an error with Unicode characters is reported correctly. + +"use strict"; + +const longParam = "0".repeat(200); +const url1 = `https://example.com?v=${longParam}`; +const url2 = `https://example.org?v=${longParam}`; + +const TEST_URI = `data:text/html;charset=utf8,`; +const { ELLIPSIS } = require("resource://devtools/shared/l10n.js"); + +add_task(async function () { + const hud = await openNewTabAndConsole(TEST_URI); + + // On e10s, the exception is triggered in child process + // and is ignored by test harness + if (!Services.appinfo.browserTabsRemoteAutostart) { + expectUncaughtException(); + } + + const getCroppedUrl = origin => { + const cropLimit = 120; + const half = cropLimit / 2; + const params = `?v=${"0".repeat( + half - origin.length - 3 + )}${ELLIPSIS}${"0".repeat(half)}`; + return `${origin}${params}`; + }; + + const getVisibleLinkText = linkEl => { + const [firstPart, , lastPart] = linkEl.children; + return `${firstPart.innerText}${ELLIPSIS}${lastPart.innerText}`; + }; + + const EXPECTED_MESSAGE = `get more information on this error`; + + const msg = await waitFor(() => findErrorMessage(hud, EXPECTED_MESSAGE)); + ok(msg, `Link in error message are cropped as expected`); + + const [comLink, orgLink] = Array.from(msg.querySelectorAll("a")); + is(comLink.getAttribute("href"), url1, "First link has expected url"); + is(comLink.getAttribute("title"), url1, "First link has expected tooltip"); + is( + getVisibleLinkText(comLink), + getCroppedUrl("https://example.com"), + "First link has expected text" + ); + + is(orgLink.getAttribute("href"), url2, "Second link has expected url"); + is(orgLink.getAttribute("title"), url2, "Second link has expected tooltip"); + is( + getVisibleLinkText(orgLink), + getCroppedUrl("https://example.org"), + "Second link has expected text" + ); +}); -- cgit v1.2.3