Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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>