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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
|
/* bender-tags: editor */
/* bender-ckeditor-plugins: maximize,sourcearea */
bender.editor = true;
bender.test( {
setUp: function() {
// Maximize plugin is disabled on iOS (https://dev.ckeditor.com/ticket/8307).
if ( CKEDITOR.env.iOS ) {
assert.ignore();
}
},
tearDown: function() {
var editors = CKEDITOR.tools.object.values( CKEDITOR.instances );
CKEDITOR.tools.array.forEach( editors, function( editor ) {
if ( editor.getCommand( 'maximize' ).state === CKEDITOR.TRISTATE_ON ) {
editor.execCommand( 'maximize' );
}
} );
},
// https://dev.ckeditor.com/ticket/4355
'test command exec not require editor focus': function() {
if ( this.editor.elementMode == CKEDITOR.ELEMENT_MODE_INLINE )
assert.ignore();
var bot = this.editorBot, editor = this.editor;
var focused = false;
editor.on( 'focus', function() {
focused = true;
} );
// Maximize command will take some time.
bot.execCommand( 'maximize' );
wait(
function() {
bot.execCommand( 'maximize' );
assert.isFalse( focused );
}, 0
);
},
'test maximize in source mode': function() {
if ( this.editor.elementMode == CKEDITOR.ELEMENT_MODE_INLINE )
assert.ignore();
var bot = this.editorBot;
// Switch to source mode.
this.editor.setMode( 'source', function() {
// Maximize command will take some time.
bot.execCommand( 'maximize' );
setTimeout( function() {
resume( function() {
bot.execCommand( 'maximize' );
assert.isTrue( true );
} );
}, 0 );
} );
wait();
},
'test maximize fire resize event with proper properties': function() {
bender.editorBot.create( {
name: 'editor_resize_event',
config: {
// Set the empty toolbar, so bazillions of buttons in the build mode will not
// break this test (the height comparison).
toolbar: [ [ 'Bold' ] ]
}
},
function( bot ) {
var editor = bot.editor,
calls = 0,
lastResizeData;
editor.on( 'resize', function( e ) {
calls++;
lastResizeData = e.data;
} );
editor.resize( 200, 400 );
editor.execCommand( 'maximize' );
assert.areEqual( window.innerHeight || document.documentElement.clientHeight, lastResizeData.outerHeight, 'Height should be same as window height.' );
assert.areEqual( window.innerWidth || document.documentElement.clientWidth, lastResizeData.outerWidth, 'Width should be same as window height.' );
editor.execCommand( 'maximize' );
assert.areEqual( 200, lastResizeData.outerWidth, 'Width should be restored.' );
assert.areEqual( 400, lastResizeData.outerHeight, 'Height should be restored.' );
} );
},
'test maximize command work when config title is set to empty string': function() {
bender.editorBot.create( {
name: 'editor2',
config: {
title: ''
}
}, function( bot ) {
var inner = bot.editor.container.getFirst( function( node ) {
return node.hasClass( 'cke_inner' );
} );
bot.editor.execCommand( 'maximize' );
assert.isTrue( inner.hasClass( 'cke_maximized' ) );
bot.editor.execCommand( 'maximize' );
assert.isFalse( inner.hasClass( 'cke_maximized' ) );
} );
},
// (#4374)
'test maximize integrates with native History API by default': function() {
bender.editorBot.create( {
name: 'editor_historyDefault'
}, function( bot ) {
var ckeWindow = CKEDITOR.document.getWindow(),
editor = bot.editor,
maximizeCommand = editor.getCommand( 'maximize' );
ckeWindow.on( 'popstate', function() {
assert.areSame( CKEDITOR.TRISTATE_OFF, maximizeCommand.state, 'Maximize has correct state – OFF' );
}, null, null, 999 );
editor.execCommand( 'maximize' );
ckeWindow.fire( 'popstate' );
} );
},
// (#4374)
'test maximize integrates with native History API if config.maximize_historyIntegration is set to native value': function() {
bender.editorBot.create( {
name: 'editor_historyNative',
config: {
maximize_historyIntegration: CKEDITOR.HISTORY_NATIVE
}
}, function( bot ) {
var ckeWindow = CKEDITOR.document.getWindow(),
editor = bot.editor,
maximizeCommand = editor.getCommand( 'maximize' );
ckeWindow.on( 'popstate', function() {
assert.areSame( CKEDITOR.TRISTATE_OFF, maximizeCommand.state, 'Maximize has correct state – OFF' );
}, null, null, 999 );
editor.execCommand( 'maximize' );
ckeWindow.fire( 'popstate' );
} );
},
// (#4374)
'test maximize integrates with hash-based navigation if config.maximize_historyIntegration is set to hash value': function() {
bender.editorBot.create( {
name: 'editor_historyHash',
config: {
maximize_historyIntegration: CKEDITOR.HISTORY_HASH
}
}, function( bot ) {
var ckeWindow = CKEDITOR.document.getWindow(),
editor = bot.editor,
maximizeCommand = editor.getCommand( 'maximize' );
ckeWindow.on( 'hashchange', function() {
assert.areSame( CKEDITOR.TRISTATE_OFF, maximizeCommand.state, 'Maximize has correct state – OFF' );
}, null, null, 999 );
editor.execCommand( 'maximize' );
ckeWindow.fire( 'hashchange' );
} );
},
// (#4374)
'test maximize does not integrates with history if config.maximize_historyIntegration is set to off value': function() {
bender.editorBot.create( {
name: 'editor_historyOff',
config: {
maximize_historyIntegration: CKEDITOR.HISTORY_OFF
}
}, function( bot ) {
var ckeWindow = CKEDITOR.document.getWindow(),
editor = bot.editor,
maximizeCommand = editor.getCommand( 'maximize' );
ckeWindow.on( 'popstate', function() {
assert.areSame( CKEDITOR.TRISTATE_ON, maximizeCommand.state, 'Maximize has correct state – ON' );
ckeWindow.fire( 'hashchange' );
}, null, null, 999 );
ckeWindow.on( 'hashchange', function() {
assert.areSame( CKEDITOR.TRISTATE_ON, maximizeCommand.state, 'Maximize has correct state – ON' );
}, null, null, 999 );
editor.execCommand( 'maximize' );
ckeWindow.fire( 'popstate' );
} );
}
} );
|