module("tinymce.utils.Quirks_WebKit", { setupModule: function() { QUnit.stop(); tinymce.init({ selector: "textarea", elements: "elm1", plugins: wpPlugins, add_unload_trigger: false, skin: false, indent: false, disable_nodechange: true, init_instance_callback : function(ed) { window.editor = ed; QUnit.start(); } }); } }); if (tinymce.isWebKit) { test('Delete from beginning of P into H1', function() { editor.getBody().innerHTML = '
b
'; Utils.setSelection('p', 0); editor.execCommand('Delete'); equal(Utils.cleanHtml(editor.getBody().innerHTML), 'b
'; var rng = editor.selection.getRng(); rng.setStartBefore(editor.getBody().firstChild); rng.setEndAfter(editor.getBody().firstChild); editor.selection.setRng(rng); editor.execCommand('Delete'); equal(Utils.cleanHtml(editor.getBody().innerHTML), 'b
'; var rng = editor.selection.getRng(); rng.setStartBefore(editor.getBody().firstChild); rng.setEndAfter(editor.getBody().firstChild); editor.selection.setRng(rng); editor.execCommand('ForwardDelete'); equal(Utils.cleanHtml(editor.getBody().innerHTML), 'a
b
'; Utils.setSelection('p:last', 0); editor.execCommand('Delete'); equal(Utils.normalizeHtml(Utils.cleanHtml(editor.getBody().innerHTML)), 'a
b
bcd
'; Utils.setSelection('h1', 1, 'span', 1); editor.execCommand('Delete'); equal(Utils.normalizeHtml(Utils.cleanHtml(editor.getBody().innerHTML)), 'bc
'; Utils.setSelection('p', 0); editor.execCommand('Delete'); equal(editor.getContent(), 'bc
'; Utils.setSelection('p', 0); editor.execCommand('Delete'); equal(editor.getContent(), 'bc
'; Utils.setSelection('p', 0); editor.execCommand('Delete'); equal(editor.getContent(), 'bc
'); equal(editor.selection.getStart().nodeName, 'H1'); }); test('Delete from beginning of P with style span inside into H1 with trailing BR', function() { editor.getBody().innerHTML = 'bc
'; Utils.setSelection('p', 0); editor.execCommand('Delete'); equal(editor.getContent(), 'b
'; Utils.setSelection('span', 0); editor.execCommand('Delete'); equal(editor.getContent(), 'b
c
b
'; Utils.setSelection('h1', 1); editor.execCommand('ForwardDelete'); equal(editor.getContent(), 'b
'; Utils.setSelection('h1', 1); editor.execCommand('ForwardDelete'); equal(editor.getContent(), 'b
'; Utils.setSelection('h1', 1); editor.execCommand('ForwardDelete'); equal(editor.getContent(), 'b
'); equal(editor.selection.getStart().nodeName, 'H1'); }); test('ForwardDelete from end of H1 to P with style and inline block element', function() { editor.getBody().innerHTML = 'b
'; Utils.setSelection('h1', 1); editor.execCommand('ForwardDelete'); equal(editor.getContent(), 'c
'; var rng = editor.selection.getRng(); rng.setStart(editor.$('h1')[0].lastChild, 1); rng.setEnd(editor.$('h1')[0].lastChild, 1); editor.selection.setRng(rng); editor.execCommand('ForwardDelete'); equal(Utils.normalizeHtml(Utils.cleanHtml(editor.getBody().innerHTML)), 'b
'; Utils.setSelection('h1', 1); editor.execCommand('ForwardDelete'); equal(Utils.cleanHtml(editor.getBody().innerHTML), 'b
'; Utils.setSelection('h1', 1); editor.execCommand('ForwardDelete'); equal(Utils.cleanHtml(editor.getBody().innerHTML), 'b
'); equal(editor.selection.getStart().nodeName, 'H1'); }); test('ForwardDelete from end of H1 into P with style span inside', function() { editor.getBody().innerHTML = 'bc
'; Utils.setSelection('h1', 1); editor.execCommand('ForwardDelete'); equal(editor.getContent(), 'b
'; Utils.setSelection('p', 0); editor.fire("keydown", {keyCode: 8}); equal(Utils.cleanHtml(editor.getBody().innerHTML), 'b
'; Utils.setSelection('h1', 1); editor.fire("keydown", {keyCode: 46}); equal(Utils.cleanHtml(editor.getBody().innerHTML), 'abc 123
'; Utils.setSelection('p', 7); editor.fire("keydown", {keyCode: 8, ctrlKey: true}); equal(Utils.cleanHtml(editor.getBody().innerHTML), 'abc
'); equal(editor.selection.getStart().nodeName, 'P'); }); test('Backspace previous line', function() { editor.getBody().innerHTML = 'abc 123
'; Utils.setSelection('p', 7); editor.fire("keydown", {keyCode: 8, metaKey: true}); equal(Utils.cleanHtml(editor.getBody().innerHTML), 'abc 123
'; Utils.setSelection('p', 0); editor.fire("keydown", {keyCode: 46, ctrlKey: true}); // Remove nbsp since very old WebKit has an slight issue equal(Utils.cleanHtml(editor.getBody().innerHTML).replace(' ', ''), '123
'); equal(editor.selection.getStart().nodeName, 'P'); }); test('Delete next line', function() { editor.getBody().innerHTML = 'abc 123
'; Utils.setSelection('p', 0); editor.fire("keydown", {keyCode: 46, metaKey: true}); equal(Utils.cleanHtml(editor.getBody().innerHTML), 'x
'; Utils.setSelection('b', 0, 'b', 1); editor.fire("keypress", {keyCode: 65, charCode: 65}); equal(Utils.cleanHtml(editor.getBody().innerHTML), 'a
'); equal(editor.selection.getStart().nodeName, 'B'); }); test('Type over partial bold text and keep bold', function() { editor.getBody().innerHTML = 'xy
'; Utils.setSelection('b', 0, 'b', 1); editor.fire("keypress", {keyCode: 65, charCode: 65}); equal(Utils.cleanHtml(editor.getBody().innerHTML), 'ay
'); equal(editor.selection.getStart().nodeName, 'B'); }); test('Type over bold text wrapped inside other formats', function() { editor.getBody().innerHTML = '123
'; Utils.setSelection('b', 0, 'b', 1); editor.fire("keypress", {keyCode: 65, charCode: 65}); equal(Utils.cleanHtml(editor.getBody().innerHTML), '1a3
'); equal(editor.selection.getStart().nodeName, 'B'); }); test('Delete last character in formats', function() { editor.getBody().innerHTML = 'b
'; Utils.setSelection('i', 1); editor.fire("keydown", {keyCode: 8}); equal(Utils.cleanHtml(editor.getBody().innerHTML), 'b
'; Utils.setSelection('i', 0); editor.fire("keydown", {keyCode: 46}); equal(Utils.cleanHtml(editor.getBody().innerHTML), 'a
a
a
a