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