Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/test_runner/TestRunner.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/test_runner/TestRunner.js b/third_party/WebKit/Source/devtools/front_end/test_runner/TestRunner.js |
| index 04a05eb4d86e61de8e1b86462dde3b3931724e24..4174a5200a284299a5cae8933026dc6fe46b25ca 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/test_runner/TestRunner.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/test_runner/TestRunner.js |
| @@ -91,7 +91,7 @@ TestRunner.runTests = function(tests) { |
| * @param {!Object} receiver |
| * @param {string} methodName |
| * @param {!Function} override |
| - * @param {boolean} opt_sticky |
| + * @param {boolean=} opt_sticky |
| */ |
| TestRunner.addSniffer = function(receiver, methodName, override, opt_sticky) { |
| override = TestRunner.safeWrap(override); |
| @@ -187,7 +187,7 @@ TestRunner.createKeyEvent = function(key, ctrlKey, altKey, shiftKey, metaKey) { |
| }; |
| /** |
| - * @param {!Function} func |
| + * @param {!Function=} func |
|
caseq
2017/07/12 01:04:33
I think it's technically {!Function|undefined} rat
chenwilliam
2017/07/12 22:02:58
Done.
|
| * @param {!Function=} onexception |
| * @return {!Function} |
| */ |
| @@ -212,6 +212,44 @@ TestRunner.safeWrap = function(func, onexception) { |
| return result; |
| }; |
| +/** |
| + * @param {!Element} node |
| + * @return {string} |
| + */ |
| +TestRunner.textContentWithLineBreaks = function(node) { |
| + function padding(currentNode) { |
| + var result = 0; |
| + while (currentNode && currentNode !== node) { |
| + if (currentNode.nodeName === 'OL' && |
| + !(currentNode.classList && currentNode.classList.contains('object-properties-section'))) |
| + ++result; |
| + currentNode = currentNode.parentNode; |
| + } |
| + return Array(result * 4 + 1).join(' '); |
| + } |
| + |
| + var buffer = ''; |
| + var currentNode = node; |
| + var ignoreFirst = false; |
| + while (currentNode.traverseNextNode(node)) { |
| + currentNode = currentNode.traverseNextNode(node); |
| + if (currentNode.nodeType === Node.TEXT_NODE) { |
| + buffer += currentNode.nodeValue; |
| + } else if (currentNode.nodeName === 'LI' || currentNode.nodeName === 'TR') { |
| + if (!ignoreFirst) |
| + buffer += '\n' + padding(currentNode); |
| + else |
| + ignoreFirst = false; |
| + } else if (currentNode.nodeName === 'STYLE') { |
| + currentNode = currentNode.traverseNextNode(node); |
| + continue; |
| + } else if (currentNode.classList && currentNode.classList.contains('object-properties-section')) { |
| + ignoreFirst = true; |
| + } |
| + } |
| + return buffer; |
| +}; |
| + |
| /** |
| * @param {!Function} testFunction |
| * @return {!Function} |