content/base/test/test_bug604660.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 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=604660
     5 -->
     6 <head>
     7   <title>Test for Bug 604660</title>
     8   <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
     9   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    11 </head>
    12 <body>
    13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=604660">Mozilla Bug 604660</a>
    14 <script>
    15 SimpleTest.waitForExplicitFinish();
    16 var asyncState = false;
    17 var scriptState = 0;
    19 function scriptRan(num) {
    20   ++scriptState;
    21   is(scriptState, num, "Scripts ran in the wrong sequence.");
    22 }
    24 function asyncRan() {
    25   asyncState = true;
    26 }
    28 </script>
    29 <p id="display"><iframe src="file_bug604660-1.xml" onload="iframeloaded()";></iframe></p>
    30 <div id="content" style="display: none">
    32 </div>
    33 <pre id="test">
    34 <script class="testbody" type="text/javascript">
    36 var xlstProcessorState = false;
    38 function xsltProcessorCreatedScriptRan() {
    39   xlstProcessorState = true;
    40 }
    42 function iframeloaded() {
    43   ok(asyncState, "Async script should have run.");
    44   is(scriptState, 5, "Five scripts should have run.");
    46   var processor = new XSLTProcessor();
    48   var xhr = new XMLHttpRequest();
    49   xhr.onreadystatechange = function() {
    50     if (this.readyState == 4) {
    51       processor.importStylesheet(this.responseXML);
    52       xhr.onreadystatechange = function() {
    53         if (this.readyState == 4) {
    54           var doc = processor.transformToDocument(this.responseXML);
    55           var target = document.getElementById("display");
    56           target.appendChild(doc.documentElement.firstChild);
    57           ok(!xlstProcessorState, "Scripts created by transformToDocument should not run.");
    59           var fragment = processor.transformToFragment(this.responseXML, document);
    60           target.appendChild(fragment.firstChild.firstChild);
    61           ok(xlstProcessorState, "Scripts created by transformToFragment should run.");
    63           SimpleTest.finish();
    64         }
    65       }
    66       xhr.open("GET", "file_bug604660-5.xml");
    67       xhr.send();
    68     }
    69   }
    70   xhr.open("GET", "file_bug604660-6.xsl");
    71   xhr.send();
    72 }
    73 </script>
    74 </pre>
    75 </body>
    76 </html>

mercurial