OLD | NEW |
1 var initialize_ConsoleTest = function() { | 1 var initialize_ConsoleTest = function() { |
2 | 2 |
3 InspectorTest.preloadModule("source_frame"); | 3 InspectorTest.preloadModule("source_frame"); |
4 InspectorTest.preloadPanel("console"); | 4 InspectorTest.preloadPanel("console"); |
5 | 5 |
6 InspectorTest.selectMainExecutionContext = function() | 6 InspectorTest.selectMainExecutionContext = function() |
7 { | 7 { |
8 var executionContexts = InspectorTest.runtimeModel.executionContexts(); | 8 var executionContexts = InspectorTest.runtimeModel.executionContexts(); |
9 for (var context of executionContexts) { | 9 for (var context of executionContexts) { |
10 if (context.isDefault) { | 10 if (context.isDefault) { |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 { | 418 { |
419 if (consoleView._visibleViewMessages.length === expectedCount) { | 419 if (consoleView._visibleViewMessages.length === expectedCount) { |
420 InspectorTest.addResult("Message count: " + expectedCount); | 420 InspectorTest.addResult("Message count: " + expectedCount); |
421 callback(); | 421 callback(); |
422 } else { | 422 } else { |
423 InspectorTest.addSniffer(consoleView, "_messageAppendedForTests", ch
eckAndReturn); | 423 InspectorTest.addSniffer(consoleView, "_messageAppendedForTests", ch
eckAndReturn); |
424 } | 424 } |
425 } | 425 } |
426 } | 426 } |
427 | 427 |
| 428 InspectorTest.selectConsoleMessages = function(fromMessage, fromTextOffset, toMe
ssage, toTextOffset, useTextContainer) |
| 429 { |
| 430 var consoleView = Console.ConsoleView.instance(); |
| 431 var from = selectionContainerAndOffset(consoleView.itemElement(fromMessage).
element(), fromTextOffset); |
| 432 var to = selectionContainerAndOffset(consoleView.itemElement(toMessage).elem
ent(), toTextOffset); |
| 433 window.getSelection().setBaseAndExtent(from.container, from.offset, to.conta
iner, to.offset); |
| 434 |
| 435 function selectionContainerAndOffset(container, offset) |
| 436 { |
| 437 if (offset === 0 && container.nodeType !== Node.TEXT_NODE) |
| 438 container = container.traverseNextTextNode(); |
| 439 var charCount = 0; |
| 440 var node = container; |
| 441 while (node = node.traverseNextTextNode(true)) { |
| 442 var length = node.textContent.length; |
| 443 if (charCount + length >= offset) { |
| 444 return { |
| 445 container: node, |
| 446 offset: offset - charCount |
| 447 }; |
| 448 } |
| 449 charCount += length; |
| 450 } |
| 451 return null; |
| 452 } |
| 453 } |
| 454 |
428 } | 455 } |
OLD | NEW |