Skip to content
Permalink
Browse files

Merge branch 't/13730'

  • Loading branch information...
Reinmar committed Sep 21, 2015
2 parents 47e6f7f + fec0b25 commit 6f07d5da2263266de188c7abb2238262b99fda16
@@ -6,6 +6,7 @@ CKEditor 4 Changelog
New Features:

* [#13632](http://dev.ckeditor.com/ticket/13632): Introduce error logging mechanism.
* [#13730](http://dev.ckeditor.com/ticket/13730): Switch to the new error logging mechanism.

Fixed Issues:

@@ -2714,9 +2714,7 @@ CKEDITOR.dom.range = function( root ) {
var isRootAscendantOrSelf = this.root.equals( startContainer ) || this.root.contains( startContainer );

if ( !isRootAscendantOrSelf ) {
window.console && console.log && console.log( // jshint ignore:line
'[CKEDITOR.dom.range.setStart] Element', startContainer, 'is not a descendant of root', this.root
);
CKEDITOR.warn( 'range-startcontainer', { startContainer: startContainer, root: this.root } );
}
// %REMOVE_END%
this.startContainer = startContainer;
@@ -2734,9 +2732,7 @@ CKEDITOR.dom.range = function( root ) {
var isRootAscendantOrSelf = this.root.equals( endContainer ) || this.root.contains( endContainer );

if ( !isRootAscendantOrSelf ) {
window.console && console.log && console.log( // jshint ignore:line
'[CKEDITOR.dom.range.setEnd] Element', endContainer, 'is not a descendant of root', this.root
);
CKEDITOR.warn( 'range-endcontainer', { endContainer: endContainer, root: this.root } );
}
// %REMOVE_END%
this.endContainer = endContainer;
@@ -545,9 +545,7 @@

if ( requires && ( match = requires.match( removeRegex ) ) ) {
while ( ( name = match.pop() ) ) {
CKEDITOR.tools.setTimeout( function( name, pluginName ) {
throw new Error( 'Plugin "' + name.replace( ',', '' ) + '" cannot be removed from the plugins list, because it\'s required by "' + pluginName + '" plugin.' );
}, 0, null, [ name, pluginName ] );
CKEDITOR.error( 'editor-plugin-required', { plugin: name.replace( ',', '' ), requiredBy: pluginName } );
}
}

@@ -121,6 +121,5 @@ CKEDITOR.on( 'log', function( evt ) {
console[ type ]( prefix + errorCode );
}

// TODO: Add proper info and documentation url.
console[ type ]( prefix + 'For more information go to http://docs.ckeditor.com/' );
console[ type ]( prefix + 'For more information go to http://docs.ckeditor.com/#!/guide/dev_errors-section-' + errorCode );
}, null, null, 999 );
@@ -71,7 +71,7 @@ CKEDITOR.resourceManager.prototype = {
*/
add: function( name, definition ) {
if ( this.registered[ name ] )
throw '[CKEDITOR.resourceManager.add] The resource name "' + name + '" is already registered.';
throw new Error( '[CKEDITOR.resourceManager.add] The resource name "' + name + '" is already registered.' );

var resource = this.registered[ name ] = definition || {};
resource.name = name;
@@ -208,8 +208,8 @@ CKEDITOR.resourceManager.prototype = {

CKEDITOR.scriptLoader.load( urls, function( completed, failed ) {
if ( failed.length ) {
throw '[CKEDITOR.resourceManager.load] Resource name "' + urlsNames[ failed[ 0 ] ].join( ',' ) +
'" was not found at "' + failed[ 0 ] + '".';
throw new Error( '[CKEDITOR.resourceManager.load] Resource name "' + urlsNames[ failed[ 0 ] ].join( ',' ) +
'" was not found at "' + failed[ 0 ] + '".' );
}

for ( var i = 0; i < completed.length; i++ ) {
@@ -1669,11 +1669,9 @@

removeHiddenSelectionContainer( editor );
}
// jshint ignore:start
else { // %REMOVE_LINE%
window.console && console.log( '[CKEDITOR.dom.selection.reset] Wrong selection instance resets fake selection.' ); // %REMOVE_LINE%
} // %REMOVE_LINE%
// jshint ignore:end
else {
CKEDITOR.warn( 'selection-fake-reset' );
}
}

this.rev = nextRev++;
@@ -2066,9 +2064,7 @@
if ( bookmarks.isFake ) {
node = ranges[ 0 ].getEnclosedNode();
if ( !node || node.type != CKEDITOR.NODE_ELEMENT ) {
// %REMOVE_START%
window.console && console.log( '[CKEDITOR.dom.selection.selectBookmarks] Selection is no longer fake.' ); // jshint ignore:line
// %REMOVE_END%
CKEDITOR.warn( 'selection-not-fake' );
bookmarks.isFake = 0;
}
}
@@ -57,10 +57,7 @@
widgetDef = CKEDITOR.plugins.autoEmbed.getWidgetDefinition( editor, href );

if ( !widgetDef ) {
window.console && window.console.log(
'[CKEDITOR.plugins.autoEmbed] Incorrect config.autoEmbed_widget value. ' +
'No widget definition found.'
);
CKEDITOR.warn( 'autoembed-no-widget-def' );
return;
}

@@ -218,11 +218,7 @@

// Check if widget is still valid.
if ( !that.editor.widgets.instances[ that.id ] ) {
// %REMOVE_START%
window.console && console.log && console.log( // jshint ignore:line
'[CKEDITOR.plugins.embedBase.baseDefinition.loadContent] Widget no longer belongs to current editor\'s widgets list.'
);
// %REMOVE_END%
CKEDITOR.warn( 'embedbase-widget-invalid' );

if ( request.task ) {
request.task.done();
@@ -88,7 +88,7 @@
} catch ( err ) {
// Response parsing error.
data.message = fileLoader.lang.filetools.responseError;
window.console && window.console.log( xhr.responseText );
CKEDITOR.warn( 'filetools-response-error', { responseText: xhr.responseText } );

evt.cancel();
}
@@ -17,11 +17,10 @@
hidpi: true, // %REMOVE_LINE_CORE%

init: function( editor ) {
var cls = editor.config.mathJaxClass || 'math-tex',
docsUrl = 'http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-mathJaxLib';
var cls = editor.config.mathJaxClass || 'math-tex';

if ( !editor.config.mathJaxLib && ( window.console && window.console.log ) ) {
window.console.log( 'Error: config.mathJaxLib property is not set. For more information visit: ', docsUrl );
if ( !editor.config.mathJaxLib ) {
CKEDITOR.error( 'mathjax-no-config' );
}

editor.widgets.add( 'mathjax', {
@@ -27,10 +27,7 @@
uploadUrl = fileTools.getUploadUrl( editor.config, 'image' );

if ( !uploadUrl ) {
window.console && window.console.log(
'Error: Upload URL for the Upload Image feature was not defined. ' +
'For more information see: http://docs.ckeditor.com/#!/guide/dev_file_upload'
);
CKEDITOR.error( 'uploadimage-config' );
return;
}

@@ -15,23 +15,7 @@ bender.test(
},

'errors thrown when required plugin specified in removePlugins list': function() {
var originalSetTimeout = window.setTimeout,
errors = [];

// Override native setTimeout to catch all errors.
window.setTimeout = function( fn, timeout ) {
originalSetTimeout( function() {
try {
fn.apply( this, Array.prototype.slice.call( arguments ) );
} catch ( err ) {
errors.push( err );

// Do not fail silently on other errors.
if ( !err.message || !err.message.match( /^Plugin "\w+" cannot be removed/ ) )
throw err;
}
}, timeout );
};
var log = sinon.stub( CKEDITOR, 'error' );

CKEDITOR.plugins.add( 'errorplugin1', {
requires: 'errorplugin3,errorplugin2'
@@ -53,7 +37,7 @@ bender.test(
}
} );

originalSetTimeout( function() {
setTimeout( function() {
CKEDITOR.replace( 'errortest', {
plugins: 'wysiwygarea,errorplugin1,errorplugin3',
extraPlugins: 'errorplugin2',
@@ -62,15 +46,17 @@ bender.test(
on: {
instanceReady: function( evt ) {
resume( function() {
// Reset overriden setTimeout.
window.setTimeout = originalSetTimeout;

log.restore();

// plugin 3 reqed by plugin 1 and plugins 4 & 3 reqed by plugin 2.
assert.areEqual( 3, errors.length );
assert.isTrue( log.calledThrice, 'CKEDITOR.error should be called three times.' );

var err;
while ( ( err = errors.pop() ) )
assert.isMatching( /^Plugin "\w+" cannot be removed/, err.message );
var call;
for ( var i = 0; i < log.callCount; i++ ) {
call = log.getCall( i );
assert.areEqual( 'editor-plugin-required', call.args[ 0 ], 'Required plugin error should be logged.' );
}

// Plugins are corretly inited.
assert.isTrue( evt.editor.plugin3Inited );
@@ -83,4 +69,4 @@ bender.test(

wait();
}
} );
} );
@@ -170,7 +170,7 @@
},

'test fileUploadResponse event': function() {
var log = window.console && sinon.stub( window.console, 'log' );
var log = sinon.stub( CKEDITOR, 'warn' );

var message = 'Not a JSON';
var error = 'Error.';
@@ -192,10 +192,10 @@

this.editor.fire( 'fileUploadResponse', data );

log && log.restore();
log.restore();

assert.areEqual( data.message, error );
assert.isTrue( log ? log.calledWith( message ) : true );
assert.areEqual( message, log.firstCall.args[ 1 ].responseText, 'responseText should match' );
}
} );
} )();

0 comments on commit 6f07d5d

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