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 | /** |
michael@0 | 2 | * Test for Bug 493881: Changes to legacy HTML color properties before the BODY is loaded |
michael@0 | 3 | * should be ignored. Additionally, after BODY loads, setting any of these properties to undefined |
michael@0 | 4 | * should cause them to be returned as the string "undefined". |
michael@0 | 5 | */ |
michael@0 | 6 | |
michael@0 | 7 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 8 | |
michael@0 | 9 | var legacyProps = ["fgColor", "bgColor", "linkColor", "vlinkColor", "alinkColor"]; |
michael@0 | 10 | var testColors = ["blue", "silver", "green", "orange", "red"]; |
michael@0 | 11 | var rgbTestColors = ["rgb(255, 0, 0)", "rgb(192, 192, 192)", "rgb(0, 128, 0)", "rgb(255, 165, 0)", "rgb(255, 0, 0)"]; |
michael@0 | 12 | var idPropList = [ {id: "plaintext", prop: "color"}, |
michael@0 | 13 | {id: "body", prop: "background-color"}, |
michael@0 | 14 | {id: "nonvisitedlink", prop: "color"}, |
michael@0 | 15 | {id: "visitedlink", prop: "color"} ]; |
michael@0 | 16 | var initialValues = []; |
michael@0 | 17 | |
michael@0 | 18 | function setAndTestProperty(prop, color) { |
michael@0 | 19 | var initial = document[prop]; |
michael@0 | 20 | document[prop] = color; |
michael@0 | 21 | is(document[prop], initial, "document[" + prop + "] not ignored before body"); |
michael@0 | 22 | return initial; |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | /** |
michael@0 | 26 | * Attempt to set legacy color properties before BODY exists, and verify that such |
michael@0 | 27 | * attempts are ignored. |
michael@0 | 28 | */ |
michael@0 | 29 | for (var i = 0; i < legacyProps.length; i++) { |
michael@0 | 30 | initialValues[i] = setAndTestProperty(legacyProps[i], testColors[i]); |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | /** |
michael@0 | 34 | * After BODY loads, run some more tests. |
michael@0 | 35 | */ |
michael@0 | 36 | addLoadEvent( function() { |
michael@0 | 37 | // Verify that the legacy color properties still have their original values. |
michael@0 | 38 | for (var i = 0; i < legacyProps.length; i++) { |
michael@0 | 39 | is(document[legacyProps[i]], initialValues[i], "document[" + legacyProps[i] + "] altered after body load"); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | // Verify that legacy color properties applied before BODY are really ignored when rendering. |
michael@0 | 43 | // Save current computed style colors for later use. |
michael@0 | 44 | for (i = 0; i < idPropList.length; i++) { |
michael@0 | 45 | var style = window.getComputedStyle(document.getElementById(idPropList[i].id), null); |
michael@0 | 46 | var color = style.getPropertyValue(idPropList[i].prop); |
michael@0 | 47 | idPropList[i].initialComputedColor = color; |
michael@0 | 48 | isnot(color, rgbTestColors[i], "element rendered using before-body style"); |
michael@0 | 49 | } |
michael@0 | 50 | // XXX: Can't get links to visually activate via script events, so can't verify |
michael@0 | 51 | // that the alinkColor property was not applied. |
michael@0 | 52 | |
michael@0 | 53 | // Verify that setting legacy color props to undefined after BODY loads will cause them |
michael@0 | 54 | // to be read as the string "undefined". |
michael@0 | 55 | for (var i = 0; i < legacyProps.length; i++) { |
michael@0 | 56 | document[legacyProps[i]] = undefined; |
michael@0 | 57 | is(document[legacyProps[i]], "undefined", |
michael@0 | 58 | "Unexpected value of " + legacyProps[i] + " after setting to undefined"); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | // Verify that setting legacy color props to undefined led to result |
michael@0 | 62 | // of parsing undefined as a color. |
michael@0 | 63 | for (i = 0; i < idPropList.length; i++) { |
michael@0 | 64 | var style = window.getComputedStyle(document.getElementById(idPropList[i].id), null); |
michael@0 | 65 | var color = style.getPropertyValue(idPropList[i].prop); |
michael@0 | 66 | is(color, "rgb(0, 239, 14)", |
michael@0 | 67 | "element's style should get result of parsing undefined as a color"); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | // Mark the test as finished. |
michael@0 | 71 | setTimeout(SimpleTest.finish, 0); |
michael@0 | 72 | }); |