1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/style/test/test_bug397427.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,91 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=397427 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 397427</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.13 + <style id="a"> 1.14 + @import url("redirect.sjs?http://example.org/tests/layout/style/test/post-redirect-1.css"); 1.15 + @import url("redirect.sjs?http://example.org/tests/layout/style/test/post-redirect-2.css"); 1.16 + .test { color: red } 1.17 + </style> 1.18 + <link id="b" rel="stylesheet" href="http://example.com"> 1.19 + <link id="c" rel="stylesheet" href="redirect.sjs?http://example.org/tests/layout/style/test/post-redirect-2.css"> 1.20 + <link id="d" rel="stylesheet" href="redirect.sjs?http://example.org/tests/layout/style/test/post-redirect-3.css"> 1.21 +</head> 1.22 +<body> 1.23 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=397427">Mozilla Bug 397427</a> 1.24 +<p id="display"> 1.25 +<span id="one" class="test"></span> 1.26 +<span id="two" class="test"></span> 1.27 +<span id="three" class="test"></span> 1.28 +</p> 1.29 +<div id="content" style="display: none"> 1.30 + 1.31 +</div> 1.32 +<pre id="test"> 1.33 +<script class="testbody" type="text/javascript"> 1.34 + 1.35 +/** Test for Bug 397427 **/ 1.36 +SimpleTest.waitForExplicitFinish(); 1.37 + 1.38 +addLoadEvent(function() { 1.39 + is($("a").sheet.href, null, "href should be null"); 1.40 + is(typeof($("a").sheet.href), "object", "should be actual null"); 1.41 + 1.42 + // Make sure the redirected sheets are loaded and have the right base URI 1.43 + is(document.defaultView.getComputedStyle($("one"), "").color, 1.44 + "rgb(0, 128, 0)", "Redirect 1 did not work"); 1.45 + is(document.defaultView.getComputedStyle($("one"), "").backgroundImage, 1.46 + "url(\"http://example.org/tests/layout/style/test/post-redirect-1.css#\")", 1.47 + "Redirect 1 did not get right base URI"); 1.48 + is(document.defaultView.getComputedStyle($("two"), "").color, 1.49 + "rgb(0, 128, 0)", "Redirect 2 did not work"); 1.50 + is(document.defaultView.getComputedStyle($("two"), "").backgroundImage, 1.51 + "url(\"http://example.org/tests/layout/style/test/post-redirect-2.css#\")", 1.52 + "Redirect 2 did not get right base URI"); 1.53 + is(document.defaultView.getComputedStyle($("three"), "").color, 1.54 + "rgb(0, 128, 0)", "Redirect 3 did not work"); 1.55 + is(document.defaultView.getComputedStyle($("three"), "").backgroundImage, 1.56 + "url(\"http://example.org/tests/layout/style/test/post-redirect-3.css#\")", 1.57 + "Redirect 3 did not get right base URI"); 1.58 + 1.59 + var ruleList = $("a").sheet.cssRules; 1.60 + 1.61 + var redirHrefBase = 1.62 + window.location.href.replace(/test_bug397427.html$/, 1.63 + "redirect.sjs?http://example.org/tests/layout/style/test/post-"); 1.64 + 1.65 + is(ruleList[0].styleSheet.href, redirHrefBase + "redirect-1.css", 1.66 + "Unexpected href for imported sheet"); 1.67 + todo_is(ruleList[0].href, redirHrefBase + "redirect-1.css", 1.68 + "Rule href should be absolute"); 1.69 + is(ruleList[1].styleSheet.href, redirHrefBase + "redirect-2.css", 1.70 + "Unexpected href for imported sheet"); 1.71 + todo_is(ruleList[1].href, redirHrefBase + "redirect-2.css", 1.72 + "Rule href should be absolute"); 1.73 + 1.74 + is($("b").href, "http://example.com/", "Unexpected href one"); 1.75 + is($("b").href, $("b").sheet.href, 1.76 + "Should have the same href when not redirecting"); 1.77 + 1.78 + is($("c").href, redirHrefBase + "redirect-2.css", 1.79 + "Unexpected href two"); 1.80 + is($("c").href, $("c").sheet.href, 1.81 + "Should have the same href when redirecting"); 1.82 + 1.83 + is($("d").href, redirHrefBase + "redirect-3.css", 1.84 + "Unexpected href three"); 1.85 + is($("d").href, $("d").sheet.href, 1.86 + "Should have the same href when redirecting again"); 1.87 +}) 1.88 + 1.89 +addLoadEvent(SimpleTest.finish); 1.90 +</script> 1.91 +</pre> 1.92 +</body> 1.93 +</html> 1.94 +