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>
<head>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.setCanOpenWindows();
testRunner.waitUntilDone();
}
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
async_test((t) => {
let xmlWindow;
var xmlWindow;
t.add_cleanup(() => { xmlWindow.close(); });
function print(str)
{
document.getElementById('output').textContent = str;
xmlWindow.close();
testRunner.notifyDone();
}
function checkSourceXML() {
var sourceXML = xmlWindow.document.getElementById('webkit-xml-viewer-source-xml');
assert_equals(typeof(sourceXML), 'object');
assert_equals(sourceXML.firstChild.nodeName, 'root', 'Content of source XML.');
function checkSourceXML()
{
var sourceXML = xmlWindow.document.getElementById('webkit-xml-viewer-source-xml');
if (sourceXML && sourceXML.firstChild.nodeName == 'root')
print('SUCCESS');
else
print('FAIL');
}
t.done();
}
function onload()
{
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>
<body onload="onload();">
<p>Tests extensions hooks in xml viewer.</p>
<div id='output'></div>
<body>
</body>
</html>
<html>
<head>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.setCanOpenWindows();
testRunner.waitUntilDone();
}
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
async_test((t) => {
let xmlWindow;
var xmlWindow;
t.add_cleanup(() => { xmlWindow.close(); });
function print(str)
{
document.getElementById('output').textContent = str;
xmlWindow.close();
testRunner.notifyDone();
}
function checkWhitespaces() {
var sourcePretty = xmlWindow.document.getElementsByClassName('pretty-print')[0];
function checkWhiteSpaces()
{
var sourcePretty = xmlWindow.document.getElementsByClassName("pretty-print")[0];
if (!sourcePretty || !sourcePretty.innerText) {
requestAnimationFrame(t.step_func(checkWhitespaces));
return;
}
if (!sourcePretty || !sourcePretty.innerText) {
requestAnimationFrame(checkWhiteSpaces);
return;
}
assert_true(sourcePretty.innerText.includes(' bar '));
if (sourcePretty.innerText.includes(" bar "))
print('SUCCESS');
else
print('FAIL');
}
t.done();
}
function onload()
{
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>
<body onload="onload();">
<p>Tests leading and trailing whitespaces in xml viewer.</p>
<div id='output'></div>
<body>
</body>
</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