Index: third_party/WebKit/LayoutTests/http/tests/inspector/console-test.js |
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/console-test.js b/third_party/WebKit/LayoutTests/http/tests/inspector/console-test.js |
index c4ac59cd0c26e0e9c7e82724e1a77649bcad6b86..4e050859238f87843c9755cac46f2796d5910cae 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/console-test.js |
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/console-test.js |
@@ -425,4 +425,29 @@ InspectorTest.waitForConsoleMessages = function(expectedCount, callback) |
} |
} |
+InspectorTest.selectConsoleMessages = function(fromMessage, fromTextOffset, toMessage, toTextOffset) |
+{ |
+ var consoleView = Console.ConsoleView.instance(); |
+ var from = selectionContainerAndOffset(consoleView.itemElement(fromMessage).element(), fromTextOffset); |
+ var to = selectionContainerAndOffset(consoleView.itemElement(toMessage).element(), toTextOffset); |
+ window.getSelection().setBaseAndExtent(from.container, from.offset, to.container, to.offset); |
+ |
+ function selectionContainerAndOffset(container, offset) |
+ { |
+ var charCount = 0; |
+ var node = container; |
+ while (node = node.traverseNextTextNode(true)) { |
+ var length = node.textContent.length; |
+ if (charCount + length >= offset) { |
+ return { |
+ container: node, |
+ offset: offset - charCount |
+ }; |
+ } |
+ charCount += length; |
+ } |
+ return null; |
+ } |
+} |
+ |
} |