tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug351633-3.html (3587B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=351633
      5 -->
      6 <head>
      7  <title>Test for Bug 351633</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>        
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     10 </head>
     11 <body>
     12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=351633">Mozilla Bug 351633</a>
     13 <pre id="test">
     14 <script class="testbody" type="text/javascript">
     15 // String concatenation used to avoid incorrect detection of end of script elements.
     16 /* eslint-disable no-useless-concat */
     17 
     18 var passJSUrl;
     19 var passJSUrl2;
     20 var finishTest;
     21 
     22 /** Test for Bug 351633 */
     23 function runTests() {
     24  $("testframe1").onload = test1;
     25  // test2 will be called as finishTest
     26  $("testframe3").onload = test3;
     27  $("testframe4").onload = test4;
     28  $("testframe5").onload = test5;
     29  passJSUrl = false;
     30  window.testframe1.location.href =
     31    'javascript:"<script>parent.passJSUrl = true</' + 'script>"'
     32 }
     33 
     34 function test1() {
     35  is(passJSUrl, true, "Script should have run in child");
     36 
     37  passJSUrl = false;
     38  passJSUrl2 = true;
     39  finishTest = test2;
     40 
     41  window.testframe2.location.href =
     42    'javascript: location = "pass.html"; ' +
     43    '"<script>parent.passJSUrl2 = false</' + 'script>"'
     44 }
     45 
     46 function test2() {
     47  is(passJSUrl, true, "pass.html should have loaded");
     48  is(passJSUrl2, true, "<script> should not have run");
     49 
     50  passJSUrl = true;
     51  passJSUrl2 = false;
     52  finishTest = function() { };
     53 
     54  window.testframe3.location.href = 'fail.html';
     55  window.testframe3.location.href =
     56    'javascript: "<script>parent.passJSUrl2 = true</' + 'script>"'
     57 }
     58 
     59 function test3() {
     60  if (window.testframe3.location.href == 'fail.html') {
     61    // Ignore this call; we expect the javascript: URI to still load.  Note
     62    // that whether onload fires for the fail.html load before the event for
     63    // the javascript: URI execution runs is a timing issue, so we can't depend
     64    // on the ordering.    
     65    return;
     66  }
     67 
     68  // Since fail.html could have loaded, the value of passJSUrl here is random
     69 
     70  // Something is bogus here.  Maybe we're ending up with the href being the
     71  // javascript: URI even though it hasn't run yet?  Or something?  In any
     72  // case, this test fails on some tinderboxen but not others....  Need to
     73  // sort it out.  
     74  // is(passJSUrl2, true, "<script> should have run");
     75 
     76  passJSUrl = false;
     77  passJSUrl2 = true;
     78  finishTest = function() { };
     79 
     80  window.testframe4.location.href = 'pass.html';
     81  window.testframe4.location.href =
     82    'javascript:void("<script>parent.passJSUrl2 = false</' + 'script>")'; 
     83 }
     84 
     85 function test4() {
     86  is(passJSUrl, true, "pass.html should have loaded again");
     87  is(passJSUrl2, true, "<script> should not have run in void");
     88 
     89  passJSUrl = false;
     90  passJSUrl2 = true;
     91  finishTest = function() { };
     92 
     93  window.testframe5.location.href =
     94    'javascript:"<script>parent.passJSUrl2 = false</' + 'script>"';
     95  window.testframe5.location.href = 'pass.html';  
     96 }
     97 
     98 function test5() {
     99  is(passJSUrl, true, "pass.html should have loaded yet again");
    100  is(passJSUrl2, true, "javascript: load should have been canceled");
    101 
    102  SimpleTest.finish();
    103 }
    104 
    105 SimpleTest.waitForExplicitFinish();
    106 addLoadEvent(runTests);
    107 
    108 </script>
    109 </pre>
    110 <p id="display">
    111  <iframe name="testframe1" id="testframe1"></iframe>
    112  <iframe name="testframe2" id="testframe2"></iframe>
    113  <iframe name="testframe3" id="testframe3"></iframe>
    114  <iframe name="testframe4" id="testframe4"></iframe>
    115  <iframe name="testframe5" id="testframe5"></iframe>
    116 </p>
    117 <div id="content" style="display: none">
    118  
    119 </div>
    120 </body>
    121 </html>