Skip to content

Commit

Permalink
Merge branch 't/9137'
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Aug 28, 2014
2 parents bea9cb8 + c555cd0 commit c9a0a2a
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 37 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -6,6 +6,7 @@ CKEditor 4 Changelog
Fixed Issues:

* [#10804](http://dev.ckeditor.com/ticket/10804): Fixed: `CKEDITOR_GETURL` isn't used with some plugins it should be used. Thanks to [Thomas Andraschko](https://github.com/tandraschko)!
* [#9137](http://dev.ckeditor.com/ticket/9137): Fixed: `base` tag is not created when `head` has an attribute. Thanks to [naoki.fujikawa](https://github.com/naoki-fujikawa)!
* [#12315](http://dev.ckeditor.com/ticket/12315): Fixed: Marked [`config.autoParagraph`](http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-autoParagraph) as deprecated.
* [#12113](http://dev.ckeditor.com/ticket/12113): Fixed: Code snippet should be presented in elements path as "codesnippet".
* [#12311](http://dev.ckeditor.com/ticket/12311): Fixed: Remove format should also remove `<cite>` elements.
Expand Down
4 changes: 2 additions & 2 deletions plugins/wysiwygarea/plugin.js
@@ -1,4 +1,4 @@
/**
/**
* @license Copyright (c) 2003-2014, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or http://ckeditor.com/license
*/
Expand Down Expand Up @@ -401,7 +401,7 @@

// The base must be the first tag in the HEAD, e.g. to get relative
// links on styles.
baseTag && ( data = data.replace( /<head>/, '$&' + baseTag ) );
baseTag && ( data = data.replace( /<head[^>]*?>/, '$&' + baseTag ) );

// Inject the extra stuff into <head>.
// Attention: do not change it before testing it well. (V2)
Expand Down
134 changes: 99 additions & 35 deletions tests/plugins/wysiwygarea/fullpage.js
@@ -1,42 +1,106 @@
/* bender-tags: editor,unit */
/* bender-ckeditor-plugins: basicstyles,toolbar */

// Editor styles must be removed before the comparison occurs.
// It is due the fact that different browsers use different styles.
// The following regex handles the problem.
var removeStyle = /<style[\s\S]+style>/g;

bender.editor = {
creator: 'replace',
config: {
docType: '',
contentsLangDirection: 'ltr',
fullPage: true,
contentsCss: []
( function() {
'use strict';

// Editor styles must be removed before the comparison occurs.
// It is due the fact that different browsers use different styles.
// The following regex handles the problem.
var removeStyle = /<style[\s\S]+style>/g;

function getBaseElement( editor ) {
var base = editor.document.getHead().getFirst();

// On IE we add the fixDomain script (see document#write).
// On IE8 also the title lands before the base tag (magic...).
if ( CKEDITOR.env.ie && base.is( { script: 1, title: 1 } ) )
base = base.getNext();
if ( CKEDITOR.env.ie && base.is( { script: 1, title: 1 } ) )
base = base.getNext();

return base;
}
};

bender.test(
{
'test load full-page data' : function() {
var bot = this.editorBot;
bender.tools.testInputOut( 'fullpage1', function( source, expected ) {
bot.setData( source, function() {
assert.areSame( bender.tools.compatHtml( expected ),
bot.getData( true ).replace( removeStyle, '' ) ); // remove styles from data

bender.test( {
'async:init': function() {
var that = this;

bender.tools.setUpEditors( {
editor: {
name: 'editor1',
creator: 'replace',
config: {
docType: '',
contentsLangDirection: 'ltr',
fullPage: true,
contentsCss: []
}
},
editor_basehref: {
name: 'editor2',
creator: 'replace',
config: {
fullPage: true,
baseHref: '/foo/bar/404/',
allowedContent: true
}
},
}, function( editors, bots ) {
that.editorBots = bots;
that.editors = editors;
that.callback();
} );
} );
},

'test load full-page data (with doctype)': function() {
var bot = this.editorBot;
bender.tools.testInputOut( 'fullpage2', function( source, expected ) {
bot.setData( source, function() {
assert.areSame( bender.tools.compatHtml( expected ),
bot.getData( true, true ).replace( removeStyle, '' ) ); // remove styles from data
},

'test load full-page data' : function() {
var bot = this.editorBots.editor;
bender.tools.testInputOut( 'fullpage1', function( source, expected ) {
bot.setData( source, function() {
assert.areSame( bender.tools.compatHtml( expected ),
bot.getData( true ).replace( removeStyle, '' ) ); // remove styles from data
} );
} );
} );
}
} );
},

'test load full-page data (with doctype)': function() {
var bot = this.editorBots.editor;
bender.tools.testInputOut( 'fullpage2', function( source, expected ) {
bot.setData( source, function() {
assert.areSame( bender.tools.compatHtml( expected ),
bot.getData( true, true ).replace( removeStyle, '' ) ); // remove styles from data
} );
} );
},

'test base tag is placed before every element it affects in the head': function() {
var bot = this.editorBots.editor_basehref;

bot.setData( '<p>foo</p>', function() {
var base = getBaseElement( bot.editor );

assert.areSame( 'base', base.getName() );
assert.isMatching( /\/foo\/bar\/404\/$/, base.getAttribute( 'href' ) );
} );
},

// #9137
'test base tag is correctly added when head has an attribute': function() {
var bot = this.editorBots.editor_basehref;

bot.setData( '<head foo="xxx"><title>x</title><body><p>foo</p></body>', function() {
var base = getBaseElement( bot.editor );

assert.areSame( 'base', base.getName() );
assert.isMatching( /\/foo\/bar\/404\/$/, base.getAttribute( 'href' ) );

// For some (unrelated) reaons on IE attributes are left.
if ( !CKEDITOR.env.ie ) {
// Common problem - ACF :P
assert.isTrue( base.getParent().hasAttribute( 'foo' ), 'attribute was not lost' );
}
} );
}
} );

//]]>
} )();

0 comments on commit c9a0a2a

Please sign in to comment.