tenfourfox/parser/htmlparser/tests/mochitest/test_viewsource.html
Cameron Kaiser c9b2922b70 hello FPR
2017-04-19 00:56:45 -07:00

51 lines
1.5 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test for view source</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<!--
this is a multi-line comment
-->
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
// Return the source text of the document at the given URL.
function fetch(url) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, false); // None of this async silliness,
xhr.send(); // we'll just wait.
return xhr.responseText;
}
// We will "view" the source of the document in a new window.
// If everything is working correctly, the "source" will simply be the
// text content of the new window's document's body element.
// We have to use a window as view-source: is only allowed in top level,
// see bug 624883.
// Open the new window.
var windowWithSource = window.open("about:blank");
// The actual test will be carried out inside the window's onload handler.
windowWithSource.onload = function () {
var apparentSource = this.document.body.textContent;
var actualSource = fetch(location.href);
is(apparentSource, actualSource, "Sources should match");
windowWithSource.close()
SimpleTest.finish();
}
windowWithSource.location.href = "view-source:" + location.href;
</script>
</body>
</html>