background.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. module( 'plugins.background' );
  2. test( 'getAllHtml能取到背景', function() {
  3. var sc = document.createElement("script");
  4. var editor = te.obj[2];
  5. sc.id="sc";
  6. sc.type = "text/plain";
  7. document.body.appendChild(sc);
  8. editor.render('sc');
  9. editor.ready(function(){
  10. equal( editor.queryCommandState( 'background' ), 0, 'check background state' );
  11. this.body.style.backgroundColor = "#d7e3bc";
  12. // this.body.style.backgroundImage = '/ueditor/php/upload//8721363160868.gif';
  13. setTimeout(function(){
  14. var headHtml = [];
  15. editor.fireEvent('getAllHtml',headHtml);
  16. equal(ua.formatColor(editor.body.style.backgroundColor),'#d7e3bc','检查body背景色');
  17. // equal(editor.body.style.backgroundImage,'','检查body背景图片');
  18. document.getElementById('sc').parentNode.removeChild(document.getElementById('sc'));
  19. start();
  20. },50);
  21. });
  22. stop();
  23. } );
  24. test( ' trace 3744 setContent 背景色', function() {
  25. var editor = te.obj[0];
  26. editor.setContent('<p> <br/></p><p style="display:none;" data-background="background-repeat:no-repeat; background-position:center center; background-color:#8064A2; "> <br/></p>');
  27. stop();
  28. setTimeout(function(){
  29. equal(ua.formatColor($(editor.body).css('background-color')),'#8064a2','setContent 背景色');
  30. start();
  31. },50);
  32. });
  33. test( ' trace 3751 3748 设置 背景色', function() {
  34. var editor = te.obj[0];
  35. var backgroundStyle = {'background-repeat': "no-repeat", 'background-position': "center center", 'background-color': "#4F81BD"};
  36. editor.setContent('<p><br/></p>');
  37. editor.execCommand('background',backgroundStyle);
  38. stop();
  39. setTimeout(function(){
  40. equal(editor.queryCommandValue('background')['background-repeat'],'no-repeat');
  41. equal(ua.formatColor(editor.queryCommandValue('background')['background-color'].toLowerCase()),'#4f81bd');
  42. ok(/center/.test(editor.queryCommandValue('background')['background-position']));
  43. editor.execCommand('source');
  44. setTimeout(function(){
  45. ua.checkSameHtml(editor.body.lastChild.outerHTML,'<p style="display:none;" data-background="background-repeat:no-repeat; background-position:center center; background-color:#4F81BD; "><br/></p>','source查看 背景色');
  46. // equal(editor.body.lastChild.outerHTML,'<p style="display:none;" data-background="background-repeat:no-repeat; background-position:center center; background-color:#4F81BD; "><br/></p>','source查看 背景色');
  47. start();
  48. },50);
  49. },50);
  50. });