Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE HTML> | |
| 2 <title>SVGLengthList, reacts to XML DOM modifications</title> | |
|
Srirama
2016/09/17 11:27:53
nit: s/reacts/reaction
Shanmuga Pandi
2016/09/17 12:29:34
Done.
| |
| 3 <script src="../../resources/testharness.js"></script> | |
| 4 <script src="../../resources/testharnessreport.js"></script> | |
| 5 <svg width="200" height="200"> | |
| 6 <text x="500 1000 1500" y="50"> ABC </text> | |
| 7 </svg> | |
| 8 <script> | |
| 9 test(function() { | |
| 10 // This is a test how SVGLengthList reacts to XML DOM modifications. | |
| 11 | |
| 12 var text = document.querySelector("text"); | |
| 13 var list = text.x.baseVal; | |
| 14 assert_equals(list.numberOfItems, 3); | |
| 15 | |
| 16 var text1XBaseValGetItem0 = list.getItem(0); | |
| 17 var text1XBaseValGetItem1 = list.getItem(1); | |
| 18 var text1XBaseValGetItem2 = list.getItem(2); | |
| 19 | |
| 20 assert_equals(text1XBaseValGetItem0.value, 500); | |
| 21 assert_equals(text1XBaseValGetItem1.value, 1000); | |
| 22 assert_equals(text1XBaseValGetItem2.value, 1500); | |
| 23 | |
| 24 // Setting x = x - 250 on all three items. | |
| 25 | |
| 26 text1XBaseValGetItem0.value -= 250; | |
| 27 text1XBaseValGetItem1.value -= 250; | |
| 28 text1XBaseValGetItem2.value -= 250; | |
| 29 | |
| 30 assert_equals(text1XBaseValGetItem0.value, 250); | |
| 31 assert_equals(text1XBaseValGetItem1.value, 750); | |
| 32 assert_equals(text1XBaseValGetItem2.value, 1250); | |
| 33 | |
| 34 // Now using text.setAttribute('x', '50 100'). | |
| 35 text.setAttribute("x", "50 100"); | |
| 36 | |
| 37 // Assure that the wrappers still point to the OLD values. | |
| 38 assert_equals(text1XBaseValGetItem0.value, 250); | |
| 39 assert_equals(text1XBaseValGetItem1.value, 750); | |
| 40 assert_equals(text1XBaseValGetItem2.value, 1250); | |
| 41 | |
| 42 // Assure that obtaining new wrappers will give the right NEW values. | |
| 43 assert_equals(list.numberOfItems, 2); | |
| 44 assert_equals(list.getItem(0).value, 50); | |
| 45 assert_equals(list.getItem(1).value, 100); | |
| 46 | |
| 47 // Setting x = x + 100 on all old wrapper items. | |
| 48 text1XBaseValGetItem0.value += 100; | |
| 49 text1XBaseValGetItem1.value += 100; | |
| 50 text1XBaseValGetItem2.value += 100; | |
| 51 | |
| 52 // Assure that the old wrappers can still be modified, but don't influence the new wrappers. | |
| 53 assert_equals(text1XBaseValGetItem0.value, 350); | |
| 54 assert_equals(text1XBaseValGetItem1.value, 850); | |
| 55 assert_equals(text1XBaseValGetItem2.value, 1350); | |
| 56 | |
| 57 // Assure that the new wrappers stayed the same. | |
| 58 assert_equals(list.numberOfItems, 2); | |
| 59 assert_equals(list.getItem(0).value, 50); | |
| 60 assert_equals(list.getItem(1).value, 100); | |
| 61 }); | |
| 62 </script> | |
| OLD | NEW |