summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/svg/dom/SVGLengthList-xml-dom-modifications.xhtml
blob: 6fdf7b32e8ff69c4ce5d40f3baa8903b027328e9 (plain)
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
73
74
75
76
77
78
79
80
81
82
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>window.enablePixelTesting = true;</script>
<script src="../../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="200" height="200">
    <text id="text1" x="500 1000 1500" y="50">   ABC  </text>
    <text id="reference" x="50 100" y="100">   ABC  </text>
</svg>

<p id="description"></p>
<div id="console"></div>
<script type="text/javascript">
<![CDATA[
    description("This is a test how SVGLengthList reacts to XML DOM modifications.");

    var text1 = document.getElementById("text1");
    shouldBe("text1.x.baseVal.numberOfItems", "3");

    var text1XBaseValGetItem0 = text1.x.baseVal.getItem(0);
    var text1XBaseValGetItem1 = text1.x.baseVal.getItem(1);
    var text1XBaseValGetItem2 = text1.x.baseVal.getItem(2);

    shouldBe("text1XBaseValGetItem0.value", "500");
    shouldBe("text1XBaseValGetItem1.value", "1000");
    shouldBe("text1XBaseValGetItem2.value", "1500");

    debug("");
    debug("Setting x = x - 250 on all three items");
    
    text1XBaseValGetItem0.value -= 250;
    text1XBaseValGetItem1.value -= 250;
    text1XBaseValGetItem2.value -= 250;

    shouldBe("text1XBaseValGetItem0.value", "250");
    shouldBe("text1XBaseValGetItem1.value", "750");
    shouldBe("text1XBaseValGetItem2.value", "1250");

    debug("");
    debug("Now using text.setAttribute('x', '50 100')");
    text1.setAttribute("x", "50 100");

    debug("");
    debug("Assure that the wrappers still point to the OLD values");
    shouldBe("text1XBaseValGetItem0.value", "250");
    shouldBe("text1XBaseValGetItem1.value", "750");
    shouldBe("text1XBaseValGetItem2.value", "1250");

    debug("");
    debug("Assure that obtaining new wrappers will give the right NEW values");
    shouldBe("text1.x.baseVal.numberOfItems", "2");
    shouldBe("text1.x.baseVal.getItem(0).value", "50");
    shouldBe("text1.x.baseVal.getItem(1).value", "100");

    debug("");
    debug("Setting x = x + 100 on all old wrapper items");
    text1XBaseValGetItem0.value += 100;
    text1XBaseValGetItem1.value += 100;
    text1XBaseValGetItem2.value += 100;

    debug("");
    debug("Assure that the old wrappers can still be modified, but don't influence the new wrappers");
    shouldBe("text1XBaseValGetItem0.value", "350");
    shouldBe("text1XBaseValGetItem1.value", "850");
    shouldBe("text1XBaseValGetItem2.value", "1350");

    debug("");
    debug("Assure that the new wrappers stayed the same");
    shouldBe("text1.x.baseVal.numberOfItems", "2");
    shouldBe("text1.x.baseVal.getItem(0).value", "50");
    shouldBe("text1.x.baseVal.getItem(1).value", "100");

    debug("");
    debug("The test passes if you only see 'PASS' messages, and both elements on top look the same");
    debug("");
 
]]>
</script>
<script src="../../fast/js/resources/js-test-post.js"></script>
</body>
</html>