Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Unified Diff: third_party/WebKit/LayoutTests/inspector/console/console-copy-truncated-text.html

Issue 2644753002: DevTools: untruncate links on copy (Closed)
Patch Set: ac Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/inspector/console/console-copy-truncated-text.html
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-copy-truncated-text.html b/third_party/WebKit/LayoutTests/inspector/console/console-copy-truncated-text.html
new file mode 100644
index 0000000000000000000000000000000000000000..636de568ef1d64662a7e3b7dc907ec12c8e70ccf
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector/console/console-copy-truncated-text.html
@@ -0,0 +1,127 @@
+<html>
+<head>
+<script src="../../http/tests/inspector/inspector-test.js"></script>
+<script src="../../http/tests/inspector/console-test.js"></script>
+<script>
+
+function test()
+{
+ var longUrl = "www." + "0123456789".repeat(15) + ".com";
+ var shortUrl = "www.bar.com";
+ var mixedUrl = longUrl + " " + shortUrl + " " + longUrl;
+ var prepareCode = `
+ // Keep this as the first url logged to record the max truncated length.
+ console.log("${longUrl}");
+
+ console.log("${shortUrl}");
+ console.log("${longUrl}");
+ console.log("${mixedUrl}");
+ `;
+
+ var consoleView = Console.ConsoleView.instance();
+ var viewport = Console.ConsoleView.instance()._viewport;
+ var maxLength;
+ var halfMaxLength;
+ var secondLongUrlIndexInMixedUrl;
+
+ var tests = [
+ function testSelectWithinTruncatedUrl(next)
+ {
+ makeSelectionAndDump(1, 0, 1, halfMaxLength);
+ makeSelectionAndDump(1, 0, 1, halfMaxLength + 1);
+ makeSelectionAndDump(1, 0, 1, maxLength);
+ makeSelectionAndDump(1, halfMaxLength, 1, halfMaxLength + 1);
+ makeSelectionAndDump(1, halfMaxLength, 1, maxLength);
+ makeSelectionAndDump(1, halfMaxLength + 1, 1, maxLength);
+ next();
+ },
+
+ function testSelectAcrossMultipleMessages(next) {
+ makeSelectionAndDump(1, 0, 2, shortUrl.length);
+ makeSelectionAndDump(1, halfMaxLength, 2, shortUrl.length);
+ makeSelectionAndDump(1, halfMaxLength + 1, 2, shortUrl.length);
+ next()
+ },
+
+ function testSelectAcrossMultipleMessagesWithTruncatedUrls(next) {
+ makeSelectionAndDump(1, 0, 3, halfMaxLength);
+ makeSelectionAndDump(1, 0, 3, halfMaxLength + 1);
+ makeSelectionAndDump(1, 0, 3, maxLength);
+ next()
+ },
+
+ function testSelectWithinMessageWithMultipleTruncatedUrls(next) {
+ makeSelectionAndDump(4, 0, 4, halfMaxLength);
+ makeSelectionAndDump(4, 0, 4, halfMaxLength + 1);
+ makeSelectionAndDump(4, 0, 4, secondLongUrlIndexInMixedUrl);
+ makeSelectionAndDump(4, 0, 4, secondLongUrlIndexInMixedUrl + halfMaxLength);
+ makeSelectionAndDump(4, 0, 4, secondLongUrlIndexInMixedUrl + halfMaxLength + 1);
+ makeSelectionAndDump(4, 0, 4, secondLongUrlIndexInMixedUrl + maxLength);
+
+ makeSelectionAndDump(4, halfMaxLength, 4, halfMaxLength + 1);
+ makeSelectionAndDump(4, halfMaxLength, 4, secondLongUrlIndexInMixedUrl);
+ makeSelectionAndDump(4, halfMaxLength, 4, secondLongUrlIndexInMixedUrl + halfMaxLength);
+ makeSelectionAndDump(4, halfMaxLength, 4, secondLongUrlIndexInMixedUrl + halfMaxLength + 1);
+ makeSelectionAndDump(4, halfMaxLength, 4, secondLongUrlIndexInMixedUrl + maxLength);
+
+ makeSelectionAndDump(4, halfMaxLength + 1, 4, secondLongUrlIndexInMixedUrl);
+ makeSelectionAndDump(4, halfMaxLength + 1, 4, secondLongUrlIndexInMixedUrl + halfMaxLength);
+ makeSelectionAndDump(4, halfMaxLength + 1, 4, secondLongUrlIndexInMixedUrl + halfMaxLength + 1);
+ makeSelectionAndDump(4, halfMaxLength + 1, 4, secondLongUrlIndexInMixedUrl + maxLength);
+
+ makeSelectionAndDump(4, secondLongUrlIndexInMixedUrl, 4, secondLongUrlIndexInMixedUrl + halfMaxLength);
+ makeSelectionAndDump(4, secondLongUrlIndexInMixedUrl, 4, secondLongUrlIndexInMixedUrl + halfMaxLength + 1);
+ makeSelectionAndDump(4, secondLongUrlIndexInMixedUrl, 4, secondLongUrlIndexInMixedUrl + maxLength);
+
+ makeSelectionAndDump(4, secondLongUrlIndexInMixedUrl + halfMaxLength, 4, secondLongUrlIndexInMixedUrl + halfMaxLength + 1);
+ makeSelectionAndDump(4, secondLongUrlIndexInMixedUrl + halfMaxLength, 4, secondLongUrlIndexInMixedUrl + maxLength);
+
+ makeSelectionAndDump(4, secondLongUrlIndexInMixedUrl + halfMaxLength + 1, 4, secondLongUrlIndexInMixedUrl + maxLength);
+ next()
+ }
+ ];
+
+ InspectorTest.waitForConsoleMessages(5, () => {
+ viewport.invalidate();
+
+ // Get the max truncated length from the first longUrl logged.
+ try {
+ var longUrlMessage = consoleView._visibleViewMessages[1].element();
+ var longUrlMessageText = longUrlMessage.querySelector('.console-message-text').deepTextContent();
+ maxLength = longUrlMessageText.length;
+ halfMaxLength = maxLength >> 1;
+ secondLongUrlIndexInMixedUrl = maxLength + 1 + shortUrl.length + 1;
+ InspectorTest.addResult("Long url has max length: " + maxLength + ", text: " + longUrlMessageText);
+ } catch (e) {
+ InspectorTest.addResult("FAIL: Could not get max truncation length from first longUrl message.");
+ InspectorTest.completeTest();
+ return;
+ }
+ InspectorTest.runTestSuite(tests);
+ });
+ InspectorTest.evaluateInConsole(prepareCode);
+
+ function makeSelectionAndDump(fromMessage, fromTextOffset, toMessage, toTextOffset, includeAnchor) {
+ InspectorTest.addResult("\nMaking selection: " + fromMessage + ", " + fromTextOffset + ", " + toMessage + ", " + toTextOffset);
+
+ // Ignore the anchor text on the start/end message, just use their contents.
+ if (!includeAnchor) {
+ var fromAnchor = consoleView.itemElement(fromMessage).element().querySelector('.console-message-anchor');
+ var toAnchor = consoleView.itemElement(toMessage).element().querySelector('.console-message-anchor');
+ fromTextOffset += fromAnchor ? fromAnchor.deepTextContent().length : 0;
+ toTextOffset += toAnchor ? toAnchor.deepTextContent().length : 0;
+ }
+ InspectorTest.selectConsoleMessages(fromMessage, fromTextOffset, toMessage, toTextOffset);
+ var selectedText = viewport._selectedText();
+ if (selectedText)
+ InspectorTest.addResult("Selection length: " + selectedText.length + ", " + "text: " + selectedText.replace(/\bVM\d+/g, "VM"));
+ else
+ InspectorTest.addResult("No selection");
+ }
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>Tests that console copies tree outline messages properly.</p>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698