| 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.evaluateInConsole = function(code, callback) | 6 InspectorTest.evaluateInConsole = function(code, callback) |
| 7 { | 7 { |
| 8 callback = InspectorTest.safeWrap(callback); | 8 callback = InspectorTest.safeWrap(callback); |
| 9 | 9 |
| 10 var consoleView = WebInspector.ConsolePanel._view(); | 10 var consoleView = WebInspector.ConsolePanel._view(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 InspectorTest.addSniffer(WebInspector.ConsoleView.prototype, "_consoleMessag
eAddedForTest", sniffer, opt_sticky); | 27 InspectorTest.addSniffer(WebInspector.ConsoleView.prototype, "_consoleMessag
eAddedForTest", sniffer, opt_sticky); |
| 28 } | 28 } |
| 29 | 29 |
| 30 InspectorTest.evaluateInConsoleAndDump = function(code, callback) | 30 InspectorTest.evaluateInConsoleAndDump = function(code, callback) |
| 31 { | 31 { |
| 32 callback = InspectorTest.safeWrap(callback); | 32 callback = InspectorTest.safeWrap(callback); |
| 33 | 33 |
| 34 function mycallback(text) | 34 function mycallback(text) |
| 35 { | 35 { |
| 36 text = text.replace(/\bVM\d+/g, "VM"); | 36 text = text.replace(/\bVM\d+/g, "VM"); |
| 37 text = text.replace(/(?:InjectedScript\.)?_?evaluate\w* @ VM:\d+/g, ""); | |
| 38 InspectorTest.addResult(code + " = " + text); | 37 InspectorTest.addResult(code + " = " + text); |
| 39 callback(text); | 38 callback(text); |
| 40 } | 39 } |
| 41 InspectorTest.evaluateInConsole(code, mycallback); | 40 InspectorTest.evaluateInConsole(code, mycallback); |
| 42 } | 41 } |
| 43 | 42 |
| 44 InspectorTest.prepareConsoleMessageText = function(messageElement, consoleMessag
e) | 43 InspectorTest.prepareConsoleMessageText = function(messageElement, consoleMessag
e) |
| 45 { | 44 { |
| 46 var messageText = messageElement.deepTextContent().replace(/\u200b/g, ""); | 45 var messageText = messageElement.deepTextContent().replace(/\u200b/g, ""); |
| 47 // Replace scriptIds with generic scriptId string to avoid flakiness. | 46 // Replace scriptIds with generic scriptId string to avoid flakiness. |
| 48 messageText = messageText.replace(/VM\d+/g, "VM"); | 47 messageText = messageText.replace(/VM\d+/g, "VM"); |
| 49 // Strip out InjectedScript line numbers from stack traces to avoid rebaseli
ning each time InjectedScriptSource is edited. | |
| 50 messageText = messageText.replace(/(?:InjectedScript\.)?_?evaluate\w* @ VM:\
d+/g, ""); | |
| 51 // Strip out InjectedScript line numbers from console message anchor. | |
| 52 var functionName = consoleMessage && consoleMessage.stackTrace && consoleMes
sage.stackTrace.callFrames[0] && consoleMessage.stackTrace.callFrames[0].functio
nName || ""; | |
| 53 if (functionName.indexOf("evaluate") !== -1) | |
| 54 messageText = messageText.replace(/\bVM:\d+/, ""); // Only first replace
. | |
| 55 if (messageText.startsWith("Navigated to")) { | 48 if (messageText.startsWith("Navigated to")) { |
| 56 var fileName = messageText.split(" ").pop().split("/").pop(); | 49 var fileName = messageText.split(" ").pop().split("/").pop(); |
| 57 messageText = "Navigated to " + fileName; | 50 messageText = "Navigated to " + fileName; |
| 58 } | 51 } |
| 59 // The message might be extremely long in case of dumping stack overflow mes
sage. | 52 // The message might be extremely long in case of dumping stack overflow mes
sage. |
| 60 messageText = messageText.substring(0, 1024); | 53 messageText = messageText.substring(0, 1024); |
| 61 return messageText; | 54 return messageText; |
| 62 } | 55 } |
| 63 | 56 |
| 64 InspectorTest.disableConsoleViewport = function() | 57 InspectorTest.disableConsoleViewport = function() |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 { | 119 { |
| 127 function isNotEmptyLine(string) | 120 function isNotEmptyLine(string) |
| 128 { | 121 { |
| 129 return string.trim().length > 0; | 122 return string.trim().length > 0; |
| 130 } | 123 } |
| 131 | 124 |
| 132 function ignoreStackFrameAndMutableData(string) | 125 function ignoreStackFrameAndMutableData(string) |
| 133 { | 126 { |
| 134 var buffer = string.replace(/\u200b/g, ""); | 127 var buffer = string.replace(/\u200b/g, ""); |
| 135 buffer = buffer.replace(/VM\d+/g, "VM"); | 128 buffer = buffer.replace(/VM\d+/g, "VM"); |
| 136 buffer = buffer.replace(/(?:InjectedScript\.)?_?evaluate\w* @ VM:\d+/g,
""); | |
| 137 return buffer.replace(/^\s+at [^\]]+(]?)$/, "$1"); | 129 return buffer.replace(/^\s+at [^\]]+(]?)$/, "$1"); |
| 138 } | 130 } |
| 139 | 131 |
| 140 messageFormatter = messageFormatter || InspectorTest.textContentWithLineBrea
ks; | 132 messageFormatter = messageFormatter || InspectorTest.textContentWithLineBrea
ks; |
| 141 var buffer = messageFormatter(node); | 133 var buffer = messageFormatter(node); |
| 142 return buffer.split("\n").map(ignoreStackFrameAndMutableData).filter(isNotEm
ptyLine).join("\n"); | 134 return buffer.split("\n").map(ignoreStackFrameAndMutableData).filter(isNotEm
ptyLine).join("\n"); |
| 143 } | 135 } |
| 144 | 136 |
| 145 InspectorTest.simpleFormatter = function(element, message) | 137 InspectorTest.simpleFormatter = function(element, message) |
| 146 { | 138 { |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 if (consoleView._visibleViewMessages.length === expectedCount) { | 389 if (consoleView._visibleViewMessages.length === expectedCount) { |
| 398 InspectorTest.addResult("Message count: " + expectedCount); | 390 InspectorTest.addResult("Message count: " + expectedCount); |
| 399 callback(); | 391 callback(); |
| 400 } else { | 392 } else { |
| 401 InspectorTest.addSniffer(consoleView, "_messageAppendedForTests", ch
eckAndReturn); | 393 InspectorTest.addSniffer(consoleView, "_messageAppendedForTests", ch
eckAndReturn); |
| 402 } | 394 } |
| 403 } | 395 } |
| 404 } | 396 } |
| 405 | 397 |
| 406 } | 398 } |
| OLD | NEW |