/
destroy.js
84 lines (71 loc) · 2.14 KB
/
destroy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* bender-tags: editor,unit */
/* bender-ckeditor-plugins: toolbar,button,stylescombo,wysiwygarea */
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 ) );
// #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 );
} );
} );
},
// #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() );
}, 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();
} );
}
}
} );
wait();
}
} );