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