| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../resources/js-test-pre.js"></script> |
| </head> |
| <body> |
| <div id="description"></div> |
| <div id="console"></div> |
| |
| <div id="parentNode"> |
| <div id="previousSibling"></div><div id="target"><div id="firstChild"></div><div id="lastChild"></div></div><div id="nextSibling"></div> |
| </div> |
| |
| <script> |
| description('Test LICM-ed DOMJIT function getElementById will work correctly when the function is replaced.'); |
| |
| function test(flag) { |
| var ret = 0; |
| var text = document.createTextNode('Cocoa'); |
| for (var i = 0; i < 1e4; ++i) { |
| ret = document.getElementById("target").nodeType; |
| ret = document.getElementById("target").nodeType; |
| if (i === 100 && flag) |
| document.getElementById = function (id) { return text; }; |
| ret = document.getElementById("target").nodeType; |
| ret = document.getElementById("target").nodeType; |
| } |
| return ret; |
| } |
| var result; |
| (function () { |
| for (var i = 0; i < 100; ++i) { |
| result = test(false); |
| shouldBe(`result`, `1`, true); |
| } |
| var original = document.getElementById; |
| result = test(true); |
| document.getElementById = original; |
| shouldBe(`result`, `Node.TEXT_NODE`, true); |
| }()); |
| </script> |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |