blob: 9ea1e302e1053d0f50fd02c41ef47207f6aff4b2 [file] [log] [blame]
<!doctype>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<div id="textContent"></div>
<script>
if (window.testRunner)
testRunner.dumpAsText();
// Put text content on the page with 2^16 'a' characters.
textContent.append(document.createTextNode('a'.repeat(2**15)));
textContent.append(document.createTextNode('a'.repeat(2**15)));
shouldBe("textContent.innerText.length", "2**16");
// Verify that find fails if no match is found.
window.getSelection().removeAllRanges();
shouldBeFalse("window.find('b')");
// Verify that find succeeds for a small string.
window.getSelection().removeAllRanges();
shouldBeTrue("window.find('a'.repeat(2**5))");
// Verify that find succeeds just below the limit.
window.getSelection().removeAllRanges();
shouldBeTrue("window.find('a'.repeat(2**16 - 1))");
// Verify that find fails when reaching WebKit's hardcoded limit.
window.getSelection().removeAllRanges();
shouldBeFalse("window.find('a'.repeat(2**16))");
// Verify that very long string does not cause out-of-memory crash.
window.getSelection().removeAllRanges();
shouldBeFalse("window.find('a'.repeat(2**30))");
document.body.removeChild(textContent);
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>