Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=713564
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for Bug 713564</title>
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
12 <!-- Load the variable stylesheet, which changes the color of #content. -->
13 <link rel="stylesheet" type="text/css" href="variable_style_sheet.sjs"/>
15 <script type="application/javascript">
17 function insertLinkToVarSSAndRun(callback) {
18 var ss = document.createElement("link");
19 ss.rel = "stylesheet";
20 ss.type = "text/css";
21 ss.href = "variable_style_sheet.sjs";
22 document.getElementsByTagName("head")[0].appendChild(ss);
23 ss.addEventListener("load", callback);
24 }
26 /** Test for Bug 713564 **/
28 // Then you link to that sheet, remove the link from the DOM, insert a new link to
29 // the same url and check that there was no new access, then call our new method,
30 // insert _another_ <link> to the same url, and check that this time we hit the
31 // server.
32 SimpleTest.waitForExplicitFinish();
34 function do_test() {
35 var var_sheet = document.getElementsByTagName("link")[1];
36 var head = document.getElementsByTagName("head")[0];
37 var content = document.getElementById("content");
38 var var_sheet_url = var_sheet.href;
40 var previousBgColor = window.getComputedStyle(content).
41 getPropertyValue("background-color");
42 var_sheet.parentNode.removeChild(var_sheet);
43 insertLinkToVarSSAndRun(function() {
44 is(window.getComputedStyle(content).getPropertyValue("background-color"),
45 previousBgColor,
46 "Sheet should still be the same.");
48 // Obsolete sheet
49 try {
50 SpecialPowers.wrap(document).obsoleteSheet(var_sheet_url);
51 } catch (e) {
52 ok(false, "obsoleteSheet should not raise an error on valid URL.");
53 }
54 insertLinkToVarSSAndRun(function() {
55 isnot(window.getComputedStyle(content).getPropertyValue("background-color"),
56 previousBgColor,
57 "Sheet should change after obsoleted and reinserted.");
58 SimpleTest.finish();
59 });
60 });
61 // obsoleteSheet should throw with invalid input:
62 try {
63 SpecialPowers.wrap(document).obsoleteSheet("");
64 ok(false, "obsoleteSheet should throw with empty string.");
65 } catch (e) {
66 ok(true, "obsoleteSheet throws with empty string.");
67 }
68 try {
69 SpecialPowers.wrap(document).obsoleteSheet("foo");
70 ok(false, "obsoleteSheet should throw with invalid URL.");
71 } catch (e) {
72 ok(true, "obsoleteSheet throws with invalid URL.");
73 }
74 try {
75 SpecialPowers.wrap(document).obsoleteSheet("http://www.mozilla.org");
76 ok(true, "obsoleteSheet should not throw with valid URL.");
77 } catch (e) {
78 ok(false, "obsoleteSheet throws with valid URL.");
79 }
80 }
82 </script>
83 </head>
84 <body onload="do_test();">
85 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=713564">Mozilla Bug 713564</a>
86 <p id="display"></p>
87 <div id="content">
88 <br>
89 <br>
90 </div>
91 <pre id="test">
92 </pre>
93 </body>
94 </html>