| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <style> | 3 <style> |
| 4 * { | 4 * { |
| 5 color: black; | 5 color: black; |
| 6 } | 6 } |
| 7 </style> | 7 </style> |
| 8 <script> | 8 <script> |
| 9 function print(message, color) | 9 function print(message, color) |
| 10 { | 10 { |
| 11 var paragraph = document.createElement("div"); | 11 var paragraph = document.createElement("div"); |
| 12 paragraph.appendChild(document.createTextNode(message)); | 12 paragraph.appendChild(document.createTextNode(message)); |
| 13 paragraph.style.fontFamily = "monospace"; | 13 paragraph.style.fontFamily = "monospace"; |
| 14 if (color) | 14 if (color) |
| 15 paragraph.style.color = color; | 15 paragraph.style.color = color; |
| 16 document.getElementById("console").appendChild(paragraph); | 16 document.getElementById("console").appendChild(paragraph); |
| 17 } | 17 } |
| 18 | 18 |
| 19 function shouldBe(a, b) | 19 function shouldBe(a, b) |
| 20 { | 20 { |
| 21 var evalA; | 21 var evalA; |
| 22 try { | 22 try { |
| 23 evalA = eval(a); | 23 evalA = eval(a); |
| 24 } catch(e) { | 24 } catch(e) { |
| 25 evalA = e; | 25 evalA = e; |
| 26 } | 26 } |
| 27 if (evalA != b) | 27 if (evalA != b) |
| 28 print("FAIL: " + a + " should be " + b + " but instead is " + evalA, "re
d"); | 28 print("FAIL: " + a + " should be " + b + " but instead is " + evalA, "re
d"); |
| 29 } | 29 } |
| 30 | 30 |
| 31 function test() | 31 function test() |
| 32 { | 32 { |
| 33 if (window.testRunner) | 33 if (window.testRunner) |
| 34 testRunner.dumpAsText(); | 34 testRunner.dumpAsText(); |
| 35 | 35 |
| 36 domParser = new DOMParser(); | 36 domParser = new DOMParser(); |
| 37 shouldBe("DOMParser.prototype.isPrototypeOf(domParser)", true); | 37 shouldBe("DOMParser.prototype.isPrototypeOf(domParser)", true); |
| 38 | 38 |
| 39 xmlHttpRequest = new XMLHttpRequest(); | 39 xmlHttpRequest = new XMLHttpRequest(); |
| 40 shouldBe("XMLHttpRequest.prototype.isPrototypeOf(xmlHttpRequest)", true); | 40 shouldBe("XMLHttpRequest.prototype.isPrototypeOf(xmlHttpRequest)", true); |
| 41 | 41 |
| 42 xmlSerializer = new XMLSerializer(); | 42 xmlSerializer = new XMLSerializer(); |
| 43 shouldBe("XMLSerializer.prototype.isPrototypeOf(xmlSerializer)", true); | 43 shouldBe("XMLSerializer.prototype.isPrototypeOf(xmlSerializer)", true); |
| 44 | 44 |
| 45 xsltProcessor = new XSLTProcessor(); | 45 xsltProcessor = new XSLTProcessor(); |
| 46 shouldBe("XSLTProcessor.prototype.isPrototypeOf(xsltProcessor)", true); | 46 shouldBe("XSLTProcessor.prototype.isPrototypeOf(xsltProcessor)", true); |
| 47 | 47 |
| 48 shouldBe("window.Document.prototype.isPrototypeOf(document)", true); | 48 shouldBe("window.Document.prototype.isPrototypeOf(document)", true); |
| 49 shouldBe("window.HTMLDocument.prototype.isPrototypeOf(document)", true); | 49 shouldBe("window.HTMLDocument.prototype.isPrototypeOf(document)", true); |
| 50 | 50 |
| 51 element = document.body; | 51 element = document.body; |
| 52 shouldBe("window.Node.prototype.isPrototypeOf(element)", true); | 52 shouldBe("window.Node.prototype.isPrototypeOf(element)", true); |
| 53 shouldBe("window.Element.prototype.isPrototypeOf(element)", true); | 53 shouldBe("window.Element.prototype.isPrototypeOf(element)", true); |
| 54 shouldBe("window.HTMLElement.prototype.isPrototypeOf(element)", true); | 54 shouldBe("window.HTMLElement.prototype.isPrototypeOf(element)", true); |
| 55 | 55 |
| 56 range = document.createRange(); | 56 range = document.createRange(); |
| 57 shouldBe("window.Range.prototype.isPrototypeOf(range)", true); | 57 shouldBe("window.Range.prototype.isPrototypeOf(range)", true); |
| 58 | 58 |
| 59 cssRule = document.styleSheets[0].cssRules[0]; | 59 cssRule = document.styleSheets[0].cssRules[0]; |
| 60 shouldBe("window.CSSRule.prototype.isPrototypeOf(cssRule)", true); | 60 shouldBe("window.CSSRule.prototype.isPrototypeOf(cssRule)", true); |
| 61 | 61 |
| 62 cssStyleDeclaration = cssRule.style; | 62 cssStyleDeclaration = cssRule.style; |
| 63 shouldBe("window.CSSStyleDeclaration.prototype.isPrototypeOf(cssStyleDeclara
tion)", true); | 63 shouldBe("window.CSSStyleDeclaration.prototype.isPrototypeOf(cssStyleDeclara
tion)", true); |
| 64 | 64 |
| 65 event = document.createEvent("MutationEvents"); | 65 event = document.createEvent("MutationEvents"); |
| 66 shouldBe("window.Event.prototype.isPrototypeOf(event)", true); | 66 shouldBe("window.Event.prototype.isPrototypeOf(event)", true); |
| 67 shouldBe("window.MutationEvent.prototype.isPrototypeOf(event)", true); | 67 shouldBe("window.MutationEvent.prototype.isPrototypeOf(event)", true); |
| 68 | 68 |
| 69 xmldoc = document.implementation.createDocument(null, null, null); | 69 xmldoc = document.implementation.createDocument(null, null, null); |
| 70 shouldBe("window.XMLDocument.prototype.isPrototypeOf(xmldoc)", true); | 70 shouldBe("window.XMLDocument.prototype.isPrototypeOf(xmldoc)", true); |
| 71 | 71 |
| 72 fragment = document.createDocumentFragment(); | 72 fragment = document.createDocumentFragment(); |
| 73 shouldBe("window.DocumentFragment.prototype.isPrototypeOf(fragment)", true); | 73 shouldBe("window.DocumentFragment.prototype.isPrototypeOf(fragment)", true); |
| 74 | 74 |
| 75 xpathevaluator = new XPathEvaluator(); | 75 xpathevaluator = new XPathEvaluator(); |
| 76 shouldBe("window.XPathEvaluator.prototype.isPrototypeOf(xpathevaluator)", tr
ue); | 76 shouldBe("window.XPathEvaluator.prototype.isPrototypeOf(xpathevaluator)", tr
ue); |
| 77 | 77 |
| 78 xpathresult = xpathevaluator.evaluate('/', document, null, 0, null); | 78 xpathresult = xpathevaluator.evaluate('/', document, null, 0, null); |
| 79 shouldBe("window.XPathResult.prototype.isPrototypeOf(xpathresult)", true); | 79 shouldBe("window.XPathResult.prototype.isPrototypeOf(xpathresult)", true); |
| 80 | 80 |
| 81 try { | 81 try { |
| 82 nodeFilter = document.createNodeIterator(document, NodeFilter.SHOW_ELEMENT
, function () {}, false).filter; | 82 nodeFilter = document.createNodeIterator(document, NodeFilter.SHOW_ELEMENT
, function () {}, false).filter; |
| 83 } catch(e) {} | 83 } catch(e) {} |
| 84 shouldBe("window.NodeFilter.prototype.isPrototypeOf(nodeFilter)", true); | 84 shouldBe("window.NodeFilter.prototype.isPrototypeOf(nodeFilter)", true); |
| 85 | 85 |
| 86 originalNodePrototype = window.Node.prototype; | 86 originalNodePrototype = window.Node.prototype; |
| 87 | 87 |
| 88 delete window.Node.prototype; | 88 deleteResult = delete window.Node.prototype; |
| 89 print("[Deleted window.Node.prototype]"); | 89 print("[Deleted window.Node.prototype]"); |
| 90 shouldBe("window.Node.prototype", originalNodePrototype); | 90 shouldBe("window.Node.prototype", originalNodePrototype); |
| 91 | 91 shouldBe("deleteResult", false); |
| 92 originalNodeConstructor = window.Node; | 92 |
| 93 originalNodeConstructor = window.Node; |
| 94 |
| 95 // Attempt to shadow window.Node with a frame named 'Node' |
| 96 var iframe = document.createElement('iframe'); |
| 97 iframe.setAttribute('name', 'Node'); |
| 98 document.body.appendChild(iframe); |
| 99 print("[Added an iframe named 'Node']"); |
| 100 shouldBe("window.Node", originalNodeConstructor); |
| 93 | 101 |
| 94 // Shadow window.Node | 102 // Shadow window.Node |
| 95 window.Node = 1; | 103 window.Node = 1; |
| 96 print("[Set window.Node = 1]"); | 104 print("[Set window.Node = 1]"); |
| 97 shouldBe("window.Node", 1); | 105 shouldBe("window.Node", 1); |
| 98 | 106 |
| 99 // Unshadow window.Node | 107 // Delete window.Node |
| 100 delete window.Node; | 108 deleteResult = delete window.Node; |
| 101 print("[Deleted window.Node]"); | 109 print("[Deleted window.Node]"); |
| 102 shouldBe("window.Node", originalNodeConstructor); | 110 shouldBe("window.Node", iframe.contentWindow); |
| 111 shouldBe("deleteResult", true); |
| 103 | 112 |
| 104 // Attempt to shadow window.Node with a frame named 'Node' | 113 // Delete window.Element |
| 105 var iframe = document.createElement('iframe'); | 114 deleteResult = delete window.Element; |
| 106 iframe.setAttribute('name', "Node"); | 115 print("[Deleted window.Element]"); |
| 107 document.body.appendChild(iframe); | 116 shouldBe("window.Element", undefined); |
| 108 print("[Added an iframe named 'Node']"); | 117 shouldBe("deleteResult", true); |
| 109 shouldBe("window.Node", originalNodeConstructor); | |
| 110 | |
| 111 } | 118 } |
| 112 </script> | 119 </script> |
| 113 </head> | 120 </head> |
| 114 | 121 |
| 115 <body onload="test();"> | 122 <body onload="test();"> |
| 116 <p>This page tests global constructor objects like window.HTMLDocument. If it pa
sses, you'll | 123 <p>This page tests global constructor objects like window.HTMLDocument. If it pa
sses, you'll |
| 117 see no lines with the text FAIL below. | 124 see no lines with the text FAIL below. |
| 118 </p> | 125 </p> |
| 119 <hr> | 126 <hr> |
| 120 <div id='console'></div> | 127 <div id='console'></div> |
| 121 | 128 |
| 122 </body> | 129 </body> |
| 123 </html> | 130 </html> |
| OLD | NEW |