/testing/web-platform/tests/html/semantics/text-level-semantics/the-data-element/data.value-001.html

https://bitbucket.org/vionika/spin.android · HTML · 66 lines · 54 code · 12 blank · 0 comment · 0 complexity · 37878cffe693a59f44eece20cb3365c1 MD5 · raw file

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>HTMLDataElement.value getting</title>
  5. <link rel="author" title="ofekd" href="mailto:ofek@outlook.com">
  6. <link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#dom-data-value">
  7. <script src=/resources/testharness.js></script>
  8. <script src=/resources/testharnessreport.js></script>
  9. </head>
  10. <body>
  11. <div id="log"></div>
  12. <div id="container">
  13. <data value=""></data>
  14. <data value="40">Forty</data>
  15. </div>
  16. <script>
  17. var newData, datasArr, container;
  18. container = document.getElementById('container')
  19. newData = document.createElement('data');
  20. newData.textContent = 'Five';
  21. newData.setAttribute('value', '5');
  22. container.appendChild(newData);
  23. datasArr = container.getElementsByTagName('data');
  24. test(function () {
  25. test(function() {
  26. assert_equals(datasArr[0].value, '');
  27. }, 'data[value] #0 getter test');
  28. test(function() {
  29. assert_equals(datasArr[1].value, '40');
  30. }, 'data[value] #1 getter test');
  31. test(function() {
  32. assert_equals(datasArr[2].value, '5');
  33. }, 'data[value] #2 getter test');
  34. }, 'Getter tests');
  35. test(function () {
  36. var i;
  37. for (i = 0; i < datasArr.length; i++) {
  38. datasArr[i].textContent = 'Twenty';
  39. datasArr[i].value = 20;
  40. test(function() {
  41. assert_equals(datasArr[i].getAttribute('value'), '20');
  42. }, 'data[value] #' + i + ' setter test');
  43. }
  44. newData = document.createElement('data');
  45. newData.textContent = 'Twenty';
  46. newData.value = '20';
  47. container.appendChild(newData);
  48. test(function() {
  49. assert_equals(datasArr[3].getAttribute('value'), '20');
  50. }, 'data[value] #3 setter test');
  51. }, 'Setter tests');
  52. </script>
  53. </body>
  54. </html>