| OLD | NEW |
| 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 function populateConsoleWithMessages(count) | 6 function populateConsoleWithMessages(count) |
| 7 { | 7 { |
| 8 for (var i = 0; i < count - 1; ++i) | 8 for (var i = 0; i < count - 1; ++i) |
| 9 console.log("Message #" + i); | 9 console.log("Message #" + i); |
| 10 console.log("hello %cworld", "color: blue"); | 10 console.log("hello %cworld", "color: blue"); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 { | 90 { |
| 91 viewport.forceScrollItemToBeFirst(0); | 91 viewport.forceScrollItemToBeFirst(0); |
| 92 dumpSelectionModel(); | 92 dumpSelectionModel(); |
| 93 dumpViewportRenderedItems(); | 93 dumpViewportRenderedItems(); |
| 94 next(); | 94 next(); |
| 95 }, | 95 }, |
| 96 | 96 |
| 97 function testScrollSelectionAwayDown(next) | 97 function testScrollSelectionAwayDown(next) |
| 98 { | 98 { |
| 99 consoleView._immediatelyScrollToBottom(); | 99 consoleView._immediatelyScrollToBottom(); |
| 100 viewport.refresh(); | 100 viewport._innerRefresh(true); |
| 101 dumpSelectionModel(); | 101 dumpSelectionModel(); |
| 102 dumpViewportRenderedItems(); | 102 dumpViewportRenderedItems(); |
| 103 next(); | 103 next(); |
| 104 }, | 104 }, |
| 105 | 105 |
| 106 function testShiftClickSelectionOver(next) | 106 function testShiftClickSelectionOver(next) |
| 107 { | 107 { |
| 108 emulateShiftClickOnMessage(minimumViewportMessagesCount); | 108 emulateShiftClickOnMessage(minimumViewportMessagesCount); |
| 109 dumpSelectionModel(); | 109 dumpSelectionModel(); |
| 110 dumpViewportRenderedItems(); | 110 dumpViewportRenderedItems(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 197 |
| 198 function dumpSelectionModelElement(model) | 198 function dumpSelectionModelElement(model) |
| 199 { | 199 { |
| 200 if (!model) | 200 if (!model) |
| 201 return "null"; | 201 return "null"; |
| 202 return String.sprintf("{item: %d, offset: %d}", model.item, model.offset
); | 202 return String.sprintf("{item: %d, offset: %d}", model.item, model.offset
); |
| 203 } | 203 } |
| 204 | 204 |
| 205 function dumpSelectionModel() | 205 function dumpSelectionModel() |
| 206 { | 206 { |
| 207 viewport.refresh(); | 207 viewport._innerRefresh(true); |
| 208 var text = String.sprintf("anchor = %s, head = %s", dumpSelectionModelEl
ement(viewport._anchorSelection), dumpSelectionModelElement(viewport._headSelect
ion)); | 208 var text = String.sprintf("anchor = %s, head = %s", dumpSelectionModelEl
ement(viewport._anchorSelection), dumpSelectionModelElement(viewport._headSelect
ion)); |
| 209 InspectorTest.addResult(text); | 209 InspectorTest.addResult(text); |
| 210 } | 210 } |
| 211 | 211 |
| 212 function dumpSelectionText() | 212 function dumpSelectionText() |
| 213 { | 213 { |
| 214 viewport.refresh(); | 214 viewport._innerRefresh(true); |
| 215 var text = viewport._selectedText(); | 215 var text = viewport._selectedText(); |
| 216 InspectorTest.addResult("Selected text:<<<EOL\n" + text + "\nEOL"); | 216 InspectorTest.addResult("Selected text:<<<EOL\n" + text + "\nEOL"); |
| 217 } | 217 } |
| 218 | 218 |
| 219 function dumpViewportRenderedItems() | 219 function dumpViewportRenderedItems() |
| 220 { | 220 { |
| 221 viewport.refresh(); | 221 viewport._innerRefresh(true); |
| 222 var firstVisibleIndex = viewport.firstVisibleIndex(); | 222 var firstVisibleIndex = viewport.firstVisibleIndex(); |
| 223 var lastVisibleIndex = viewport.lastVisibleIndex(); | 223 var lastVisibleIndex = viewport.lastVisibleIndex(); |
| 224 InspectorTest.addResult("first visible message index: " + firstVisibleIn
dex); | 224 InspectorTest.addResult("first visible message index: " + firstVisibleIn
dex); |
| 225 } | 225 } |
| 226 | 226 |
| 227 function emulateShiftClickOnMessage(messageIndex) | 227 function emulateShiftClickOnMessage(messageIndex) |
| 228 { | 228 { |
| 229 viewport.refresh(); | 229 viewport._innerRefresh(true); |
| 230 var selection = window.getSelection(); | 230 var selection = window.getSelection(); |
| 231 if (!selection || !selection.rangeCount) { | 231 if (!selection || !selection.rangeCount) { |
| 232 InspectorTest.addResult("FAILURE: There's no selection"); | 232 InspectorTest.addResult("FAILURE: There's no selection"); |
| 233 return; | 233 return; |
| 234 } | 234 } |
| 235 viewport.forceScrollItemToBeFirst(Math.max(messageIndex - minimumViewpor
tMessagesCount / 2, 0)); | 235 viewport.forceScrollItemToBeFirst(Math.max(messageIndex - minimumViewpor
tMessagesCount / 2, 0)); |
| 236 var element = consoleView.itemElement(messageIndex).element(); | 236 var element = consoleView.itemElement(messageIndex).element(); |
| 237 selection.setBaseAndExtent(selection.anchorNode, selection.anchorOffset,
element, 0); | 237 selection.setBaseAndExtent(selection.anchorNode, selection.anchorOffset,
element, 0); |
| 238 viewport.refresh(); | 238 viewport._innerRefresh(true); |
| 239 } | 239 } |
| 240 | 240 |
| 241 function selectionContainerAndOffset(container, offset) | 241 function selectionContainerAndOffset(container, offset) |
| 242 { | 242 { |
| 243 var charCount = 0; | 243 var charCount = 0; |
| 244 var node = container; | 244 var node = container; |
| 245 while (node = node.traverseNextTextNode(true)) { | 245 while (node = node.traverseNextTextNode(true)) { |
| 246 var length = node.textContent.length; | 246 var length = node.textContent.length; |
| 247 if (charCount + length >= offset) { | 247 if (charCount + length >= offset) { |
| 248 return { | 248 return { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 260 if (Math.abs(toMessage - fromMessage) > minimumViewportMessagesCount) { | 260 if (Math.abs(toMessage - fromMessage) > minimumViewportMessagesCount) { |
| 261 InspectorTest.addResult(String.sprintf("FAILURE: Cannot select more
then %d messages (requested to select from %d to %d", minimumViewportMessagesCou
nt, fromMessage, toMessage)); | 261 InspectorTest.addResult(String.sprintf("FAILURE: Cannot select more
then %d messages (requested to select from %d to %d", minimumViewportMessagesCou
nt, fromMessage, toMessage)); |
| 262 InspectorTest.completeTest(); | 262 InspectorTest.completeTest(); |
| 263 return; | 263 return; |
| 264 } | 264 } |
| 265 viewport.forceScrollItemToBeFirst(Math.min(fromMessage, toMessage)); | 265 viewport.forceScrollItemToBeFirst(Math.min(fromMessage, toMessage)); |
| 266 | 266 |
| 267 var from = selectionContainerAndOffset(consoleView.itemElement(fromMessa
ge).element(), fromTextOffset); | 267 var from = selectionContainerAndOffset(consoleView.itemElement(fromMessa
ge).element(), fromTextOffset); |
| 268 var to = selectionContainerAndOffset(consoleView.itemElement(toMessage).
element(), toTextOffset); | 268 var to = selectionContainerAndOffset(consoleView.itemElement(toMessage).
element(), toTextOffset); |
| 269 window.getSelection().setBaseAndExtent(from.container, from.offset, to.c
ontainer, to.offset); | 269 window.getSelection().setBaseAndExtent(from.container, from.offset, to.c
ontainer, to.offset); |
| 270 viewport.refresh(); | 270 viewport._innerRefresh(true); |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 </script> | 273 </script> |
| 274 </head> | 274 </head> |
| 275 <body onload="runTest()"> | 275 <body onload="runTest()"> |
| 276 <p> | 276 <p> |
| 277 Tests that console viewport handles selection properly. | 277 Tests that console viewport handles selection properly. |
| 278 </p> | 278 </p> |
| 279 </body> | 279 </body> |
| 280 </html> | 280 </html> |
| OLD | NEW |