Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Unified Diff: third_party/WebKit/Source/devtools/front_end/test_runner/TestRunner.js

Issue 2975523002: DevTools: add console test helpers to new test runner & migrate a console test (Closed)
Patch Set: fix Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/integration_test_runner/IntegrationTestRunner.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f5ca4bc82a47979ee9fe0ecc802a77d60d978a53 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|undefined} func
* @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}
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/integration_test_runner/IntegrationTestRunner.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698