Ticket #3457: testWhitespaceTextarea.html

File testWhitespaceTextarea.html, 1.5 KB (added by Alfonso Martínez de Lizarrondo, 11 years ago)

testcase

Line 
1<!DOCTYPE html>
2<!--
3Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
4For licensing, see LICENSE.html or http://ckeditor.com/license
5-->
6<html>
7<head>
8        <title>testcase</title>
9        <meta content="text/html; charset=utf-8" http-equiv="content-type" />
10        <script type="text/javascript" src="../ckeditor_source.js"></script>
11
12</head>
13<body>
14        <h1 class="samples">
15                Testcase for handling of whitespace at start of textareas using innerHTML
16        </h1>
17
18<script>
19function encode(text)
20{
21        text = text.replace( />/g, '&gt;');
22        text = text.replace( /</g, '&lt;');
23        return text;
24}
25
26
27performTest('New line at start', '<textarea>\nsome text</textarea>');
28performTest('Whitespace at start', '<textarea> some text</textarea>');
29
30performTest('New line at end', '<textarea>some text\n</textarea>');
31performTest('Whitespace at end', '<textarea>some text </textarea>');
32
33function performTest(title, sampleData)
34{
35        document.write('<p style="white-space:pre">' + title + '. Original data:<br>' + encode(sampleData) + '</p>')
36
37var div = new CKEDITOR.dom.element( 'div' );
38div.setHtml( sampleData );
39var data = div.getHtml();
40data = data.toLowerCase(); // not interested about IE's casing issues
41
42if ( sampleData != data)
43        document.write('<p style="background-color:red">Test failed.</p><p style="white-space:pre">Returned data:<br>' + encode(data) + '</p>')
44else
45        document.write('<p style="background-color:green">Test OK</p>')
46}
47
48</script>
49</body>
50</html>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy