Commit 1d193ea0 authored by Dong Hwi Lee's avatar Dong Hwi Lee Committed by Commit Bot

Update tests with testharness.js testing framework for xmlviewer.

Change-Id: I8bbfa6893179d4c713b79852400d0f77d1754b1a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2071294
Commit-Queue: Kent Tamura <tkent@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744401}
parent dc7bb093
<html> <html>
<head> <head>
<script> <script src="../resources/testharness.js"></script>
if (window.testRunner) { <script src="../resources/testharnessreport.js"></script>
testRunner.dumpAsText(); <script>
testRunner.setCanOpenWindows(); async_test((t) => {
testRunner.waitUntilDone(); let xmlWindow;
}
var xmlWindow;
function print(str) t.add_cleanup(() => { xmlWindow.close(); });
{
document.getElementById('output').textContent = str;
xmlWindow.close();
testRunner.notifyDone();
}
function checkSourceXML() function checkSourceXML() {
{
var sourceXML = xmlWindow.document.getElementById('webkit-xml-viewer-source-xml'); var sourceXML = xmlWindow.document.getElementById('webkit-xml-viewer-source-xml');
if (sourceXML && sourceXML.firstChild.nodeName == 'root') assert_equals(typeof(sourceXML), 'object');
print('SUCCESS'); assert_equals(sourceXML.firstChild.nodeName, 'root', 'Content of source XML.');
else
print('FAIL');
}
function onload() t.done();
{
xmlWindow = window.open('resources/sample.xml', "XMLViewerTestWindow");
xmlWindow.onload = checkSourceXML;
} }
</script> window.addEventListener("load", (e) => {
xmlWindow = window.open('resources/sample.xml',
'XMLViewerTestWindow');
xmlWindow.onload = t.step_func(checkSourceXML);
});
}, 'XMLTreeConverted');
</script>
</head> </head>
<body onload="onload();"> <body>
<p>Tests extensions hooks in xml viewer.</p>
<div id='output'></div>
</body> </body>
</html> </html>
<html> <html>
<head> <head>
<script> <script src="../resources/testharness.js"></script>
if (window.testRunner) { <script src="../resources/testharnessreport.js"></script>
testRunner.dumpAsText(); <script>
testRunner.setCanOpenWindows(); async_test((t) => {
testRunner.waitUntilDone(); let xmlWindow;
}
var xmlWindow;
function print(str) t.add_cleanup(() => { xmlWindow.close(); });
{
document.getElementById('output').textContent = str;
xmlWindow.close();
testRunner.notifyDone();
}
function checkWhiteSpaces() function checkWhitespaces() {
{ var sourcePretty = xmlWindow.document.getElementsByClassName('pretty-print')[0];
var sourcePretty = xmlWindow.document.getElementsByClassName("pretty-print")[0];
if (!sourcePretty || !sourcePretty.innerText) { if (!sourcePretty || !sourcePretty.innerText) {
requestAnimationFrame(checkWhiteSpaces); requestAnimationFrame(t.step_func(checkWhitespaces));
return; return;
} }
if (sourcePretty.innerText.includes(" bar ")) assert_true(sourcePretty.innerText.includes(' bar '));
print('SUCCESS');
else
print('FAIL');
}
function onload() t.done();
{
xmlWindow = window.open('resources/leading-and-trailing-whitespaces.xml', "XMLViewerTestWindow");
xmlWindow.onload = checkWhiteSpaces;
} }
</script> window.addEventListener("load", (e) => {
xmlWindow = window.open('resources/leading-and-trailing-whitespaces.xml',
'XMLViewerTestWindow');
xmlWindow.onload = t.step_func(checkWhitespaces);
});
}, 'XMLTreeConverted');
</script>
</head> </head>
<body onload="onload();"> <body>
<p>Tests leading and trailing whitespaces in xml viewer.</p>
<div id='output'></div>
</body> </body>
</html> </html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment