Skip to content

Commit

Permalink
Merge branch 't/16935' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
f1ames committed Mar 30, 2017
2 parents ff631c8 + a55f9c5 commit e1bf2df
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -11,6 +11,7 @@ New Features:

Fixed Issues:

* [#16935](http://dev.ckeditor.com/ticket/16935): Fixed: [Chrome] Blurring editor in [Source Mode](http://ckeditor.com/addon/sourcearea) throws an error.
* [#16825](http://dev.ckeditor.com/ticket/16825): Fixed: [Chrome] Error thrown when destroying focused inline editor.
* [#16857](http://dev.ckeditor.com/ticket/16857): Fixed: Ctrl + Shift + V blocked by copy formatting.
* [#14714](http://dev.ckeditor.com/ticket/14714): [Webkit/Blink] Fixed: Exception thrown on refocusing a blurred inline editor.
Expand Down
2 changes: 1 addition & 1 deletion core/focusmanager.js
Expand Up @@ -160,7 +160,7 @@
// Blink browsers leave selection in `[contenteditable=true]`
// when it's blurred and it's necessary to remove it manually for inline editor. (#13446)
// It seems to be related to https://bugs.chromium.org/p/chromium/issues/detail?id=433303.
if ( CKEDITOR.env.chrome && editor.editable() && editor.editable().isInline() ) {
if ( CKEDITOR.env.chrome && editor.elementMode == CKEDITOR.ELEMENT_MODE_INLINE ) {
editor.window.$.getSelection().removeAllRanges();
}

Expand Down
47 changes: 46 additions & 1 deletion tests/core/focusmanager/focusmanager.js
Expand Up @@ -54,5 +54,50 @@ bender.test( {
assert.isTrue( focusManager.hasFocus, 'editor is still focused' );
}, 50 );
}, 10 );
},

// #16935
'test blur editor in source mode': function() {
if ( !CKEDITOR.env.chrome ) {
assert.ignore();
}

bender.editorBot.create( {
name: 'test_editor_source',
config: {
plugins: 'sourcearea',
startupMode: 'source'
}
}, function( bot ) {
// Super mega ugly hack to test async error:
// 1. Listener for global error event is created, which forces the test to fail.
// 2. At the same time setTimeout is set to resonably long time to be sure that
// if error was going to throw, it had been already thrown. This timeout forces test to pass.
var timer;

function errorHandler( evt ) {
resume( function() {
if ( evt.data.$.message.indexOf( 'Cannot read property \'$\'' ) !== -1 ) {
clearTimeout( timer );
assert.fail( 'Error was thrown' );
}
} );
}

CKEDITOR.document.getWindow().once( 'error', errorHandler );

timer = setTimeout( function() {
resume( function() {
CKEDITOR.document.getWindow().removeListener( 'error', errorHandler );

assert.pass( 'Error was not thrown' );
} );
}, 200 );

bot.editor.focus();
CKEDITOR.document.getById( 'focusable' ).focus();

wait();
} );
}
} );
} );
16 changes: 16 additions & 0 deletions tests/core/focusmanager/manual/sourcemodeblur.html
@@ -0,0 +1,16 @@
<body>
<div id="editor">
<p>Example text</p>
</div>
<button>I'm a button!</button>

<script>
if ( !CKEDITOR.env.chrome ) {
bender.ignore();
}

CKEDITOR.replace( 'editor', {
startupMode: 'source'
} );
</script>
</body>
10 changes: 10 additions & 0 deletions tests/core/focusmanager/manual/sourcemodeblur.md
@@ -0,0 +1,10 @@
@bender-tags: tc, editor, focus, 16935, 4.7.0
@bender-ui: collapsed
@bender-ckeditor-plugins: toolbar, sourcearea

1. Open console.
2. Click inside editor.
3. Click the button.

**Expected:**
* There is no error in the console.

0 comments on commit e1bf2df

Please sign in to comment.