dom/src/jsurl/test/test_bug351633-3.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=351633
     5 -->
     6 <head>
     7   <title>Test for Bug 351633</title>
     8   <script type="text/javascript" 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">
    16 var passJSUrl;
    17 var passJSUrl2;
    18 var finishTest;
    20 /** Test for Bug 351633 **/
    21 function runTests() {
    22   $("testframe1").onload = test1;
    23   // test2 will be called as finishTest
    24   $("testframe3").onload = test3;
    25   $("testframe4").onload = test4;
    26   $("testframe5").onload = test5;
    27   passJSUrl = false;
    28   window.testframe1.location.href =
    29     'javascript:"<script>parent.passJSUrl = true</' + 'script>"'
    30 }
    32 function test1() {
    33   is(passJSUrl, true, "Script should have run in child");
    35   passJSUrl = false;
    36   passJSUrl2 = true;
    37   finishTest = test2;
    39   window.testframe2.location.href =
    40     'javascript: location = "pass.html"; ' +
    41     '"<script>parent.passJSUrl2 = false</' + 'script>"'
    42 }
    44 function test2() {
    45   is(passJSUrl, true, "pass.html should have loaded");
    46   is(passJSUrl2, true, "<script> should not have run");
    48   passJSUrl = true;
    49   passJSUrl2 = false;
    50   finishTest = function() { };
    52   window.testframe3.location.href = 'fail.html';
    53   window.testframe3.location.href =
    54     'javascript: "<script>parent.passJSUrl2 = true</' + 'script>"'
    55 }
    57 function test3() {
    58   if (window.testframe3.location.href == 'fail.html') {
    59     // Ignore this call; we expect the javascript: URI to still load.  Note
    60     // that whether onload fires for the fail.html load before the event for
    61     // the javascript: URI execution runs is a timing issue, so we can't depend
    62     // on the ordering.    
    63     return;
    64   }
    66   // Since fail.html could have loaded, the value of passJSUrl here is random
    68   // Something is bogus here.  Maybe we're ending up with the href being the
    69   // javascript: URI even though it hasn't run yet?  Or something?  In any
    70   // case, this test fails on some tinderboxen but not others....  Need to
    71   // sort it out.  
    72   // is(passJSUrl2, true, "<script> should have run");
    74   passJSUrl = false;
    75   passJSUrl2 = true;
    76   finishTest = function() { };
    78   window.testframe4.location.href = 'pass.html';
    79   window.testframe4.location.href =
    80     'javascript:void("<script>parent.passJSUrl2 = false</' + 'script>")'; 
    81 }
    83 function test4() {
    84   is(passJSUrl, true, "pass.html should have loaded again");
    85   is(passJSUrl2, true, "<script> should not have run in void");
    87   passJSUrl = false;
    88   passJSUrl2 = true;
    89   finishTest = function() { };
    91   window.testframe5.location.href =
    92     'javascript:"<script>parent.passJSUrl2 = false</' + 'script>"';
    93   window.testframe5.location.href = 'pass.html';  
    94 }
    96 function test5() {
    97   is(passJSUrl, true, "pass.html should have loaded yet again");
    98   is(passJSUrl2, true, "javascript: load should have been canceled");
   100   SimpleTest.finish();
   101 }
   103 SimpleTest.waitForExplicitFinish();
   104 addLoadEvent(runTests);
   106 </script>
   107 </pre>
   108 <p id="display">
   109   <iframe name="testframe1" id="testframe1"></iframe>
   110   <iframe name="testframe2" id="testframe2"></iframe>
   111   <iframe name="testframe3" id="testframe3"></iframe>
   112   <iframe name="testframe4" id="testframe4"></iframe>
   113   <iframe name="testframe5" id="testframe5"></iframe>
   114 </p>
   115 <div id="content" style="display: none">
   117 </div>
   118 </body>
   119 </html>

mercurial