Wed, 31 Dec 2014 07:16:47 +0100
Revert simplistic fix pending revisit of Mozilla integration attempt.
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 type="text/javascript" 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">
28 </div>
29 <pre id="test">
30 <script class="testbody" type="text/javascript">
32 /** Test for Bug 397427 **/
33 SimpleTest.waitForExplicitFinish();
35 addLoadEvent(function() {
36 is($("a").sheet.href, null, "href should be null");
37 is(typeof($("a").sheet.href), "object", "should be actual null");
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#\")",
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#\")",
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#\")",
54 "Redirect 3 did not get right base URI");
56 var ruleList = $("a").sheet.cssRules;
58 var redirHrefBase =
59 window.location.href.replace(/test_bug397427.html$/,
60 "redirect.sjs?http://example.org/tests/layout/style/test/post-");
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");
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");
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");
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 })
86 addLoadEvent(SimpleTest.finish);
87 </script>
88 </pre>
89 </body>
90 </html>