summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/crash/string-replacement-outofmemory.html
blob: ff020626679360a4bbef03ce1fc3178dfced7c71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!DOCTYPE html>
<script src="../resources/js-test.js"></script>
<script>
description(
'This tests that string replacement with a large replacement string causes an out-of-memory exception. See <a href="https://bugs.webkit.org/show_bug.cgi?id=102956">bug 102956</a> for more details.'
);

function createStringWithRepeatedChar(c, multiplicity) {
    while (c.length < multiplicity)
        c += c;
    c = c.substring(0, multiplicity);
    return c;
}

var x = "1";
var y = "2";
x = createStringWithRepeatedChar(x, 1 << 12);
y = createStringWithRepeatedChar(y, (1 << 20) + 1);

shouldThrow("x.replace(/\\d/g, y)", '"Error: Out of memory"');
var successfullyParsed = true;
</script>