OLD | NEW |
(Empty) | |
| 1 // http://whatwg.org/html#reflecting-content-attributes-in-idl-attributes |
| 2 // http://whatwg.org/html#rules-for-parsing-non-negative-integers |
| 3 function testUnsignedLong(interface, createElement, attribute) |
| 4 { |
| 5 test(function() |
| 6 { |
| 7 var element = createElement(); |
| 8 |
| 9 assert_equals(element[attribute], 0); |
| 10 |
| 11 function t(input, output) |
| 12 { |
| 13 element.setAttribute(attribute, input); |
| 14 assert_equals(element[attribute], output); |
| 15 } |
| 16 |
| 17 t("", 0); |
| 18 t("0", 0); |
| 19 t("1", 1); |
| 20 t("2147483647", 2147483647); |
| 21 t("2147483648", 0); |
| 22 t("-1", 0); |
| 23 t("+42", 42); |
| 24 t(" 42", 42); |
| 25 t("42!", 42); |
| 26 }, "get " + interface + "." + attribute); |
| 27 |
| 28 test(function() |
| 29 { |
| 30 var element = createElement(); |
| 31 |
| 32 assert_false(element.hasAttribute(attribute)); |
| 33 |
| 34 function t(input, output) |
| 35 { |
| 36 element[attribute] = input; |
| 37 assert_equals(element.getAttribute(attribute), output); |
| 38 } |
| 39 |
| 40 t(0, "0"); |
| 41 t(2147483647, "2147483647"); |
| 42 // per spec: |
| 43 //t(2147483648, "0"); |
| 44 //t(-1, "0"); |
| 45 // per implementation <http://crbug.com/316122>: |
| 46 t(2147483648, "2147483648"); |
| 47 t(-1, "4294967295"); |
| 48 }, "set " + interface + "." + attribute); |
| 49 } |
OLD | NEW |