-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removed memory leak caused by CKEDITOR.filter.instances #1770
+332
−86
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f7e709d
Added filter owning editor option.
jacekbogdanski 72f1e87
Binded editor destroy with plugin filters.
jacekbogdanski 5caa79b
Added tests.
jacekbogdanski b0c0431
Changelog entry.
jacekbogdanski 314f23c
Added and updated unit tests.
94213c6
Updated docs.
e99654a
Updated tests.
jacekbogdanski 5b84602
Changed CKEDITOR.filter signature.
jacekbogdanski bfa71c5
Handed filter destroy for widget editables.
jacekbogdanski 96c7d3b
Added tests and fixed filter deletion.
jacekbogdanski 5342902
Updated filter docs param.
jacekbogdanski 1546d91
Refactored editor reference.
jacekbogdanski 0c42d3b
Updated filter function to support IE8.
jacekbogdanski 013af36
Updated version tags.
jacekbogdanski 50681f0
Updated docs.
jacekbogdanski c5f2244
Changelog entry.
jacekbogdanski 87d5473
Changelog entry rewrite.
jacekbogdanski 7c837b7
Updated version tags and simple refactoring.
jacekbogdanski e42fe2d
Simplify entry in API Changes section.
Comandeer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,112 @@ | ||
/* bender-tags: editor */ | ||
/* bender-ckeditor-plugins: toolbar,button,stylescombo,wysiwygarea */ | ||
|
||
bender.editor = { | ||
config: { | ||
startupFocus: true | ||
} | ||
}; | ||
( function() { | ||
|
||
bender.test( { | ||
'test destroy editor with rich combo panel opened': function() { | ||
var bot = this.editorBot, editor = this.editor; | ||
bot.combo( 'Styles', function( combo ) { | ||
var panelEl = combo._.panel.element; | ||
editor.destroy(); | ||
assert.isFalse( CKEDITOR.document.getBody().contains( panelEl ) ); | ||
bender.editor = { | ||
config: { | ||
startupFocus: true | ||
} | ||
}; | ||
|
||
bender.test( { | ||
'test destroy editor with rich combo panel opened': function() { | ||
var bot = this.editorBot, editor = this.editor; | ||
bot.combo( 'Styles', function( combo ) { | ||
var panelEl = combo._.panel.element; | ||
editor.destroy(); | ||
assert.isFalse( CKEDITOR.document.getBody().contains( panelEl ) ); | ||
|
||
// https://dev.ckeditor.com/ticket/4552: Do that one more time. | ||
// https://dev.ckeditor.com/ticket/4552: Do that one more time. | ||
bender.editorBot.create( {}, function( bot ) { | ||
this.wait( function() { | ||
bot.combo( 'Styles', function( combo ) { | ||
var panelEl = combo._.panel.element; | ||
|
||
bot.editor.destroy(); | ||
assert.isFalse( CKEDITOR.document.getBody().contains( panelEl ) ); | ||
} ); | ||
}, 0 ); | ||
} ); | ||
|
||
} ); | ||
}, | ||
|
||
// https://dev.ckeditor.com/ticket/13385. | ||
'test getSnapshot returns empty string after editor destroyed': function() { | ||
bender.editorBot.create( {}, function( bot ) { | ||
this.wait( function() { | ||
bot.combo( 'Styles', function( combo ) { | ||
var panelEl = combo._.panel.element; | ||
|
||
bot.editor.destroy(); | ||
assert.isFalse( CKEDITOR.document.getBody().contains( panelEl ) ); | ||
} ); | ||
var editor = bot.editor; | ||
editor.destroy(); | ||
assert.areSame( '', editor.getSnapshot() ); | ||
}, 0 ); | ||
} ); | ||
}, | ||
|
||
} ); | ||
}, | ||
'test destroy editor before it is fully initialized': function() { | ||
var name = 'test_editor', | ||
element, | ||
editor, | ||
warnStub = sinon.stub( CKEDITOR, 'warn' ); | ||
|
||
// https://dev.ckeditor.com/ticket/13385. | ||
'test getSnapshot returns empty string after editor destroyed': function() { | ||
bender.editorBot.create( {}, function( bot ) { | ||
this.wait( function() { | ||
var editor = bot.editor; | ||
editor.destroy(); | ||
assert.areSame( '', editor.getSnapshot() ); | ||
element = CKEDITOR.document.getById( name ); | ||
this.editor.destroy(); | ||
|
||
editor = CKEDITOR.replace( element ); | ||
editor.destroy(); | ||
|
||
// initConfig is called asynchronously. | ||
wait( function() { | ||
warnStub.restore(); | ||
assert.isTrue( warnStub.calledOnce, 'CKEDITOR.warn should be called once.' ); | ||
assert.areEqual( 'editor-incorrect-destroy', warnStub.firstCall.args[ 0 ], | ||
'CKEDITOR.warn error code should be "editor-incorrect-destroy".' ); | ||
}, 0 ); | ||
} ); | ||
}, | ||
|
||
'test destroy editor before it is fully initialized': function() { | ||
var name = 'test_editor', | ||
element, | ||
editor, | ||
warnStub = sinon.stub( CKEDITOR, 'warn' ); | ||
|
||
element = CKEDITOR.document.getById( name ); | ||
this.editor.destroy(); | ||
|
||
editor = CKEDITOR.replace( element ); | ||
editor.destroy(); | ||
|
||
// initConfig is called asynchronously. | ||
wait( function() { | ||
warnStub.restore(); | ||
assert.isTrue( warnStub.calledOnce, 'CKEDITOR.warn should be called once.' ); | ||
assert.areEqual( 'editor-incorrect-destroy', warnStub.firstCall.args[ 0 ], | ||
'CKEDITOR.warn error code should be "editor-incorrect-destroy".' ); | ||
}, 0 ); | ||
|
||
}, | ||
|
||
'test check editable existence on blur': function() { | ||
CKEDITOR.replace( 'focused', { | ||
on: { | ||
instanceReady: function( evt ) { | ||
resume( function() { | ||
var editor = evt.sender; | ||
// Simulate the circumstances instead of creating them. | ||
editor.focusManager.hasFocus = true; | ||
sinon.stub( editor, 'editable' ).returns( null ); | ||
editor.focusManager.blur( 1 ); | ||
assert.pass(); | ||
} ); | ||
|
||
}, | ||
|
||
'test check editable existence on blur': function() { | ||
CKEDITOR.replace( 'focused', { | ||
on: { | ||
instanceReady: function( evt ) { | ||
resume( function() { | ||
var editor = evt.sender; | ||
// Simulate the circumstances instead of creating them. | ||
editor.focusManager.hasFocus = true; | ||
sinon.stub( editor, 'editable' ).returns( null ); | ||
editor.focusManager.blur( 1 ); | ||
assert.pass(); | ||
} ); | ||
} | ||
} | ||
} | ||
} ); | ||
} ); | ||
|
||
wait(); | ||
}, | ||
|
||
// (#1722) | ||
'test destroy attached filters': function() { | ||
var filters = countFilters(); | ||
bender.editorBot.create( { name: 'editor_filter_destroy' }, function( bot ) { | ||
var editor = bot.editor; | ||
|
||
wait(); | ||
new CKEDITOR.filter( editor, 'br' ); | ||
new CKEDITOR.filter( editor ); | ||
new CKEDITOR.filter( 'br' ); | ||
|
||
editor.destroy(); | ||
|
||
assert.areEqual( 0, countFilters( editor ) ); | ||
assert.areEqual( filters + 1, countFilters() ); | ||
} ); | ||
} | ||
} ); | ||
|
||
function countFilters( editor ) { | ||
var filters = bender.tools.objToArray( CKEDITOR.filter.instances ); | ||
return editor ? CKEDITOR.tools.array.filter( filters, function( filter ) { | ||
return filter.editor === editor; | ||
} ).length : filters.length; | ||
} | ||
} ); | ||
|
||
} )(); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create followup ticket that will describe changes in API and reference it in "API Changes" section.