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

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

Issue 2856933006: DevTools: fix text offset when selection ends on expand triangle (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script> 3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/console-test.js"></script> 4 <script src="../../http/tests/inspector/console-test.js"></script>
5 <script> 5 <script>
6 6
7 function test() 7 function test()
8 { 8 {
9 var longUrl = "www." + "z123456789".repeat(15) + ".com"; 9 var longUrl = "www." + "z123456789".repeat(15) + ".com";
10 var shortUrl = "www.bar.com"; 10 var shortUrl = "www.bar.com";
11 var mixedUrl = longUrl + " " + shortUrl + " " + longUrl; 11 var mixedUrl = longUrl + " " + shortUrl + " " + longUrl;
12 var shortUrlWithHashes = "www." + "0123456789".repeat(2) + "zfoobarz" + "012 3456789".repeat(2); 12 var shortUrlWithHashes = "www." + "0123456789".repeat(2) + "zfoobarz" + "012 3456789".repeat(2);
13 var urlWithHashes = "www." + "0123456789".repeat(2) + "z".repeat(150) + "012 3456789".repeat(2); 13 var urlWithHashes = "www." + "0123456789".repeat(2) + "z".repeat(150) + "012 3456789".repeat(2);
14 var highlightedUrl = "www." + "z".repeat(200) + ".com"; 14 var highlightedUrl = "www." + "z".repeat(200) + ".com";
15 var longUrlInMessageWithNonTextNodePrefix = "www." + "z123456789".repeat(15) + ".com";
15 var prepareCode = ` 16 var prepareCode = `
16 // Keep this as the first url logged to record the max truncated length. 17 // Keep this as the first url logged to record the max truncated length.
17 console.log("${longUrl}"); 18 console.log("${longUrl}");
18 19
19 console.log("${shortUrl}"); 20 console.log("${shortUrl}");
20 console.log("${longUrl}"); 21 console.log("${longUrl}");
21 console.log("${mixedUrl}"); 22 console.log("${mixedUrl}");
22 console.log("${shortUrlWithHashes}"); 23 console.log("${shortUrlWithHashes}");
23 console.log("${urlWithHashes}"); 24 console.log("${urlWithHashes}");
24 console.log("${highlightedUrl}"); 25 console.log("${highlightedUrl}");
26 console.log("${longUrlInMessageWithNonTextNodePrefix}");
25 `; 27 `;
26 28
27 var expectedMessageCount = 8; 29 var expectedMessageCount = 9;
28 var consoleView = Console.ConsoleView.instance(); 30 var consoleView = Console.ConsoleView.instance();
29 var viewport = Console.ConsoleView.instance()._viewport; 31 var viewport = Console.ConsoleView.instance()._viewport;
30 var maxLength; 32 var maxLength;
31 var halfMaxLength; 33 var halfMaxLength;
32 var secondLongUrlIndexInMixedUrl; 34 var secondLongUrlIndexInMixedUrl;
33 35
34 var tests = [ 36 var tests = [
35 function testSelectWithinTruncatedUrl(next) 37 function testSelectWithinTruncatedUrl(next)
36 { 38 {
37 makeSelectionAndDump(1, 0, 1, halfMaxLength); 39 makeSelectionAndDump(1, 0, 1, halfMaxLength);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 function testSelectWithinHighlightedUrlBeginning(next) { 115 function testSelectWithinHighlightedUrlBeginning(next) {
114 testHighlightedUrlWithSearchQuery("www.", next); 116 testHighlightedUrlWithSearchQuery("www.", next);
115 }, 117 },
116 118
117 function testSelectWithinHighlightedUrlMiddle(next) { 119 function testSelectWithinHighlightedUrlMiddle(next) {
118 testHighlightedUrlWithSearchQuery("zzzzz", next); 120 testHighlightedUrlWithSearchQuery("zzzzz", next);
119 }, 121 },
120 122
121 function testSelectWithinHighlightedUrlEnd(next) { 123 function testSelectWithinHighlightedUrlEnd(next) {
122 testHighlightedUrlWithSearchQuery(".com", next); 124 testHighlightedUrlWithSearchQuery(".com", next);
125 },
126
127 function testSelectionStartingInNonTextNode(next) {
128 var messageElement = consoleView.itemElement(8).element();
129
130 // Artificially insert an empty non-text node element in the beginni ng.
131 var artificialEmptyPrefixElement = createElementWithClass('div', 'ar tificialEmptyPrefixElement');
132 messageElement.insertBefore(artificialEmptyPrefixElement, messageEle ment.firstChild);
133
134 // Use .childNodes to ensure we get all nodes.
135 InspectorTest.addResult("\nMaking selection from empty prefix to end ");
136 window.getSelection().setBaseAndExtent(artificialEmptyPrefixElement, 0, messageElement.lastChild, messageElement.childNodes.length - 1);
137
138 var selectedText = viewport._selectedText();
139 if (selectedText)
140 InspectorTest.addResult("Selection length: " + selectedText.leng th + ", " + "text: " + selectedText.replace(/\bVM:\d+/g, "VM"));
141 else
142 InspectorTest.addResult("No selection");
143 next();
123 } 144 }
124 ]; 145 ];
125 146
126 InspectorTest.waitForConsoleMessages(expectedMessageCount, () => { 147 InspectorTest.waitForConsoleMessages(expectedMessageCount, () => {
127 viewport.invalidate(); 148 viewport.invalidate();
128 149
129 // Get the max truncated length from the first longUrl logged. 150 // Get the max truncated length from the first longUrl logged.
130 try { 151 try {
131 var longUrlMessageText = consoleMessageText(1); 152 var longUrlMessageText = consoleMessageText(1);
132 maxLength = longUrlMessageText.length; 153 maxLength = longUrlMessageText.length;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 next(); 210 next();
190 } 211 }
191 } 212 }
192 } 213 }
193 </script> 214 </script>
194 </head> 215 </head>
195 <body onload="runTest()"> 216 <body onload="runTest()">
196 <p>Tests that console copies tree outline messages properly.</p> 217 <p>Tests that console copies tree outline messages properly.</p>
197 </body> 218 </body>
198 </html> 219 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698