parser/htmlparser/tests/mochitest/test_viewsource.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <!DOCTYPE HTML>
     2 <html>
     3   <head>
     4     <title>Test for view source</title>
     5     <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     6     <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     7   </head>
     9   <body>
    11 <!--
    12   this is a multi-line comment
    13 -->
    15     <script class="testbody" type="text/javascript">
    17       SimpleTest.waitForExplicitFinish();
    19       // Return the source text of the document at the given URL.
    20       function fetch(url) {
    21         var xhr = new XMLHttpRequest();
    22         xhr.open("GET", url, false);    // None of this async silliness,
    23         xhr.send();                     // we'll just wait.
    24         return xhr.responseText;
    25       }
    27       // We will "view" the source of the document in a new window.
    28       // If everything is working correctly, the "source" will simply be the
    29       // text content of the new window's document's body element.
    30       // We have to use a window as view-source: is only allowed in top level,
    31       // see bug 624883.
    33       // Open the new window.
    34       var windowWithSource = window.open("about:blank");
    36       // The actual test will be carried out inside the window's onload handler.
    37       windowWithSource.onload = function () {
    38         var apparentSource = this.document.body.textContent;
    39         var actualSource = fetch(location.href);
    40         is(apparentSource, actualSource, "Sources should match");
    42         windowWithSource.close()
    43         SimpleTest.finish();
    44       }
    46       windowWithSource.location.href = "view-source:" + location.href;
    47     </script>
    49   </body>
    50 </html>

mercurial