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

Unified Diff: third_party/WebKit/LayoutTests/resources/js-test.js

Issue 1648123004: Fix lazy test result printing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 4 years, 11 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/LayoutTests/intersection-observer/same-document-root.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/resources/js-test.js
diff --git a/third_party/WebKit/LayoutTests/resources/js-test.js b/third_party/WebKit/LayoutTests/resources/js-test.js
index c0988cea14a0d4c2c8eff34ebcf4cac0e81376a6..d94f49b5a8af1e54bbd6284b97eadf2e163d6c50 100644
--- a/third_party/WebKit/LayoutTests/resources/js-test.js
+++ b/third_party/WebKit/LayoutTests/resources/js-test.js
@@ -2,6 +2,7 @@
// results once at the end of the test instead of building them up. To enable
// this option, call setPrintTestResultsLazily() before running any tests.
var _lazyTestResults; // Set by setPrintTestResultsLazily().
+var _lazyDescription; // Set by description() after setPrintTestResultsLazily().
// svg/dynamic-updates tests set enablePixelTesting=true, as we want to dump text + pixel results
if (self.testRunner) {
@@ -13,7 +14,7 @@ if (self.testRunner) {
var isJsTest = true;
-var description, debug, successfullyParsed;
+var description, debug, successfullyParsed, getOrCreateTestElement;
var expectingError; // set by shouldHaveError()
var expectedErrorMessage; // set by onerror when expectingError is true
@@ -21,7 +22,7 @@ var unexpectedErrorMessage; // set by onerror when expectingError is not true
(function() {
- function getOrCreate(id, tagName)
+ getOrCreateTestElement = function(id, tagName)
{
var element = document.getElementById(id);
if (element)
@@ -32,7 +33,7 @@ var unexpectedErrorMessage; // set by onerror when expectingError is not true
var refNode;
var parent = document.body || document.documentElement;
if (id == "description")
- refNode = getOrCreate("console", "div");
+ refNode = getOrCreateTestElement("console", "div");
else
refNode = parent.firstChild;
@@ -49,7 +50,12 @@ var unexpectedErrorMessage; // set by onerror when expectingError is not true
else
span.innerHTML = '<p>' + msg + '</p><p>On success, you will see a series of "<span class="pass">PASS</span>" messages, followed by "<span class="pass">TEST COMPLETE</span>".</p>';
- var description = getOrCreate("description", "p");
+ if (_lazyTestResults) {
+ _lazyDescription = span;
+ return;
+ }
+
+ var description = getOrCreateTestElement("description", "p");
if (description.firstChild)
description.replaceChild(span, description.firstChild);
else
@@ -62,7 +68,8 @@ var unexpectedErrorMessage; // set by onerror when expectingError is not true
self._lazyTestResults.push(msg);
} else {
var span = document.createElement("span");
- getOrCreate("console", "div").appendChild(span); // insert it first so XHTML knows the namespace
+ // insert it first so XHTML knows the namespace;
+ getOrCreateTestElement("console", "div").appendChild(span);
span.innerHTML = msg + '<br />';
}
};
@@ -811,18 +818,15 @@ function finishJSTest()
return;
isSuccessfullyParsed();
+ if (self._lazyDescription)
+ getOrCreateTestElement("description", "p").appendChild(self._lazyDescription);
+
if (self._lazyTestResults && self._lazyTestResults.length > 0) {
- var consoleElement = document.getElementById("console");
- if (!consoleElement) {
- consoleElement = document.createElement("div");
- consoleElement.id = "console";
- var parent = document.body || document.documentElement;
- parent.insertBefore(consoleElement, parent.firstChild);
- }
+ var consoleElement = getOrCreateTestElement("console", "div");
self._lazyTestResults.forEach(function(msg) {
var span = document.createElement("span");
- span.innerHTML = msg + '<br />';
consoleElement.appendChild(span);
+ span.innerHTML = msg + '<br />';
});
}
« no previous file with comments | « third_party/WebKit/LayoutTests/intersection-observer/same-document-root.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698