module("tinymce.plugins.Fullpage", { setupModule: function() { QUnit.stop(); tinymce.init({ selector: "textarea", plugins: "fullpage", add_unload_trigger: false, skin: 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) { window.editor = ed; QUnit.start(); } }); }, teardown: function() { editor.getBody().dir = 'ltr'; } }); test('Keep header/footer intact', function() { expect(2); function normalizeHTML(html) { return html.replace(/\s/g, ''); } editor.setContent('

Test

'); equal(normalizeHTML(editor.getContent()), '

Test

', 'Invalid HTML content is still editable.'); editor.setContent('

Test

'); equal(normalizeHTML(editor.getContent()), '

Test

', 'Header/footer is intact.'); }); test('Default header/footer', function() { expect(1); editor.setContent('

Test

'); equal(editor.getContent(), '\n\n\n\n\n

Test

\n\n', 'Invalid HTML content is still editable.'); }); test('Parse body attributes', function() { expect(9); editor.setContent('

Test

'); 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('

Test

'); ok(editor.getBody().style.color.length > 0, 'Color added to body'); editor.setContent('

Test

'); equal(editor.getBody().dir, 'rtl', 'Dir added to body'); editor.setContent('

Test

'); equal(editor.dom.getStyle(editor.getBody().firstChild, 'text-align', true), 'right', 'Styles added to iframe document'); editor.setContent('

Test

'); 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('

1

'); equal(editor.getContent({source_view: true}), '\n

1

\n'); }); test('fullpage_hide_in_source_view: false', function() { editor.settings.fullpage_hide_in_source_view = true; editor.setContent('

1

'); equal(editor.getContent({source_view: true}), '

1

'); }); test('link elements', function() { editor.setContent('

c

'); equal(editor.getContent(), '\n

c

\n'); }); test('add/remove stylesheets', function() { function hasLink(href) { var links = editor.getDoc().getElementsByTagName('link'); for (var i = 0; i < links.length; i++) { if (links[i].href.indexOf('/' + href) != -1) { return true; } } } editor.setContent('

c

'); ok(hasLink("a.css")); ok(!hasLink("b.css")); ok(!hasLink("c.css")); editor.setContent('

c

'); ok(hasLink("a.css")); ok(hasLink("b.css")); ok(!hasLink("c.css")); editor.setContent('

c

'); ok(hasLink("a.css")); ok(hasLink("b.css")); ok(hasLink("c.css")); editor.setContent('

c

'); ok(hasLink("a.css")); ok(!hasLink("b.css")); ok(!hasLink("c.css")); editor.setContent('

c

'); ok(!hasLink("a.css")); ok(!hasLink("b.css")); ok(!hasLink("c.css")); });