Fixes #32801.

git-svn-id: https://develop.svn.wordpress.org/trunk@33013 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz
2015-07-01 00:51:22 +00:00
parent f733d8a91d
commit 58f914004d
55 changed files with 4455 additions and 2055 deletions
+19 -14
View File
@@ -25,6 +25,9 @@
<script src="js/utils.js"></script>
<script src="js/init.js"></script>
<!-- tinymce.file.* -->
<script src="tinymce/file/Conversions.js"></script>
<script>
var wpPlugins = 'charmap colorpicker hr lists media paste tabfocus textcolor ' +
'fullscreen wordpress wpautoresize wpeditimage wpgallery wplink wpdialogs wpview';
@@ -50,6 +53,7 @@
<script src="tinymce/html/Obsolete.js"></script>
<script src="tinymce/html/Styles.js"></script>
<script src="tinymce/html/Writer.js"></script>
<script src="tinymce/html/Serializer.js"></script>
<!-- tnymce.ui.* -->
<script src="tinymce/ui/AbsoluteLayout.js"></script>
@@ -83,6 +87,7 @@
<!-- tinymce.* -->
<script src="tinymce/AddOnManager.js"></script>
<script src="tinymce/Editor.js"></script>
<script src="tinymce/EditorUpload.js"></script>
<script src="tinymce/EditorCommands.js"></script>
<script src="tinymce/EditorManager.js"></script>
<script src="tinymce/EnterKey.js"></script>
@@ -94,23 +99,23 @@
<script src="tinymce/UndoManager.js"></script>
<!-- tinymce.plugins.* -->
<!--<script src="plugins/autolink.js"></script>
<script src="plugins/autosave.js"></script>
<script src="plugins/fullpage.js"></script> -->
<!--<script src="plugins/autolink.js"></script>-->
<!--<script src="plugins/autosave.js"></script>-->
<!--<script src="plugins/fullpage.js"></script>-->
<script src="plugins/image.js"></script>
<!--<script src="plugins/importcss.js"></script>
<script src="plugins/jquery_plugin.js"></script>
<script src="plugins/jquery_initialization.js"></script>
<script src="plugins/legacyoutput.js"></script>
<script src="plugins/link.js"></script>
<script src="plugins/lists.js"></script>-->
<!--<script src="plugins/importcss.js"></script>-->
<!--<script src="plugins/jquery_plugin.js"></script>-->
<!--<script src="plugins/jquery_initialization.js"></script>-->
<!--<script src="plugins/legacyoutput.js"></script>-->
<!--<script src="plugins/link.js"></script>-->
<script src="plugins/lists.js"></script>
<script src="plugins/media.js"></script>
<!--<script src="plugins/noneditable.js"></script> -->
<script src="plugins/paste.js"></script>
<!--<script src="plugins/searchreplace.js"></script>
<script src="plugins/spellchecker.js"></script>
<script src="plugins/table.js"></script>
<script src="plugins/textpattern.js"></script>
<script src="plugins/wordcount.js"></script>-->
<!--<script src="plugins/searchreplace.js"></script>-->
<!--<script src="plugins/spellchecker.js"></script>-->
<!--<script src="plugins/table.js"></script>-->
<!--<script src="plugins/textpattern.js"></script>-->
<!--<script src="plugins/wordcount.js"></script>-->
</body>
</html>
+2 -2
View File
@@ -320,7 +320,7 @@
ok(true);
}
function getFontmostWindow() {
function getFrontmostWindow() {
return editor.windowManager.windows[editor.windowManager.windows.length - 1];
}
@@ -414,7 +414,7 @@
size: size,
resetScroll: resetScroll,
nearlyEqualRects: nearlyEqualRects,
getFontmostWindow: getFontmostWindow,
getFrontmostWindow: getFrontmostWindow,
pressArrowKey: pressArrowKey,
pressEnter: pressEnter,
trimBrsOnIE: trimBrsOnIE,
+38 -38
View File
@@ -24,7 +24,7 @@
delete editor.settings.document_base_url;
delete editor.settings.image_advtab;
var win = Utils.getFontmostWindow();
var win = Utils.getFrontmostWindow();
if (win) {
win.close();
@@ -37,7 +37,7 @@
}
function fillAndSubmitWindowForm(data) {
var win = Utils.getFontmostWindow();
var win = Utils.getFrontmostWindow();
win.fromJSON(data);
win.find('form')[0].submit();
@@ -48,7 +48,7 @@
editor.setContent('');
editor.execCommand('mceImage', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"constrain": true,
"height": "",
@@ -74,7 +74,7 @@
editor.setContent('');
editor.execCommand('mceImage', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"src": ""
});
@@ -104,7 +104,7 @@
editor.setContent('');
editor.execCommand('mceImage', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"class": "class1",
"constrain": true,
@@ -140,7 +140,7 @@
"alt": "alt"
};
win = Utils.getFontmostWindow();
win = Utils.getFrontmostWindow();
elementId = win.find('#src')[0]._id;
element = document.getElementById(elementId).childNodes[0];
@@ -170,7 +170,7 @@
"alt": "alt"
};
win = Utils.getFontmostWindow();
win = Utils.getFrontmostWindow();
elementId = win.find('#src')[0]._id;
element = document.getElementById(elementId).childNodes[0];
@@ -193,7 +193,7 @@
editor.setContent('');
editor.execCommand('mceImage', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "",
@@ -221,7 +221,7 @@
editor.setContent('');
editor.execCommand('mceImage', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "",
@@ -251,7 +251,7 @@
editor.setContent('');
editor.execCommand('mceImage', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "",
@@ -280,7 +280,7 @@
editor.setContent('');
editor.execCommand('mceImage', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "",
@@ -309,7 +309,7 @@
editor.setContent('');
editor.execCommand('mceImage', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "",
@@ -339,7 +339,7 @@
editor.setContent('');
editor.execCommand('mceImage', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "",
@@ -370,7 +370,7 @@
editor.setContent('');
editor.execCommand('mceImage', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "",
@@ -379,9 +379,9 @@
"vspace": ""
});
Utils.getFontmostWindow().find('#style').value('margin-left: 15px; margin-right: 15px;').fire('change');
Utils.getFrontmostWindow().find('#style').value('margin-left: 15px; margin-right: 15px;').fire('change');
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "15",
@@ -399,7 +399,7 @@
editor.setContent('');
editor.execCommand('mceImage', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "",
@@ -408,9 +408,9 @@
"vspace": ""
});
Utils.getFontmostWindow().find('#style').value('margin-top: 15px; margin-bottom: 15px;').fire('change');
Utils.getFrontmostWindow().find('#style').value('margin-top: 15px; margin-bottom: 15px;').fire('change');
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "",
@@ -428,7 +428,7 @@
editor.setContent('');
editor.execCommand('mceImage', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "",
@@ -437,9 +437,9 @@
"vspace": ""
});
Utils.getFontmostWindow().find('#style').value('margin: 5px;').fire('change');
Utils.getFrontmostWindow().find('#style').value('margin: 5px;').fire('change');
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "5",
@@ -457,7 +457,7 @@
editor.setContent('');
editor.execCommand('mceImage', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "",
@@ -466,9 +466,9 @@
"vspace": ""
});
Utils.getFontmostWindow().find('#style').value('margin: 5px 10px;').fire('change');
Utils.getFrontmostWindow().find('#style').value('margin: 5px 10px;').fire('change');
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "10",
@@ -486,7 +486,7 @@
editor.setContent('');
editor.execCommand('mceImage', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "",
@@ -495,9 +495,9 @@
"vspace": ""
});
Utils.getFontmostWindow().find('#style').value('margin: 5px 10px;').fire('change');
Utils.getFrontmostWindow().find('#style').value('margin: 5px 10px;').fire('change');
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "10",
@@ -515,7 +515,7 @@
editor.setContent('');
editor.execCommand('mceImage', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "",
@@ -524,9 +524,9 @@
"vspace": ""
});
Utils.getFontmostWindow().find('#style').value('margin: 5px 10px 15px;').fire('change');
Utils.getFrontmostWindow().find('#style').value('margin: 5px 10px 15px;').fire('change');
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "10",
@@ -544,7 +544,7 @@
editor.setContent('');
editor.execCommand('mceImage', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "",
@@ -553,9 +553,9 @@
"vspace": ""
});
Utils.getFontmostWindow().find('#style').value('margin: 5px 10px 15px 20px;').fire('change');
Utils.getFrontmostWindow().find('#style').value('margin: 5px 10px 15px 20px;').fire('change');
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "",
@@ -573,7 +573,7 @@
editor.setContent('');
editor.execCommand('mceImage', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "",
@@ -582,9 +582,9 @@
"vspace": ""
});
Utils.getFontmostWindow().find('#style').value('margin: 5px 10px 15px 20px; margin-top: 15px;').fire('change');
Utils.getFrontmostWindow().find('#style').value('margin: 5px 10px 15px 20px; margin-top: 15px;').fire('change');
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"alt": "",
"border": "",
"hspace": "",
@@ -594,4 +594,4 @@
});
});
})();
})();
+7 -7
View File
@@ -26,7 +26,7 @@
delete editor.settings.link_target_list;
delete editor.settings.rel_list;
var win = Utils.getFontmostWindow();
var win = Utils.getFrontmostWindow();
if (win) {
win.close();
@@ -39,7 +39,7 @@
}
function fillAndSubmitWindowForm(data) {
var win = Utils.getFontmostWindow();
var win = Utils.getFrontmostWindow();
win.fromJSON(data);
win.find('form')[0].submit();
@@ -50,7 +50,7 @@
editor.setContent('');
editor.execCommand('mceLink', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"href": "",
"target": "",
"text": "",
@@ -75,7 +75,7 @@
Utils.setSelection('p', 1, 'p', 2);
editor.execCommand('mceLink', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"href": "",
"target": "",
"text": "b",
@@ -99,7 +99,7 @@
Utils.setSelection('p:nth-child(1)', 0, 'p:nth-child(2)', 2);
editor.execCommand('mceLink', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"href": "",
"target": "",
"title": ""
@@ -142,7 +142,7 @@
editor.setContent('');
editor.execCommand('mceLink', true);
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"class": "class1",
"href": "",
"rel": "rel1",
@@ -179,4 +179,4 @@
test('Test new regex for non relative link setting relative base', function() {
equal(nonRelativeRegex.test('/testjpg.jpg'), false);
});
})();
})();
+2 -1
View File
@@ -8,6 +8,7 @@ module("tinymce.plugins.Media", {
skin: false,
plugins: wpPlugins,
document_base_url: '/tinymce/tinymce/trunk/tests/',
extended_valid_elements: 'script[src|type]',
media_scripts: [
{filter: 'http://media1.tinymce.com'},
{filter: 'http://media2.tinymce.com', width: 100, height: 200}
@@ -18,7 +19,7 @@ module("tinymce.plugins.Media", {
}
});
},
teardown: function() {
delete editor.settings.media_filter_html;
}
+1 -1
View File
@@ -52,7 +52,7 @@ test("Paste styled text content", function() {
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, {content: '<strong><em><span style="color: red;">TEST</span></em></strong>'});
equal(editor.getContent(), '<p>1<strong><em><span style="color: red;">TEST</span></em></strong>4</p>'); // Changed in WordPress
equal(editor.getContent(), '<p>1<strong><em><span style="color: red;">TEST</span></em></strong>4</p>');
});
test("Paste paragraph in paragraph", function() {
+66 -13
View File
@@ -19,7 +19,7 @@
});
},
teardown: function() {
var win = Utils.getFontmostWindow();
var win = Utils.getFrontmostWindow();
if (win) {
win.close();
@@ -35,7 +35,7 @@
});
function fillAndSubmitWindowForm(data) {
var win = Utils.getFontmostWindow();
var win = Utils.getFrontmostWindow();
win.fromJSON(data);
win.find('form')[0].submit();
@@ -51,7 +51,7 @@
Utils.setSelection('td', 0);
editor.execCommand('mceTableProps');
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"align": "",
"border": "",
"caption": false,
@@ -72,7 +72,7 @@
Utils.setSelection('td', 0);
editor.execCommand('mceTableProps');
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"align": "",
"border": "",
"caption": false,
@@ -100,7 +100,7 @@
Utils.setSelection('td', 0);
editor.execCommand('mceTableProps');
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"align": "",
"border": "",
"caption": false,
@@ -140,7 +140,7 @@
Utils.setSelection('td', 0);
editor.execCommand('mceTableProps');
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"align": "",
"border": "4",
"caption": true,
@@ -318,7 +318,7 @@
Utils.setSelection('td', 0);
editor.execCommand('mceTableProps');
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"align": "",
"backgroundColor": "",
"border": "",
@@ -337,7 +337,7 @@
Utils.setSelection('td', 0);
editor.execCommand('mceTableCellProps');
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"align": "",
"valign": "",
"height": "",
@@ -357,7 +357,7 @@
Utils.setSelection('td', 0);
editor.execCommand('mceTableCellProps');
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"align": "",
"valign": "",
"height": "",
@@ -382,7 +382,7 @@
Utils.setSelection('th', 0);
editor.execCommand('mceTableCellProps');
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"align": "right",
"valign": "top",
"height": "11",
@@ -419,7 +419,7 @@
Utils.setSelection('td', 0);
editor.execCommand('mceTableRowProps');
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"align": "",
"height": "",
"type": "tbody",
@@ -434,7 +434,7 @@
Utils.setSelection('td', 0);
editor.execCommand('mceTableRowProps');
deepEqual(Utils.getFontmostWindow().toJSON(), {
deepEqual(Utils.getFrontmostWindow().toJSON(), {
"align": "right",
"height": "10",
"type": "thead",
@@ -550,4 +550,57 @@
'<table><tbody><tr><td>A1</td><td>A2</td></tr><tr><td>B1</td><td>B2</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td></tr></tbody></table><p>x</p>'
);
});
})();
test("Delete selected cells", function() {
editor.getBody().innerHTML = (
'<table><tbody>' +
'<tr><td class="mce-item-selected">A1</td><td>A2</td></tr>' +
'<tr><td class="mce-item-selected">B1</td><td>B2</td></tr>' +
'</tbody></table>' +
'<p>x</p>'
);
Utils.setSelection('td', 0, 'td', 2);
editor.fire('keydown', {keyCode: 46});
equal(
editor.getContent(),
'<table><tbody><tr><td>&nbsp;</td><td>A2</td></tr><tr><td>&nbsp;</td><td>B2</td></tr></tbody></table><p>x</p>'
);
});
test("Delete all cells", function() {
editor.getBody().innerHTML = (
'<table><tbody>' +
'<tr><td class="mce-item-selected">A1</td><td class="mce-item-selected">A2</td></tr>' +
'<tr><td class="mce-item-selected">B1</td><td class="mce-item-selected">B2</td></tr>' +
'</tbody></table>' +
'<p>x</p>'
);
Utils.setSelection('td', 0, 'td', 2);
editor.fire('keydown', {keyCode: 46});
equal(
editor.getContent(),
'<p>x</p>'
);
});
test("Delete empty like table cell contents", function() {
editor.getBody().innerHTML = (
'<table><tbody>' +
'<tr><td><p><br></p></td><td><p>a</p></td>' +
'</tbody></table>' +
'<p>x</p>'
);
Utils.setSelection('td', 0);
editor.fire('keydown', {keyCode: 46});
equal(
editor.getContent(),
'<table><tbody><tr><td>&nbsp;</td><td><p>a</p></td></tr></tbody></table><p>x</p>'
);
});
})();
@@ -0,0 +1,97 @@
(function() {
var testBlob, testBlobDataUri;
if (!tinymce.Env.fileApi) {
return;
}
module("tinymce.EditorUpload", {
setupModule: function() {
QUnit.stop();
tinymce.init({
selector: "textarea",
add_unload_trigger: false,
disable_nodechange: true,
skin: false,
entities: 'raw',
indent: false,
init_instance_callback: function(ed) {
var canvas, context;
window.editor = ed;
canvas = document.createElement("canvas");
canvas.width = 320;
canvas.height = 200;
context = canvas.getContext("2d");
context.fillStyle = "#ff0000";
context.fillRect(0, 0, 160, 100);
context.fillStyle = "#00ff00";
context.fillRect(160, 0, 160, 100);
context.fillStyle = "#0000ff";
context.fillRect(0, 100, 160, 100);
context.fillStyle = "#ff00ff";
context.fillRect(160, 100, 160, 100);
testBlobDataUri = canvas.toDataURL();
tinymce.file.Conversions.uriToBlob(testBlobDataUri).then(function(blob) {
testBlob = blob;
QUnit.start();
});
}
});
},
teardown: function() {
editor.editorUpload.destroy();
}
});
function imageHtml(uri) {
return tinymce.DOM.createHTML('img', {src: uri});
}
asyncTest('_scanForImages', function() {
editor.setContent(imageHtml(testBlobDataUri));
editor._scanForImages().then(function(result) {
var blobInfo = result[0].blobInfo;
QUnit.equal("data:" + blobInfo.blob().type + ";base64," + blobInfo.base64(), testBlobDataUri);
QUnit.equal('<p><img src="' + blobInfo.blobUri() + '" alt=""></p>', editor.getBody().innerHTML);
QUnit.equal('<p><img src="data:' + blobInfo.blob().type + ';base64,' + blobInfo.base64() + '" alt="" /></p>', editor.getContent());
QUnit.strictEqual(editor.editorUpload.blobCache.get(blobInfo.id()), blobInfo);
}).then(QUnit.start);
});
asyncTest('uploadImages', function() {
var uploadedBlobInfo;
function assertResult(result) {
QUnit.strictEqual(result[0].status, true);
QUnit.ok(result[0].element.src.indexOf(uploadedBlobInfo.id() + '.png') !== -1);
QUnit.equal('<p><img src="' + uploadedBlobInfo.filename() + '" alt="" /></p>', editor.getContent());
return result;
}
editor.setContent(imageHtml(testBlobDataUri));
editor.settings.images_upload_handler = function(data, success) {
uploadedBlobInfo = data;
success(data.id() + '.png');
};
editor.uploadImages(assertResult).then(assertResult).then(function() {
uploadedBlobInfo = null;
return editor.uploadImages(function() {}).then(function(result) {
QUnit.strictEqual(result.length, 0);
QUnit.strictEqual(uploadedBlobInfo, null);
});
}).then(QUnit.start);
});
})();
@@ -1642,4 +1642,4 @@ asyncTest('Bug #7412 - valid_styles affects the Bold and Italic buttons, althoug
equal(getContent(), '<p>1 <strong><span style="text-decoration: underline;">1234</span></strong> 1</p>');
}
});
});
});
+19 -5
View File
@@ -386,12 +386,26 @@ test('remove format on span with internal class using removeformat format', func
equal(Utils.normalizeHtml(Utils.cleanHtml(editor.getBody().innerHTML)), '<p><span class="mce-item-internal">abc</span></p>');
});
/*
test('Remove format bug 1', function() {
editor.setContent('<p><b>ab<em>cde</em>fgh</b></p>');
editor.setContent('<p><b><i>ab</i>c</b></p>');
editor.formatter.register('format', {inline: 'b'});
Utils.setSelection('em', 0, 'em', 2);
Utils.setSelection('i', 1, 'i', 2);
editor.formatter.remove('format');
equal(editor.getContent(), '<p><b>ab</b><em>cd</em><b><em>e</em>fgh</b></p>');
equal(editor.getContent(), '<p><b><i>a</i></b><i>b</i><b>c</b></p>');
});
test('Remove format bug 2', function() {
editor.setContent('<p>ab<b>c</b></p>');
editor.formatter.register('format', {inline: 'b'});
Utils.setSelection('b', 0, 'b', 1);
editor.formatter.remove('format');
equal(editor.getContent(), '<p>abc</p>');
});
test('Remove format bug 3', function() {
editor.setContent('<p><b><i>ab</i></b></p>');
editor.formatter.register('format', {inline: 'b'});
Utils.setSelection('i', 1, 'i', 2);
editor.formatter.remove('format');
equal(editor.getContent(), '<p><b><i>a</i></b><i>b</i></p>');
});
*/
+44 -4
View File
@@ -298,6 +298,10 @@ test('Undo added when typing and losing focus', function() {
test('BeforeAddUndo event', function() {
var lastEvt, addUndoEvt;
function blockEvent(e) {
e.preventDefault();
}
editor.on('BeforeAddUndo', function(e) {
lastEvt = e;
});
@@ -315,9 +319,7 @@ test('BeforeAddUndo event', function() {
equal(Utils.cleanHtml(lastEvt.lastLevel.content), "<p>a</p>");
equal(Utils.cleanHtml(lastEvt.level.content), "<p>b</p>");
editor.on('BeforeAddUndo', function(e) {
e.preventDefault();
});
editor.on('BeforeAddUndo', blockEvent);
editor.on('AddUndo', function(e) {
addUndoEvt = e;
@@ -330,4 +332,42 @@ test('BeforeAddUndo event', function() {
equal(Utils.cleanHtml(lastEvt.level.content), "<p>c</p>");
equal(lastEvt.originalEvent.data, 1);
ok(!addUndoEvt, "Event level produced when it should be blocked");
});
editor.off('BeforeAddUndo', blockEvent);
});
test('Dirty state type letter', function() {
editor.undoManager.clear();
editor.isNotDirty = true;
editor.setContent("<p>a</p>");
Utils.setSelection('p', 1);
ok(!editor.isDirty(), "Dirty state should be false");
Utils.type('b');
equal(editor.getContent(), "<p>ab</p>");
ok(editor.isDirty(), "Dirty state should be true");
});
test('Dirty state type shift+letter', function() {
editor.undoManager.clear();
editor.isNotDirty = true;
editor.setContent("<p>a</p>");
Utils.setSelection('p', 1);
ok(!editor.isDirty(), "Dirty state should be false");
Utils.type({keyCode: 65, charCode: 66, shiftKey: true});
equal(editor.getContent(), "<p>aB</p>");
ok(editor.isDirty(), "Dirty state should be true");
});
test('Dirty state type AltGr+letter', function() {
editor.undoManager.clear();
editor.isNotDirty = true;
editor.setContent("<p>a</p>");
Utils.setSelection('p', 1);
ok(!editor.isDirty(), "Dirty state should be false");
Utils.type({keyCode: 65, charCode: 66, ctrlKey: true, altKey: true});
equal(editor.getContent(), "<p>aB</p>");
ok(editor.isDirty(), "Dirty state should be true");
});
@@ -0,0 +1,17 @@
(function(Conversions) {
module("tinymce.file.Conversions");
if (!tinymce.Env.fileApi) {
test("File API not supported by browser.", function() {
QUnit.ok(true);
});
return;
}
QUnit.asyncTest("uriToBlob", function() {
Conversions.uriToBlob("data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D").then(Conversions.blobToDataUri).then(function(dataUri) {
QUnit.equal(dataUri, "data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==");
}).then(QUnit.start);
});
})(tinymce.file.Conversions);
@@ -517,4 +517,15 @@
root = parser.parse('a<span> </span>b');
equal(serializer.serialize(root), 'a b');
});
test('Bug #7543 removes whitespace between bogus elements before a block', function() {
var serializer = new tinymce.html.Serializer();
equal(
serializer.serialize(new tinymce.html.DomParser().parse(
'<div><b data-mce-bogus="1">a</b> <b data-mce-bogus="1">b</b><p>c</p></div>')
),
'<div>a b<p>c</p></div>'
);
});
})();
+5 -3
View File
@@ -56,9 +56,11 @@ test('getEncodeFunc', function() {
});
test('decode', function() {
expect(3);
equal(tinymce.html.Entities.decode('&lt;&gt;&quot;&#39;&amp;&aring;&auml;&ouml;&unknown;&#039;&#x27;'), '<>"\'&\u00e5\u00e4\u00f6&unknown;\'\'', 'Decode text with various entities');
equal(tinymce.html.Entities.decode('&lt;&gt;&quot;&#39;&amp;&aring;&auml;&ouml;&unknown;'), '<>"\'&\u00e5\u00e4\u00f6&unknown;', 'Decode text with various entities');
equal(tinymce.html.Entities.decode('&#65;&#66;&#039;'), 'AB\'', 'Decode numeric entities');
equal(tinymce.html.Entities.decode('&#x4F;&#X4F;&#x27;'), 'OO\'', 'Decode hexanumeric entities');
equal(tinymce.html.Entities.decode('&#65&#66&#x43'), 'ABC', 'Decode numeric entities with no semicolon');
equal(tinymce.html.Entities.decode('&test'), '&test', 'Dont decode invalid entity name without semicolon');
equal(tinymce.html.Entities.encodeNumeric(tinymce.html.Entities.decode(
'&#130;&#131;&#132;&#133;&#134;&#135;&#136;&#137;&#138;' +
@@ -718,4 +718,21 @@
testFindEndTag('<b><!-- </b> --></b>', 3, 20);
testFindEndTag('<span><b><i>a<img>b</i><b>c</b></b></span>', 9, 35);
});
test('parse XSS PI', function() {
var counter, parser;
counter = createCounter(writer);
counter.validate = false;
parser = new tinymce.html.SaxParser(counter, schema);
writer.reset();
parser.parse('<?xml><iframe SRC=&#106&#97&#118&#97&#115&#99&#114&#105&#112&#116&#58&#97&#108&#101&#114&#116&#40&#39&#88&#83&#83&#39&#41>?>');
equal(
writer.getContent(),
'<?xml &gt;&lt;iframe SRC=&amp;#106&amp;#97&amp;#118&amp;#97&amp;#115&amp;#99&amp;#114&amp;#105&amp;#112&amp;' +
'#116&amp;#58&amp;#97&amp;#108&amp;#101&amp;#114&amp;#116&amp;#40&amp;#39&amp;#88&amp;#83&amp;#83&amp;#39&amp;#41&gt;?>'
);
});
})();
+4 -2
View File
@@ -31,8 +31,6 @@ test('CDATA', function() {
test('PI', function() {
var writer;
expect(2);
writer = new tinymce.html.Writer();
writer.pi('xml', 'someval');
equal(writer.getContent(), '<?xml someval?>');
@@ -40,6 +38,10 @@ test('PI', function() {
writer = new tinymce.html.Writer();
writer.pi('xml');
equal(writer.getContent(), '<?xml?>');
writer = new tinymce.html.Writer();
writer.pi('xml', 'encoding="UTF-8" < >');
equal(writer.getContent(), '<?xml encoding="UTF-8" &lt; &gt;?>');
});
test('Doctype', function() {
+3 -3
View File
@@ -18,7 +18,7 @@
test("button text, size default", function() {
var button = createButton({text: 'X'});
Utils.nearlyEqualRects(Utils.rect(button), [0, 0, 34, 30], 4);
Utils.nearlyEqualRects(Utils.rect(button), [0, 0, 27, 30], 4);
});
test("button text, size large", function() {
@@ -43,7 +43,7 @@
test("button icon, size default", function() {
var button = createButton({icon: 'test'});
Utils.nearlyEqualRects(Utils.rect(button), [0, 0, 40, 30], 4);
Utils.nearlyEqualRects(Utils.rect(button), [0, 0, 34, 30], 4);
});
test("button icon, size small", function() {
@@ -68,7 +68,7 @@
test("button text & icon, size default", function() {
var button = createButton({text: 'X', icon: 'test'});
Utils.nearlyEqualRects(Utils.rect(button), [0, 0, 52, 30], 4);
Utils.nearlyEqualRects(Utils.rect(button), [0, 0, 47, 30], 4);
});
test("button text & icon, size large", function() {
+6 -6
View File
@@ -24,13 +24,13 @@
test("colorbutton text, size large", function() {
var colorButton = createColorButton({text: 'X', size: 'large'});
Utils.nearlyEqualRects(Utils.rect(colorButton), [0, 0, 49, 39], 4);
Utils.nearlyEqualRects(Utils.rect(colorButton), [0, 0, 44, 39], 4);
});
test("colorbutton text, size small", function() {
var colorButton = createColorButton({text: 'X', size: 'small'});
Utils.nearlyEqualRects(Utils.rect(colorButton), [0, 0, 34, 23], 4);
Utils.nearlyEqualRects(Utils.rect(colorButton), [0, 0, 39, 23], 4);
});
test("colorbutton text, width 100, height 100", function() {
@@ -43,7 +43,7 @@
test("colorbutton icon, size default", function() {
var colorButton = createColorButton({icon: 'test'});
Utils.nearlyEqualRects(Utils.rect(colorButton), [0, 0, 50, 30], 4);
Utils.nearlyEqualRects(Utils.rect(colorButton), [0, 0, 49, 30], 4);
});
test("colorbutton icon, size small", function() {
@@ -55,7 +55,7 @@
test("colorbutton icon, size large", function() {
var colorButton = createColorButton({icon: 'test', size: 'large'});
Utils.nearlyEqualRects(Utils.rect(colorButton), [0, 0, 54, 40], 4);
Utils.nearlyEqualRects(Utils.rect(colorButton), [0, 0, 49, 40], 4);
});
test("colorbutton icon, width 100, height 100", function() {
@@ -74,13 +74,13 @@
test("colorbutton text & icon, size large", function() {
var colorButton = createColorButton({text: 'X', icon: 'test', size: 'large'});
Utils.nearlyEqualRects(Utils.rect(colorButton), [0, 0, 69, 40], 4);
Utils.nearlyEqualRects(Utils.rect(colorButton), [0, 0, 64, 40], 4);
});
test("colorbutton text & icon, size small", function() {
var colorButton = createColorButton({text: 'X', icon: 'test', size: 'small'});
Utils.nearlyEqualRects(Utils.rect(colorButton), [0, 0, 53, 24], 4);
Utils.nearlyEqualRects(Utils.rect(colorButton), [0, 0, 58, 24], 4);
});
test("colorbutton text & icon, width 100, height 100", function() {
+30 -42
View File
@@ -10,11 +10,9 @@
equal(ctrl.disabled(), false);
equal(ctrl.active(), false);
equal(ctrl.visible(), true);
equal(ctrl.text(), "");
equal(ctrl.width(), 0);
equal(ctrl.height(), 0);
equal(ctrl.name(), "");
equal(ctrl.title(), "");
equal(ctrl.text(), undefined);
equal(ctrl.name(), undefined);
equal(ctrl.title(), undefined);
equal(ctrl.parent(), undefined);
deepEqual(ctrl.settings, {});
});
@@ -26,8 +24,6 @@
visible: true,
text: 'Text',
title: 'Title',
width: 100,
height: 200,
name: 'Name'
});
@@ -36,8 +32,6 @@
equal(ctrl.active(), true);
equal(ctrl.visible(), true);
equal(ctrl.text(), "Text");
equal(ctrl.width(), 100);
equal(ctrl.height(), 200);
equal(ctrl.name(), "Name");
equal(ctrl.title(), "Title");
equal(ctrl.parent(), undefined);
@@ -47,8 +41,6 @@
visible: true,
text: 'Text',
title: 'Title',
width: 100,
height: 200,
name: 'Name'
});
});
@@ -66,8 +58,6 @@
visible(true).
text("Text").
title("Title").
width(100).
height(200).
name("Name").parent(cont);
// Check states
@@ -75,8 +65,6 @@
equal(ctrl.active(), true);
equal(ctrl.visible(), true);
equal(ctrl.text(), "Text");
equal(ctrl.width(), 100);
equal(ctrl.height(), 200);
equal(ctrl.name(), "Name");
equal(ctrl.title(), "Title");
equal(ctrl.parent(), cont);
@@ -168,37 +156,37 @@
test("hasClass,addClass,removeClass", function() {
var ctrl = new tinymce.ui.Control({classes: 'class1 class2 class3'});
equal(ctrl.classes(), 'mce-class1 mce-class2 mce-class3');
ok(ctrl.hasClass('class1'));
ok(ctrl.hasClass('class2'));
ok(ctrl.hasClass('class3'));
ok(!ctrl.hasClass('class4'));
equal(ctrl.classes, 'mce-class1 mce-class2 mce-class3');
ok(ctrl.classes.contains('class1'));
ok(ctrl.classes.contains('class2'));
ok(ctrl.classes.contains('class3'));
ok(!ctrl.classes.contains('class4'));
ctrl.addClass('class4');
equal(ctrl.classes(), 'mce-class1 mce-class2 mce-class3 mce-class4');
ok(ctrl.hasClass('class1'));
ok(ctrl.hasClass('class2'));
ok(ctrl.hasClass('class3'));
ok(ctrl.hasClass('class4'));
ctrl.classes.add('class4');
equal(ctrl.classes, 'mce-class1 mce-class2 mce-class3 mce-class4');
ok(ctrl.classes.contains('class1'));
ok(ctrl.classes.contains('class2'));
ok(ctrl.classes.contains('class3'));
ok(ctrl.classes.contains('class4'));
ctrl.removeClass('class4');
equal(ctrl.classes(), 'mce-class1 mce-class2 mce-class3');
ok(ctrl.hasClass('class1'));
ok(ctrl.hasClass('class2'));
ok(ctrl.hasClass('class3'));
ok(!ctrl.hasClass('class4'));
ctrl.classes.remove('class4');
equal(ctrl.classes, 'mce-class1 mce-class2 mce-class3');
ok(ctrl.classes.contains('class1'));
ok(ctrl.classes.contains('class2'));
ok(ctrl.classes.contains('class3'));
ok(!ctrl.classes.contains('class4'));
ctrl.removeClass('class3').removeClass('class2');
equal(ctrl.classes(), 'mce-class1');
ok(ctrl.hasClass('class1'));
ok(!ctrl.hasClass('class2'));
ok(!ctrl.hasClass('class3'));
ctrl.classes.remove('class3').remove('class2');
equal(ctrl.classes, 'mce-class1');
ok(ctrl.classes.contains('class1'));
ok(!ctrl.classes.contains('class2'));
ok(!ctrl.classes.contains('class3'));
ctrl.removeClass('class3').removeClass('class1');
equal(ctrl.classes(), '');
ok(!ctrl.hasClass('class1'));
ok(!ctrl.hasClass('class2'));
ok(!ctrl.hasClass('class3'));
ctrl.classes.remove('class3').remove('class1');
equal(ctrl.classes, '');
ok(!ctrl.classes.contains('class1'));
ok(!ctrl.classes.contains('class2'));
ok(!ctrl.classes.contains('class3'));
});
test("encode", function() {
+3 -3
View File
@@ -23,7 +23,7 @@
test("menubutton text, size default", function() {
var menuButton = createMenuButton({text: 'X'});
Utils.nearlyEqualRects(Utils.rect(menuButton), [0, 0, 46, 30], 4);
Utils.nearlyEqualRects(Utils.rect(menuButton), [0, 0, 39, 30], 4);
});
test("menubutton text, size large", function() {
@@ -48,7 +48,7 @@
test("menubutton icon, size default", function() {
var menuButton = createMenuButton({icon: 'test'});
Utils.nearlyEqualRects(Utils.rect(menuButton), [0, 0, 52, 30], 4);
Utils.nearlyEqualRects(Utils.rect(menuButton), [0, 0, 46, 30], 4);
});
test("menubutton icon, size small", function() {
@@ -73,7 +73,7 @@
test("menubutton text & icon, size default", function() {
var menuButton = createMenuButton({text: 'X', icon: 'test'});
Utils.nearlyEqualRects(Utils.rect(menuButton), [0, 0, 64, 30], 4);
Utils.nearlyEqualRects(Utils.rect(menuButton), [0, 0, 59, 30], 4);
});
test("menubutton text & icon, size large", function() {
+6 -6
View File
@@ -24,7 +24,7 @@
test("splitbutton text, size large", function() {
var splitButton = createSplitButton({text: 'X', size: 'large'});
Utils.nearlyEqualRects(Utils.rect(splitButton), [0, 0, 49, 39], 4);
Utils.nearlyEqualRects(Utils.rect(splitButton), [0, 0, 44, 39], 4);
});
test("splitbutton text, size small", function() {
@@ -37,7 +37,7 @@
var splitButton = createSplitButton({text: 'X', width: 100, height: 100});
deepEqual(Utils.rect(splitButton), [0, 0, 100, 100]);
deepEqual(Utils.rect(splitButton.getEl().firstChild), [1, 1, 82, 98]);
deepEqual(Utils.rect(splitButton.getEl().firstChild), [1, 1, 83, 98]);
});
test("splitbutton icon, size default", function() {
@@ -55,14 +55,14 @@
test("splitbutton icon, size large", function() {
var splitButton = createSplitButton({icon: 'test', size: 'large'});
Utils.nearlyEqualRects(Utils.rect(splitButton), [0, 0, 54, 40], 4);
Utils.nearlyEqualRects(Utils.rect(splitButton), [0, 0, 49, 40], 4);
});
test("splitbutton icon, width 100, height 100", function() {
var splitButton = createSplitButton({icon: 'test', width: 100, height: 100});
deepEqual(Utils.rect(splitButton), [0, 0, 100, 100]);
deepEqual(Utils.rect(splitButton.getEl().firstChild), [1, 1, 82, 98]);
deepEqual(Utils.rect(splitButton.getEl().firstChild), [1, 1, 83, 98]);
});
test("splitbutton text & icon, size default", function() {
@@ -74,7 +74,7 @@
test("splitbutton text & icon, size large", function() {
var splitButton = createSplitButton({text: 'X', icon: 'test', size: 'large'});
Utils.nearlyEqualRects(Utils.rect(splitButton), [0, 0, 69, 40], 4);
Utils.nearlyEqualRects(Utils.rect(splitButton), [0, 0, 64, 40], 4);
});
test("splitbutton text & icon, size small", function() {
@@ -87,7 +87,7 @@
var splitButton = createSplitButton({text: 'X', icon: 'test', width: 100, height: 100});
deepEqual(Utils.rect(splitButton), [0, 0, 100, 100]);
deepEqual(Utils.rect(splitButton.getEl().firstChild), [1, 1, 82, 98]);
deepEqual(Utils.rect(splitButton.getEl().firstChild), [1, 1, 83, 98]);
});
test("splitbutton click event", function() {
@@ -53,6 +53,15 @@ if (tinymce.isWebKit) {
equal(editor.selection.getStart().nodeName, 'H1');
});
*/
test('Delete between empty paragraphs', function() {
editor.getBody().innerHTML = '<p>a</p><p><br></p><p><br></p><p>b</p>';
Utils.setSelection('p:last', 0);
editor.execCommand('Delete');
equal(Utils.normalizeHtml(Utils.cleanHtml(editor.getBody().innerHTML)), '<p>a</p><p><br /></p><p>b<br /></p>');
equal(editor.selection.getStart().nodeName, 'P');
});
test('Delete range from middle of H1 to middle of span in P', function() {
editor.getBody().innerHTML = '<h1>ab</h1><p>b<span style="color:red">cd</span></p>';
Utils.setSelection('h1', 1, 'span', 1);