Skip to content
Permalink
Browse files

Merge branch 't/12110'

  • Loading branch information...
Reinmar committed Jun 26, 2014
2 parents 05f92d4 + d4928bd commit 89f4a31868ef739ff0b1dfddf3e73a64c7ede6c1
Showing with 124 additions and 76 deletions.
  1. +2 −0 CHANGES.md
  2. +5 −3 plugins/table/plugin.js
  3. +111 −70 tests/plugins/table/table.js
  4. +6 −3 tests/utils/html/compareinnerhtml.js
@@ -3,7 +3,9 @@ CKEditor 4 Changelog

## CKEditor 4.4.3

Fixed Issues:

* [#12110](http://dev.ckeditor.com/ticket/12110): Fixed: Editor crash after deleting a table. Thanks to [Alin Purcaru](https://github.com/mesmerizero)!

## CKEditor 4.4.2

@@ -45,9 +45,11 @@ CKEDITOR.plugins.add( 'table', {
if ( !table )
return;

// If the table's parent has only one child remove it as well (unless it's the body or a table cell) (#5416, #6289)
var parent = table.getParent();
if ( parent.getChildCount() == 1 && !parent.is( 'body', 'td', 'th' ) )
// If the table's parent has only one child remove it as well (unless it's a table cell, or the editable element) (#5416, #6289, #12110)
var parent = table.getParent(),
editable = editor.editable();

if ( parent.getChildCount() == 1 && !parent.is( 'td', 'th' ) && !parent.equals( editable ) )
table = parent;

var range = editor.createRange();
@@ -1,86 +1,127 @@
/* bender-tags: editor,unit */
/* bender-ckeditor-plugins: toolbar,button,entities,dialog,table */

bender.editor = { config : {} };

bender.test(
{
'test create table' : function() {
var bot = this.editorBot, tc = this;
bot.dialog( 'tableProperties', function( dialog ) {
// Check defaults.
assert.areSame( '500px', dialog.getValueOf( 'info', 'txtWidth' ) );
assert.areSame( '3', dialog.getValueOf( 'info', 'txtRows' ) );
assert.areSame( '2', dialog.getValueOf( 'info', 'txtCols' ) );

dialog.fire( 'ok' );
dialog.hide();

tc.wait( function() {
// #8337: check cursor position after hand.
var output = bender.tools.getHtmlWithSelection( bot.editor );
output = bender.tools.fixHtml( bender.tools.compatHtml( output ) );
var expected = bender.tools.compatHtml( bender.tools.getValueAsHtml( 'create-table' ) );
assert.areSame( expected, output );
}, 0 );
} );
},

'test add caption/summary': function() {
var bot = this.editorBot;
bender.tools.testInputOut( 'add-caption', function( source, expected ) {
bot.setHtmlWithSelection( source );
bot.dialog( 'tableProperties', function( dialog ) {
var captionField = dialog.getContentElement( 'info', 'txtCaption' ),
summaryField = dialog.getContentElement( 'info', 'txtSummary' );
( function() {
'use strict';

captionField.setValue( 'Caption' );
summaryField.setValue( 'Summary' );
bender.test( {
'async:init': function() {
var that = this;

dialog.fire( 'ok' );
dialog.hide();
bender.tools.setUpEditors( {
editor: {
name: 'editor1'
},
inline: {
name: 'editor2',
creator: 'inline'
}
}, function( editors, bots ) {
that.editorBots = bots;
that.editors = editors;
that.callback();
} );
},

'test create table' : function() {
var bot = this.editorBots.editor;

assert.areSame( bender.tools.compatHtml(
bender.tools.fixHtml( expected ) ),
bot.getData( true ) );
} );
} );
},

'test table populates dialog': function() {
var bot = this.editorBot;
bender.tools.testInputOut( 'read-table', function( source ) {
bot.setHtmlWithSelection( source );
bot.dialog( 'tableProperties', function( dialog ) {
// Check defaults.
assert.areSame( '500px', dialog.getValueOf( 'info', 'txtWidth' ) );
assert.areSame( '3', dialog.getValueOf( 'info', 'txtRows' ) );
assert.areSame( '2', dialog.getValueOf( 'info', 'txtCols' ) );
assert.areSame( '', dialog.getValueOf( 'info', 'txtWidth' ) );
assert.areSame( 'row', dialog.getValueOf( 'info', 'selHeaders' ) );
assert.areSame( 'caption', dialog.getValueOf( 'info', 'txtCaption' ) );

dialog.getButton( 'ok' ).click();
dialog.fire( 'ok' );
dialog.hide();

wait( function() {
// #8337: check cursor position after hand.
var output = bender.tools.getHtmlWithSelection( bot.editor );
output = bender.tools.fixHtml( bender.tools.compatHtml( output ) );
var expected = bender.tools.compatHtml( bender.tools.getValueAsHtml( 'create-table' ) );
assert.areSame( expected, output );
}, 0 );
} );
} );
},
},

'test table populates dialog - table width': function() {
var bot = this.editorBot;
bender.tools.testInputOut( 'read-table-width', function( source ) {
bot.setHtmlWithSelection( source );
bot.dialog( 'tableProperties', function( dialog ) {
assert.areSame( '50%', dialog.getValueOf( 'info', 'txtWidth' ) );
'test add caption/summary': function() {
var bot = this.editorBots.editor;
bender.tools.testInputOut( 'add-caption', function( source, expected ) {
bot.setHtmlWithSelection( source );
bot.dialog( 'tableProperties', function( dialog ) {
var captionField = dialog.getContentElement( 'info', 'txtCaption' ),
summaryField = dialog.getContentElement( 'info', 'txtSummary' );

captionField.setValue( 'Caption' );
summaryField.setValue( 'Summary' );

dialog.fire( 'ok' );
dialog.hide();

dialog.getButton( 'ok' ).click();
assert.areSame( bender.tools.compatHtml(
bender.tools.fixHtml( expected ) ),
bot.getData( true ) );
} );
} );
} );
},
},

'test delete table': function() {
var bot = this.editorBot;
bender.tools.testInputOut( 'del-table', function( source, expected ) {
bot.setHtmlWithSelection( source );
'test table populates dialog': function() {
var bot = this.editorBots.editor;
bender.tools.testInputOut( 'read-table', function( source ) {
bot.setHtmlWithSelection( source );
bot.dialog( 'tableProperties', function( dialog ) {
assert.areSame( '3', dialog.getValueOf( 'info', 'txtRows' ) );
assert.areSame( '2', dialog.getValueOf( 'info', 'txtCols' ) );
assert.areSame( '', dialog.getValueOf( 'info', 'txtWidth' ) );
assert.areSame( 'row', dialog.getValueOf( 'info', 'selHeaders' ) );
assert.areSame( 'caption', dialog.getValueOf( 'info', 'txtCaption' ) );

dialog.getButton( 'ok' ).click();
} );
} );
},

'test table populates dialog - table width': function() {
var bot = this.editorBots.editor;
bender.tools.testInputOut( 'read-table-width', function( source ) {
bot.setHtmlWithSelection( source );
bot.dialog( 'tableProperties', function( dialog ) {
assert.areSame( '50%', dialog.getValueOf( 'info', 'txtWidth' ) );

dialog.getButton( 'ok' ).click();
} );
} );
},

'test delete table wrapped in div': function() {
var bot = this.editorBots.editor;
bender.tools.testInputOut( 'del-table', function( source, expected ) {
bot.setHtmlWithSelection( source );
bot.execCommand( 'tableDelete' );
assert.isInnerHtmlMatching( '<p>@</p>', bot.editor.editable().getHtml(), 'div was removed too' );
} );
},

// #12110.
'test delete table directly in inline editor': function() {
var bot = this.editorBots.inline,
editable = bot.editor.editable();

bot.setHtmlWithSelection(
'<table>' +
'<tbody>' +
'<tr>' +
'<td></td>' +
'<td>x^x</td>' +
'</tr>' +
'</tbody>' +
'</table>' );
bot.execCommand( 'tableDelete' );
assert.areSame( expected, bot.getData( false, true ) );
} );
}
} );

assert.isTrue( CKEDITOR.document.getBody().contains( editable ), 'Editable should not be removed' );
assert.areEqual( '', bot.editor.getData() );
}
} );

} )();
@@ -5,7 +5,8 @@

var compatHtmlArgs,
originalCompatHtml = bender.tools.compatHtml,
htmlTools = bender.tools.html;
htmlTools = bender.tools.html,
filler = CKEDITOR.env.needsBrFiller ? '<br />' : '&nbsp;';

bender.tools.compatHtml = function( html, noInterWS, sortAttributes, fixZWS, fixStyles, fixNbsp ) {
compatHtmlArgs = {
@@ -55,8 +56,10 @@
'simple string': t( true, 'foo', 'foo' ),
'simple element': t( true, '<b>foo</b>', '<B>foo</B>' ),
'bogus expected, not exists': t( true, 'a@', 'a' ),
'bogus expected, exists': t( true, 'a@', 'a<br />' ),
'multiple boguses': t( true, '<p>a@</p><p>b@</p><p>c@</p>', '<p>a<br /></p><p>b</p><p>c<br /></p>' ),
// Obvious simplification - &nbsp; can't be a filler in this place, but that
// is developer's duty to use @ correctly.
'bogus expected, exists': t( true, 'a@', 'a' + filler ),
'multiple boguses': t( true, '<p>a@</p><p>b@</p><p>c@</p>', '<p>a' + filler + '</p><p>b</p><p>c' + filler + '</p>' ),
'regexp conflict [': t( true, 'ba[r', 'ba[r' ),

'markers 1 - no opts.compareSelection': t( true, 'ba[r]', 'ba[r]' ),

0 comments on commit 89f4a31

Please sign in to comment.
You can’t perform that action at this time.