module( 'tinymce.html.Obsolete', { setupModule: function() { QUnit.stop(); tinymce.init({ selector: 'textarea', plugins: wpPlugins, add_unload_trigger : false, skin: false, indent : false, entities : 'raw', plugins: 'media', convert_urls : false, init_instance_callback : function(ed) { window.editor = ed; QUnit.start(); } }); } }); /** * Test whether attribute exists in a HTML string * * @param html The HTML string * @param attr string|object When string, test for the first instance of attr. * When object, break up the HTML string into individual tags and test for attr in the specified tag. * Format: { tagName: 'attr1 attr2', ... } * @return bool */ function hasAttr( html, attr ) { var tagName, tags, tag, array, regex, i; if ( typeof attr === 'string' ) { return new RegExp( ' \\b' + attr + '\\b' ).test( html ); } for ( tagName in attr ) { if ( tags = html.match( new RegExp( '<' + tagName + ' [^>]+>', 'g' ) ) ) { for ( tag in tags ) { array = attr[tagName].split(' '); for ( i in array ) { regex = new RegExp( '\\b' + array[i] + '\\b' ); if ( regex.test( tags[tag] ) ) { attr[tagName] = attr[tagName].replace( regex, '' ); } } } if ( attr[tagName].replace( / +/g, '' ).length ) { return false; } } } return true; } // Ref: http://www.w3.org/TR/html5/obsolete.html, http://developers.whatwg.org/obsolete.html test('HTML elements non-conforming to HTML 5.0', function() { var testString; /* Not supported, deprecated in HTML 4.0 or earlier, and/or proprietary: applet bgsound dir frame frameset noframes isindex listing nextid noembed plaintext rb xmp basefont blink marquee multicol nobr spacer The rest are still supported in TinyMCE but "...must not be used by authors". */ expect(6); text = 'acronym'; testString = '

WWW

'; editor.setContent( testString ); equal( editor.getContent(), testString, text ); text = 'strike, converted to span'; editor.setContent( 'test' ); equal( editor.getContent(), '

test

', text ); text = 'big'; testString = '

test

'; editor.setContent( testString ); equal( editor.getContent(), testString, text ); text = 'center'; testString = '
test
'; editor.setContent( testString ); equal( editor.getContent(), testString, text ); text = 'font, converted to span'; editor.setContent( '

test

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

test

', text ); text = 'tt'; testString = '

test

'; editor.setContent( testString ); equal( editor.getContent(), testString, text ); }); test('Obsolete (but still conforming) HTML attributes', function() { var testString; expect(3); text = 'border on '; testString = '

'; editor.setContent( testString ); equal( editor.getContent(), testString, text ); text = 'Old style anchors'; testString = '

'; editor.setContent( testString ); equal( editor.getContent(), testString, text ); text = 'maxlength, size on input type="number"'; testString = '

'; editor.setContent( testString ); ok( hasAttr( editor.getContent(), { input: 'maxlength size' } ), text ); }); test('Obsolete attributes in HTML 5.0', function() { var testString, text; expect(22); text = 'charset, rev, shape, coords on elements'; testString = '

test

'; editor.setContent( testString ); ok( hasAttr( editor.getContent(), { a: 'charset rev shape coords' } ), text ); text = 'name, align, hspace, vspace on img elements'; testString = '

'; editor.setContent( testString ); ok( hasAttr( editor.getContent(), { img: 'name align hspace vspace' } ), text ); text = 'name, align, hspace, vspace, on embed elements'; testString = '

'; editor.setContent( testString ); ok( hasAttr( editor.getContent(), { embed: 'name align hspace vspace' } ), text ); text = 'archive, classid, code, codebase, codetype, declare, standby on object elements'; testString = '

'; editor.setContent( testString ); ok( hasAttr( editor.getContent(), { object: 'archive classid code codebase codetype declare standby' } ), text ); text = 'type, valuetype on param elements'; testString = '

'; editor.setContent( testString ); ok( hasAttr( editor.getContent(), { param: 'type valuetype' } ), text ); text = 'align, bgcolor, border, cellpadding, cellspacing, frame, rules, summary, width on table elements'; testString = '
test
'; editor.setContent( testString ); ok( hasAttr( editor.getContent(), { table: 'align bgcolor border cellpadding cellspacing frame rules summary width' } ), text ); text = 'align, char, charoff, valign on tbody, thead, and tfoot elements'; testString = '
testtest
'; editor.setContent( testString ); ok( hasAttr( editor.getContent(), { thead: 'align char charoff valign', tfoot: 'align char charoff valign', tbody: 'align char charoff valign' } ), text ); text = 'axis, align, bgcolor, char, charoff, height, nowrap, valign, width on td and th elements, scope on td elements'; testString = '
testtest
'; editor.setContent( testString ); ok( hasAttr( editor.getContent(), { th: 'axis align bgcolor char charoff height nowrap valign width', td: 'axis align bgcolor char charoff height nowrap valign width scope' } ), text ); text = 'align, bgcolor, char, charoff, valign on tr elements'; testString = '
test
'; editor.setContent( testString ); ok( hasAttr( editor.getContent(), { tr: 'align bgcolor char charoff valign' } ), text ); text = 'clear on br elements'; testString = '

test
test

'; editor.setContent( testString ); equal( editor.getContent(), testString, text ); text = 'align on caption elements'; testString = '
test
test
'; editor.setContent( testString ); equal( editor.getContent(), testString, text ); text = 'align, char, charoff, valign, width on col elements'; testString = '
testtest
'; editor.setContent( testString ); ok( hasAttr( editor.getContent(), { col: 'align char charoff valign width' } ), text ); text = 'align on div, h1—h6, input, legend, p elements'; testString = '
1

1

1

test
'; editor.setContent( testString ); equal( editor.getContent(), testString, text ); text = 'compact on dl elements'; testString = '
1
'; editor.setContent( testString ); equal( editor.getContent(), testString, text ); text = 'align, hspace, vspace on embed elements'; testString = '

'; editor.setContent( testString ); ok( hasAttr( editor.getContent(), { embed: 'align hspace vspace' } ), text ); text = 'align, noshade, size, width on hr elements'; testString = '
'; editor.setContent( testString ); ok( hasAttr( editor.getContent(), { hr: 'align noshade size width' } ), text ); text = 'align, frameborder, marginheight, marginwidth, scrolling on iframe elements'; testString = '

'; editor.setContent( testString ); ok( hasAttr( editor.getContent(), { iframe: 'align frameborder marginheight marginwidth scrolling' } ), text ); text = 'type on li elements'; testString = ''; editor.setContent( testString ); equal( editor.getContent(), testString, text ); text = 'align, border, hspace, vspace on object elements'; testString = '

'; editor.setContent( testString ); ok( hasAttr( editor.getContent(), { object: 'align border hspace vspace' } ), text ); text = 'compact on ol elements'; testString = '
  1. test
'; editor.setContent( testString ); equal( editor.getContent(), testString, text ); text = 'compact, type on ul elements'; testString = ''; editor.setContent( testString ); ok( hasAttr( editor.getContent(), { ul: 'compact type' } ), text ); text = 'width on pre elements'; testString = '
1
'; editor.setContent( testString ); equal( editor.getContent(), testString, text ); });