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