git-svn-id: https://develop.svn.wordpress.org/trunk@29458 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz
2014-08-09 20:55:34 +00:00
parent e23c1ae3ff
commit f8fed596ec
20 changed files with 459 additions and 240 deletions

View File

@@ -1,4 +1,6 @@
(function() {
var menuCtrl;
module("tinymce.plugins.ImportCSS", {
setupModule: function() {
QUnit.stop();
@@ -16,6 +18,11 @@
},
teardown: function() {
if (menuCtrl) {
menuCtrl.remove();
menuCtrl = null;
}
editor.contentCSS = [];
delete editor.settings.importcss_file_filter;
delete editor.settings.importcss_merge_classes;
@@ -26,8 +33,12 @@
});
function fireFormatsMenuEvent(styleSheets, items) {
menuCtrl = tinymce.ui.Factory.create('menu', {
items: items
}).renderTo(document.getElementById('view'));
return editor.fire('renderFormatsMenu', {
control: tinymce.ui.Factory.create('menu', {items: items}).renderTo(document.getElementById('view')),
control: menuCtrl,
doc: {
styleSheets: styleSheets
}

View File

@@ -132,10 +132,10 @@ test("Paste list like paragraph and list", function() {
editor.setContent('');
editor.execCommand('mceInsertClipboardContent', false, {
content: '<p class=MsoNormal><span style=\'font-size:10.0pt;line-height:115%;font-family:"Trebuchet MS","sans-serif";color:#666666\'>A. X<o:p></o:p></span></p><p class=MsoListParagraph style=\'text-indent:-.25in;mso-list:l0 level1 lfo1\'><![if !supportLists]><span style=\'mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin\'><span style=\'mso-list:Ignore\'>1.<span style=\'font:7.0pt "Times New Roman"\'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span><![endif]>Y</p>'
content: '<p class=MsoNormal><span style=\'font-size:10.0pt;line-height:115%;font-family:"Trebuchet MS","sans-serif";color:#666666\'>ABC. X<o:p></o:p></span></p><p class=MsoListParagraph style=\'text-indent:-.25in;mso-list:l0 level1 lfo1\'><![if !supportLists]><span style=\'mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin\'><span style=\'mso-list:Ignore\'>1.<span style=\'font:7.0pt "Times New Roman"\'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span><![endif]>Y</p>'
});
equal(editor.getContent(), '<p>A. X</p><ol><li>Y</li></ol>');
equal(editor.getContent(), '<p>ABC. X</p><ol><li>Y</li></ol>');
});
test("Paste Word table", function() {
@@ -729,4 +729,4 @@ if (tinymce.Env.webkit) {
equal(editor.getContent(), '<p style="color: #ff0000;">abc</p>');
});
}
}

View File

@@ -440,7 +440,7 @@
Utils.setSelection('tr:nth-child(2) td:nth-child(2)', 0);
editor.fire('keydown', {keyCode: 9});
equal(editor.selection.getStart().nodeName, 'TD');
equal(editor.selection.getStart(true).nodeName, 'TD');
equal(
editor.getContent(),
'<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>'

View File

@@ -43,7 +43,7 @@ module("tinymce.Editor", {
},
teardown: function() {
Utils.unpatch(editor.getDoc());
Utils.unpatch(editor.getDoc());
inlineEditor.show();
editor.show();
}
@@ -169,7 +169,6 @@ test('WebKit Serialization range bug', function() {
}
});
test('editor_methods - getParam', function() {
expect(5);
@@ -214,6 +213,14 @@ test('setContent', function() {
equal(count, 0);
});
test('setContent with comment bug #4409', function() {
editor.setContent('<!-- x --><br>');
editor.settings.disable_nodechange = false;
editor.nodeChanged();
editor.settings.disable_nodechange = true;
equal(editor.getContent(), "<!-- x --><p>\u00a0</p>");
});
test('custom elements', function() {
editor.setContent('<custom1>c1</custom1><custom2>c1</custom2>');
equal(editor.getContent(), '<custom1>c1</custom1><p><custom2>c1</custom2></p>');
@@ -221,7 +228,7 @@ test('custom elements', function() {
test('Store/restore tabindex', function() {
editor.setContent('<span tabindex="42">abc</span>');
equal(editor.getContent({format:'raw'}).toLowerCase(), '<p><span data-mce-tabindex="42">abc</span></p>');
equal(editor.getContent({format: 'raw'}).toLowerCase(), '<p><span data-mce-tabindex="42">abc</span></p>');
equal(editor.getContent(), '<p><span tabindex="42">abc</span></p>');
});

View File

@@ -1038,7 +1038,7 @@ test('Bold and italics is applied to text that is not highlighted', function() {
equal(editor.getContent(), '<p><span style="font-family: Arial;"><strong>test1 <em>test2</em></strong> test3 test4 test5 test6</span></p>', 'Selected text should be bold.');
});
test('No wrapping of links', function() {
test('Apply color format to links as well', function() {
editor.setContent('<p>123<a href="#">abc</a>456</p>');
var rng = editor.dom.createRng();
rng.setStart(editor.dom.select('p')[0].firstChild, 0);
@@ -1050,11 +1050,15 @@ test('No wrapping of links', function() {
styles: {
color: '#FF0000'
},
wrap_links: false
links: true
});
editor.formatter.apply('format');
equal(editor.getContent(), '<p><span style="color: #ff0000;">123<a href="#"><span style="color: #ff0000;">abc</span></a>456</span></p>', 'Link should have it\'s own span.');
equal(
editor.getContent(),
'<p><span style="color: #ff0000;">123<a style="color: #ff0000;" href="#">abc</a>456</span></p>',
'Link should have it\'s own color.'
);
});
test('Color on link element', function() {
@@ -1069,11 +1073,15 @@ test('Color on link element', function() {
styles: {
color: '#FF0000'
},
wrap_links: false
links: true
});
editor.formatter.apply('format');
equal(editor.getContent(), '<p><span style="color: #ff0000; font-size: 10px;">123<a href="#"><span style="color: #ff0000;">abc</span></a>456</span></p>', 'Link should have it\'s own span.');
equal(
editor.getContent(),
'<p><span style="color: #ff0000; font-size: 10px;">123<a style="color: #ff0000;" href="#">abc</a>456</span></p>',
'Link should have it\'s own color.'
);
});
test("Applying formats in lists", function() {

View File

@@ -1,5 +1,9 @@
(function() {
module("tinymce.dom.DOMUtils");
module("tinymce.dom.DOMUtils", {
teardownModule: function() {
DOM = null;
}
});
var DOM = new tinymce.dom.DOMUtils(document, {keep_values : true, schema : new tinymce.html.Schema()});
@@ -262,6 +266,11 @@
DOM.remove('test');
});
test('setGetAttrib on null', function() {
strictEqual(DOM.getAttrib(null, 'test'), '');
DOM.setAttrib(null, 'test');
});
test('getAttribs', 2, function() {
function check(obj, val) {
var count = 0;

View File

@@ -1,6 +1,13 @@
(function() {
var $elm;
module("tinymce.dom.DomQuery", {
teardown: function() {
if ($elm) {
$elm.off();
$elm = null;
}
document.getElementById('view').innerHTML = '';
}
});
@@ -582,7 +589,9 @@
});
test(prefix + 'on()/off()/trigger()', function() {
var $elm = $('<b />'), lastArgs1, lastArgs2;
var lastArgs1, lastArgs2;
$elm = $('<b />')
// Single listener
$elm.on('click', function(e) {
@@ -945,7 +954,7 @@
strictEqual($result.length, 1);
strictEqual($result[0].tagName, 'I');
});
test(prefix + 'children()', function() {
var $result, html;
@@ -983,7 +992,7 @@
strictEqual(innerMost.closest($(html[0].firstChild.firstChild)[0]).html().toLowerCase(), '<b>x</b>');
});
test(prefix + 'offset()', function() {
test(prefix + 'offset()', function() {
var testElm = $('<b></b>').offset({top: 10, left: 20});
strictEqual(testElm[0].style.top, '10px');
strictEqual(testElm[0].style.left, '20px');

View File

@@ -467,6 +467,12 @@ test('getBookmark/setBookmark (nonintrusive) - Get bookmark inside complex html'
equal(rng.endOffset, 2);
});
test('select empty TD', function() {
editor.getBody().innerHTML = '<table><tr><td><br></td></tr></table>';
editor.selection.select(editor.dom.select('td')[0], true);
equal(editor.selection.getRng(true).startContainer.nodeName, 'TD');
});
test('select first p', 2, function() {
editor.setContent('<p>text1</p><p>text2</p>');
editor.selection.select(editor.dom.select('p')[0]);

View File

@@ -175,7 +175,7 @@ test("off (all specific observer)", function() {
test("scope setting", function() {
var lastScope, lastEvent, dispatcher;
dispatcher = new tinymce.util.EventDispatcher();
dispatcher.on('click', function() {
lastScope = this;
@@ -194,7 +194,7 @@ test("scope setting", function() {
test("beforeFire setting", function() {
var lastArgs, dispatcher, args;
dispatcher = new tinymce.util.EventDispatcher({
beforeFire: function(args) {
lastArgs = args;

View File

@@ -43,7 +43,7 @@ if (tinymce.isWebKit) {
editor.getBody().innerHTML ='<h1>a</h1><p>b<span style="color:red">c</span></p>';
Utils.setSelection('p', 0);
editor.execCommand('Delete');
equal(Utils.normalizeHtml(Utils.cleanHtml(editor.getBody().innerHTML)), '<h1>ab<span data-mce-style="color:red" style="color: red;">c</span></h1>');
equal(Utils.normalizeHtml(Utils.cleanHtml(editor.getBody().innerHTML)), '<h1>ab<span data-mce-style="color: red;" style="color: red;">c</span></h1>');
equal(editor.selection.getStart().nodeName, 'H1');
});
@@ -69,10 +69,10 @@ if (tinymce.isWebKit) {
});
test('ForwardDelete from end of H1 into P with style span inside', function() {
editor.getBody().innerHTML ='<h1>a</h1><p>b<span style="color:red">c</span></p>';
editor.getBody().innerHTML ='<h1>a</h1><p>b<span style="color: #010203">c</span></p>';
Utils.setSelection('h1', 1);
editor.execCommand('ForwardDelete');
equal(Utils.normalizeHtml(Utils.cleanHtml(editor.getBody().innerHTML)), '<h1>ab<span data-mce-style="color:red" style="color: red;">c</span></h1>');
equal(editor.getContent(), '<h1>ab<span style="color: #010203;">c</span></h1>');
equal(editor.selection.getStart().nodeName, 'H1');
});

View File

@@ -2,14 +2,21 @@ if (location.protocol != "file:") {
module("tinymce.util.XHR");
asyncTest("Successful request", function() {
expect(3);
expect(5);
tinymce.util.XHR.on('beforeSend', function(e) {
e.xhr.test = 123;
e.settings.test = 456;
});
tinymce.util.XHR.send({
url : 'tinymce/util/json_rpc_ok.js',
url: 'tinymce/util/json_rpc_ok.js',
success: function(data, xhr, input) {
equal(tinymce.trim(data), '{"result": "Hello JSON-RPC", "error": null, "id": 1}');
ok(!!xhr.status);
equal(input.url, 'tinymce/util/json_rpc_ok.js');
equal(xhr.test, 123);
equal(input.test, 456);
start();
}
});
@@ -19,7 +26,7 @@ if (location.protocol != "file:") {
expect(3);
tinymce.util.XHR.send({
url : 'tinymce/util/404.js',
url: 'tinymce/util/404.js',
error: function(type, xhr, input) {
equal(type, 'GENERAL');
ok(!!xhr.status);