113 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			HTML
		
	
	
			
		
		
	
	
			113 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			HTML
		
	
	
<!DOCTYPE html>
 | 
						|
<html>
 | 
						|
<head>
 | 
						|
<title>Fullpage plugin tests</title>
 | 
						|
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
 | 
						|
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
 | 
						|
<script src="js/qunit/reporter.js"></script>
 | 
						|
<script src="js/utils.js"></script>
 | 
						|
<script src="js/tinymce_loader.js"></script>
 | 
						|
<script>
 | 
						|
var editor;
 | 
						|
 | 
						|
QUnit.config.reorder = false;
 | 
						|
QUnit.config.autostart = false;
 | 
						|
 | 
						|
module("Fullpage plugin", {
 | 
						|
	autostart: false,
 | 
						|
	teardown: function() {
 | 
						|
		editor.getBody().dir = 'ltr';
 | 
						|
	}
 | 
						|
});
 | 
						|
 | 
						|
function normalizeHTML(html) {
 | 
						|
	return html.replace(/\s/g, '');
 | 
						|
}
 | 
						|
 | 
						|
test('Keep header/footer intact', function() {
 | 
						|
	expect(2);
 | 
						|
 | 
						|
	editor.setContent('<html><body><p>Test</p>');
 | 
						|
	equal(normalizeHTML(editor.getContent()), '<html><body><p>Test</p>', 'Invalid HTML content is still editable.');
 | 
						|
 | 
						|
	editor.setContent('<html><body><p>Test</p></body></html>');
 | 
						|
	equal(normalizeHTML(editor.getContent()), '<html><body><p>Test</p></body></html>', 'Header/footer is intact.');
 | 
						|
});
 | 
						|
 | 
						|
test('Default header/footer', function() {
 | 
						|
	expect(1);
 | 
						|
 | 
						|
	editor.setContent('<p>Test</p>');
 | 
						|
	equal(editor.getContent(), '<!DOCTYPE html>\n<html>\n<head>\n</head>\n<body>\n<p>Test</p>\n</body>\n</html>', 'Invalid HTML content is still editable.');
 | 
						|
});
 | 
						|
 | 
						|
test('Parse body attributes', function() {
 | 
						|
	expect(9);
 | 
						|
 | 
						|
	editor.setContent('<html><body><p>Test</p></body></html>');
 | 
						|
	equal(editor.getBody().style.color, '', 'No color on body.');
 | 
						|
	equal(editor.getBody().dir, '', 'No dir on body.');
 | 
						|
	equal(editor.dom.getStyle(editor.getBody().firstChild, 'display', true), 'block', 'No styles added to iframe document');
 | 
						|
 | 
						|
	editor.setContent('<html><body style="color:#FF0000"><p>Test</p></body></html>');
 | 
						|
	ok(editor.getBody().style.color.length > 0, 'Color added to body');
 | 
						|
 | 
						|
	editor.setContent('<html><body dir="rtl"><p>Test</p></body></html>');
 | 
						|
	equal(editor.getBody().dir, 'rtl', 'Dir added to body');
 | 
						|
 | 
						|
	editor.setContent('<html><head><style>p {text-align:right}</style></head><body dir="rtl"><p>Test</p></body></html>');
 | 
						|
	equal(editor.dom.getStyle(editor.getBody().firstChild, 'text-align', true), 'right', 'Styles added to iframe document');
 | 
						|
 | 
						|
	editor.setContent('<html><body><p>Test</p></body></html>');
 | 
						|
	equal(editor.getBody().style.color, '', 'No color on body.');
 | 
						|
	equal(editor.getBody().dir, '', 'No dir on body.');
 | 
						|
	equal(editor.dom.getStyle(editor.getBody().firstChild, 'display', true), 'block', 'No styles added to iframe document');
 | 
						|
});
 | 
						|
 | 
						|
test('fullpage_hide_in_source_view: false', function() {
 | 
						|
	editor.settings.fullpage_hide_in_source_view = false;
 | 
						|
	editor.setContent('<html><body><p>1</p></body></html>');
 | 
						|
	equal(editor.getContent({source_view: true}), '<html><body>\n<p>1</p>\n</body></html>');
 | 
						|
});
 | 
						|
 | 
						|
test('fullpage_hide_in_source_view: false', function() {
 | 
						|
	editor.settings.fullpage_hide_in_source_view = true;
 | 
						|
	editor.setContent('<html><body><p>1</p></body></html>');
 | 
						|
	equal(editor.getContent({source_view: true}), '<p>1</p>');
 | 
						|
});
 | 
						|
 | 
						|
tinymce.init({
 | 
						|
	mode : "exact",
 | 
						|
	elements : "elm1",
 | 
						|
	plugins : "fullpage",
 | 
						|
	add_unload_trigger : false,
 | 
						|
	valid_styles : {
 | 
						|
		'*' : 'text-align,padding-left,color,font-size,font-family,background-color,font-weight,font-style,text-decoration,float,margin,margin-top,margin-right,margin-bottom,margin-left,display'
 | 
						|
	},
 | 
						|
	indent : 0,
 | 
						|
	setup: function(ed) {
 | 
						|
		ed.on('NodeChange', false);
 | 
						|
	},
 | 
						|
	init_instance_callback : function(ed) {
 | 
						|
		editor = ed;
 | 
						|
		QUnit.start();
 | 
						|
	}
 | 
						|
});
 | 
						|
</script>
 | 
						|
</head>
 | 
						|
<body>
 | 
						|
	<h1 id="qunit-header">Fullpage plugin tests</h1>
 | 
						|
	<h2 id="qunit-banner"></h2>
 | 
						|
	<div id="qunit-testrunner-toolbar"></div>
 | 
						|
	<h2 id="qunit-userAgent"></h2>
 | 
						|
	<ol id="qunit-tests"></ol>
 | 
						|
	<div id="content">
 | 
						|
		<textarea id="elm1" name="elm1"></textarea>
 | 
						|
		<div>
 | 
						|
			<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent({format : 'raw'}));">[getRawContents]</a>
 | 
						|
			<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent());">[getContents]</a>
 | 
						|
		</div>
 | 
						|
	</div>
 | 
						|
</body>
 | 
						|
</html>
 |