module( 'tinymce.html.Obsolete', {
setupModule: function() {
QUnit.stop();
tinymce.init({
selector: 'textarea',
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 = '