| OLD | NEW |
| 1 function getObject(interface) { | 1 function getObject(interface) { |
| 2 switch(interface) { | 2 switch(interface) { |
| 3 case "Element": | 3 case "Element": |
| 4 var e = document.createElementNS("http://example.com/", "example"); | 4 var e = document.createElementNS("http://example.com/", "example"); |
| 5 assert_true(e instanceof Element); | 5 assert_true(e instanceof Element); |
| 6 assert_false(e instanceof HTMLElement); | 6 assert_false(e instanceof HTMLElement); |
| 7 assert_false(e instanceof SVGElement); | 7 assert_false(e instanceof SVGElement); |
| 8 return e; | 8 return e; |
| 9 case "HTMLElement": | 9 case "HTMLElement": |
| 10 var e = document.createElement("html"); | 10 var e = document.createElement("html"); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 function testReflect(interface, attribute) { | 51 function testReflect(interface, attribute) { |
| 52 test(function() { | 52 test(function() { |
| 53 var element = getObject(interface); | 53 var element = getObject(interface); |
| 54 assert_false(element.hasAttribute(attribute), "Initially missing"); | 54 assert_false(element.hasAttribute(attribute), "Initially missing"); |
| 55 element.setAttribute(attribute, "return"); | 55 element.setAttribute(attribute, "return"); |
| 56 assert_equals(element.getAttribute(attribute), "return", "Return same st
ring"); | 56 assert_equals(element.getAttribute(attribute), "return", "Return same st
ring"); |
| 57 assert_equals(typeof element[attribute], "function", "Convert to functio
n"); | 57 assert_equals(typeof element[attribute], "function", "Convert to functio
n"); |
| 58 element.removeAttribute(attribute); | 58 element.removeAttribute(attribute); |
| 59 }, "Reflect " + interface + "." + attribute); | 59 }, "Reflect " + interface + "." + attribute); |
| 60 } | 60 } |
| 61 function testForwardToWindow(interface, attribute) { |
| 62 test(function() { |
| 63 var element = getObject(interface); |
| 64 window[attribute] = null; |
| 65 element.setAttribute(attribute, "return"); |
| 66 assert_equals(typeof window[attribute], "function", "Convert to function
"); |
| 67 assert_equals(window[attribute], element[attribute], "Forward content at
tribute"); |
| 68 function nop() {} |
| 69 element[attribute] = nop; |
| 70 assert_equals(window[attribute], nop, "Forward IDL attribute"); |
| 71 window[attribute] = null; |
| 72 }, "Forward " + interface + "." + attribute + " to Window"); |
| 73 } |
| 61 // Object.propertyIsEnumerable cannot be used because it doesn't | 74 // Object.propertyIsEnumerable cannot be used because it doesn't |
| 62 // work with properties inherited through the prototype chain. | 75 // work with properties inherited through the prototype chain. |
| 63 function getEnumerable(interface) { | 76 function getEnumerable(interface) { |
| 64 var enumerable = {}; | 77 var enumerable = {}; |
| 65 for (var attribute in getObject(interface)) { | 78 for (var attribute in getObject(interface)) { |
| 66 enumerable[attribute] = true; | 79 enumerable[attribute] = true; |
| 67 } | 80 } |
| 68 return enumerable; | 81 return enumerable; |
| 69 } | 82 } |
| 70 var enumerableCache = {}; | 83 var enumerableCache = {}; |
| 71 function testEnumerate(interface, attribute) { | 84 function testEnumerate(interface, attribute) { |
| 72 if (!(interface in enumerableCache)) { | 85 if (!(interface in enumerableCache)) { |
| 73 enumerableCache[interface] = getEnumerable(interface); | 86 enumerableCache[interface] = getEnumerable(interface); |
| 74 } | 87 } |
| 75 test(function() { | 88 test(function() { |
| 76 assert_true(enumerableCache[interface][attribute]); | 89 assert_true(enumerableCache[interface][attribute]); |
| 77 }, "Enumerate " + interface + "." + attribute); | 90 }, "Enumerate " + interface + "." + attribute); |
| 78 } | 91 } |
| OLD | NEW |