tor-browser

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

test_bug397427.html (3589B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=397427
      5 -->
      6 <head>
      7  <title>Test for Bug 397427</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     10  <style id="a">
     11    @import url("redirect.sjs?http://example.org/tests/layout/style/test/post-redirect-1.css");
     12    @import url("redirect.sjs?http://example.org/tests/layout/style/test/post-redirect-2.css");
     13    .test { color: red }
     14  </style>
     15  <link id="b" rel="stylesheet" href="http://example.com">
     16  <link id="c" rel="stylesheet" href="redirect.sjs?http://example.org/tests/layout/style/test/post-redirect-2.css">
     17  <link id="d" rel="stylesheet" href="redirect.sjs?http://example.org/tests/layout/style/test/post-redirect-3.css">
     18 </head>
     19 <body>
     20 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=397427">Mozilla Bug 397427</a>
     21 <p id="display">
     22 <span id="one" class="test"></span>
     23 <span id="two" class="test"></span>
     24 <span id="three" class="test"></span>
     25 </p>
     26 <div id="content" style="display: none">
     27  
     28 </div>
     29 <pre id="test">
     30 <script class="testbody" type="text/javascript">
     31 
     32 /** Test for Bug 397427 */
     33 SimpleTest.waitForExplicitFinish();
     34 
     35 addLoadEvent(function() {
     36  is($("a").sheet.href, null, "href should be null");
     37  is(typeof($("a").sheet.href), "object", "should be actual null");
     38 
     39  // Make sure the redirected sheets are loaded and have the right base URI
     40  is(document.defaultView.getComputedStyle($("one")).color,
     41     "rgb(0, 128, 0)", "Redirect 1 did not work");
     42  is(document.defaultView.getComputedStyle($("one")).backgroundImage,
     43     "url(\"http://example.org/tests/layout/style/test/post-redirect-1.css?1\")",
     44      "Redirect 1 did not get right base URI");
     45  is(document.defaultView.getComputedStyle($("two")).color,
     46     "rgb(0, 128, 0)", "Redirect 2 did not work");
     47  is(document.defaultView.getComputedStyle($("two")).backgroundImage,
     48     "url(\"http://example.org/tests/layout/style/test/post-redirect-2.css?1\")",
     49      "Redirect 2 did not get right base URI");
     50  is(document.defaultView.getComputedStyle($("three")).color,
     51     "rgb(0, 128, 0)", "Redirect 3 did not work");
     52  is(document.defaultView.getComputedStyle($("three")).backgroundImage,
     53     "url(\"http://example.org/tests/layout/style/test/post-redirect-3.css?1\")",
     54      "Redirect 3 did not get right base URI");
     55 
     56  var ruleList = $("a").sheet.cssRules;
     57 
     58  var redirHrefBase =
     59    window.location.href.replace(/test_bug397427.html$/,
     60      "redirect.sjs?http://example.org/tests/layout/style/test/post-");
     61 
     62  is(ruleList[0].styleSheet.href, redirHrefBase + "redirect-1.css",
     63     "Unexpected href for imported sheet");
     64  todo_is(ruleList[0].href, redirHrefBase + "redirect-1.css",
     65     "Rule href should be absolute");
     66  is(ruleList[1].styleSheet.href, redirHrefBase + "redirect-2.css",
     67     "Unexpected href for imported sheet");
     68  todo_is(ruleList[1].href, redirHrefBase + "redirect-2.css",
     69     "Rule href should be absolute");
     70 
     71  is($("b").href, "http://example.com/", "Unexpected href one");
     72  is($("b").href, $("b").sheet.href,
     73     "Should have the same href when not redirecting");
     74 
     75  is($("c").href, redirHrefBase + "redirect-2.css",
     76     "Unexpected href two");
     77  is($("c").href, $("c").sheet.href,
     78     "Should have the same href when redirecting");
     79 
     80  is($("d").href, redirHrefBase + "redirect-3.css",
     81     "Unexpected href three");
     82  is($("d").href, $("d").sheet.href,
     83     "Should have the same href when redirecting again");
     84 })
     85 
     86 addLoadEvent(SimpleTest.finish);
     87 </script>
     88 </pre>
     89 </body>
     90 </html>