File: test_bug493881.js

package info (click to toggle)
wine-gecko-2.21 2.21%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 646,272 kB
  • ctags: 630,086
  • sloc: cpp: 2,895,786; ansic: 1,502,970; python: 156,675; asm: 115,373; java: 111,421; sh: 63,309; xml: 62,872; makefile: 58,685; perl: 19,182; objc: 3,461; yacc: 2,051; lex: 979; pascal: 929; exp: 449; php: 244; lisp: 228; awk: 211; sed: 26; csh: 21; ada: 16; ruby: 3
file content (72 lines) | stat: -rw-r--r-- 3,042 bytes parent folder | download | duplicates (20)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/** 
 * Test for Bug 493881: Changes to legacy HTML color properties before the BODY is loaded
 * should be ignored. Additionally, after BODY loads, setting any of these properties to undefined 
 * should cause them to be returned as the string "undefined".
 */

SimpleTest.waitForExplicitFinish();

var legacyProps = ["fgColor", "bgColor", "linkColor", "vlinkColor", "alinkColor"];
var testColors = ["blue", "silver", "green", "orange", "red"];
var rgbTestColors = ["rgb(255, 0, 0)", "rgb(192, 192, 192)", "rgb(0, 128, 0)", "rgb(255, 165, 0)", "rgb(255, 0, 0)"];
var idPropList = [ {id: "plaintext", prop: "color"},
                   {id: "body", prop: "background-color"},
                   {id: "nonvisitedlink", prop: "color"},
                   {id: "visitedlink", prop: "color"} ];
var initialValues = [];

function setAndTestProperty(prop, color) {
  var initial = document[prop];
  document[prop] = color;
  is(document[prop], initial, "document[" + prop + "] not ignored before body");
  return initial;
}

/**
 * Attempt to set legacy color properties before BODY exists, and verify that such
 * attempts are ignored.
 */
for (var i = 0; i < legacyProps.length; i++) {
  initialValues[i] = setAndTestProperty(legacyProps[i], testColors[i]);
}

/**
 * After BODY loads, run some more tests.
 */
addLoadEvent( function() {
  // Verify that the legacy color properties still have their original values.
  for (var i = 0; i < legacyProps.length; i++) {
    is(document[legacyProps[i]], initialValues[i], "document[" + legacyProps[i] + "] altered after body load");
  }
  
  // Verify that legacy color properties applied before BODY are really ignored when rendering.
  // Save current computed style colors for later use.
  for (i = 0; i < idPropList.length; i++) {
    var style = window.getComputedStyle(document.getElementById(idPropList[i].id), null);
    var color = style.getPropertyValue(idPropList[i].prop);
    idPropList[i].initialComputedColor = color;
    isnot(color, rgbTestColors[i], "element rendered using before-body style");
  }
  // XXX: Can't get links to visually activate via script events, so can't verify
  // that the alinkColor property was not applied.
  
  // Verify that setting legacy color props to undefined after BODY loads will cause them
  // to be read as the string "undefined".
  for (var i = 0; i < legacyProps.length; i++) {
    document[legacyProps[i]] = undefined;
    is(document[legacyProps[i]], "undefined", 
      "Unexpected value of " + legacyProps[i] + " after setting to undefined");
  }
  
  // Verify that setting legacy color props to undefined led to result
  // of parsing undefined as a color.
  for (i = 0; i < idPropList.length; i++) {
    var style = window.getComputedStyle(document.getElementById(idPropList[i].id), null);
    var color = style.getPropertyValue(idPropList[i].prop);
    is(color, "rgb(0, 239, 14)", 
      "element's style should get result of parsing undefined as a color");
  }

  // Mark the test as finished.
  setTimeout(SimpleTest.finish, 0);
});