layout/style/test/test_bug397427.html

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

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

mercurial