| <html> |
| <head> |
| <script> |
| function print(message, color) |
| { |
| var paragraph = document.createElement("div"); |
| paragraph.appendChild(document.createTextNode(message)); |
| paragraph.style.fontFamily = "monospace"; |
| if (color) |
| paragraph.style.color = color; |
| document.getElementById("console").appendChild(paragraph); |
| } |
| |
| function shouldBe(a, b) |
| { |
| var evalA; |
| try { |
| evalA = eval(a); |
| } catch(e) { |
| evalA = e; |
| } |
| |
| if (evalA == b) |
| print("PASS: " + a + " should be " + b + " and is.", "green"); |
| else |
| print("FAIL: " + a + " should be " + b + " but instead is " + evalA + ".", "red"); |
| } |
| |
| function test() |
| { |
| if (window.testRunner) |
| testRunner.dumpAsText(); |
| |
| shouldBe("Object.prototype.isPrototypeOf(window.DOMException)", true); |
| shouldBe("Object.prototype.isPrototypeOf(window.Option)", true); |
| |
| div = document.createElement('div'); |
| div.style.color = "rgb(0, 0, 0)"; |
| cssValue = div.style.getPropertyCSSValue('color'); // actually a CSSPrimitiveValue |
| shouldBe("Object.prototype.isPrototypeOf(cssValue)", true); |
| |
| rgbColor = div.style.getPropertyCSSValue('color').getRGBColorValue(); |
| shouldBe("Object.prototype.isPrototypeOf(rgbColor)", true); |
| |
| div.style.clip = "rect(0, 0, 0, 0)"; |
| rect = div.style.getPropertyCSSValue('clip').getRectValue(); |
| shouldBe("Object.prototype.isPrototypeOf(rect)", true); |
| |
| styleElement = document.createElement('style'); |
| styleElement.appendChild(document.createTextNode("* {}")); |
| headElement = document.getElementsByTagName('head')[0]; |
| headElement.appendChild(styleElement); |
| styleSheetList = document.styleSheets; |
| shouldBe("Object.prototype.isPrototypeOf(styleSheetList)", true); |
| |
| styleSheet = styleSheetList[0]; |
| shouldBe("Object.prototype.isPrototypeOf(styleSheet)", true); |
| |
| cssRule = styleSheet.cssRules[0]; |
| shouldBe("Object.prototype.isPrototypeOf(cssRule)", true); |
| |
| nodeList = document.getElementsByTagName('html'); |
| shouldBe("Object.prototype.isPrototypeOf(nodeList)", true); |
| |
| var form = document.createElement('form'); |
| form.name = 'myForm'; |
| document.body.appendChild(form); |
| document.body.appendChild(form.cloneNode(true)); |
| namedNodesCollection = document.forms.myForm; |
| shouldBe("Object.prototype.isPrototypeOf(namedNodesCollection)", true); |
| } |
| </script> |
| </head> |
| |
| <body onload="test();"> |
| <p>This test checks some DOM object prototypes that WebKit has gotten wrong in the past. |
| If the test passes, you'll see a series of 'PASS' messages below.</p> |
| <hr> |
| |
| <div id='console'></div> |
| |
| </body> |
| </html> |