From f31e3c05a5bf4dc50a7f7f9146186a8653aeff3e Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 6 May 2013 18:13:00 +0100 Subject: Avoid stack overflows with long documents --- tests/document-to-html.tests.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js index 447e0b5..fd6ef1a 100644 --- a/tests/document-to-html.tests.js +++ b/tests/document-to-html.tests.js @@ -237,6 +237,18 @@ describe('DocumentConverter', function() { assert.equal(result.value, 'Not an image at all!'); }); }); + + test('long documents do not cause stack overflow', function() { + var paragraphs = []; + for (var i = 0; i < 1000; i++) { + paragraphs.push(paragraphOfText("Hello.")); + } + var document = new documents.Document(paragraphs); + var converter = new DocumentConverter(); + return converter.convertToHtml(document).then(function(result) { + assert.equal(result.value.indexOf("

Hello.

"), 0); + }); + }); }); function paragraphOfText(text, styleName) { -- cgit v1.2.3