tools.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. (function () {
  2. function mySetup() {
  3. for (var config in window.UEDITOR_CONFIG) {
  4. if (typeof(window.UEDITOR_CONFIG[config]) == 'string')
  5. window.UEDITOR_CONFIG[config] = window.UEDITOR_CONFIG[config].replace('_test/tools/br/', '');
  6. }
  7. var div = document.body.appendChild(document.createElement('div'));
  8. div.id = 'test1';
  9. var utils = baidu.editor.utils;
  10. var editor = new baidu.editor.Editor({'UEDITOR_HOME_URL':'../../../', 'autoFloatEnabled':false,initialContent:'tool'});
  11. var iframe = document.createElement('iframe');
  12. document.body.appendChild(iframe);
  13. iframe.id = 'iframe';
  14. var range = new baidu.editor.dom.Range(document);
  15. var domUtils = baidu.editor.dom.domUtils;
  16. var div_dom = document.body.appendChild(document.createElement('div'));
  17. div_dom.id = 'test';
  18. te.dom.push(div);
  19. te.dom.push(iframe);
  20. te.dom.push(div_dom);
  21. te.obj.push(utils);
  22. te.obj.push(editor);
  23. te.obj.push(range);
  24. te.obj.push(domUtils);
  25. }
  26. var _d = function () {
  27. if (te) {
  28. if (te.dom && te.dom.length) {
  29. for (var i = 0; i < te.dom.length; i++) {
  30. if (te.dom[i] && te.dom[i].parentNode)
  31. te.dom[i].parentNode.removeChild(te.dom[i]);
  32. }
  33. }
  34. }
  35. te.dom = [];
  36. te.obj = [];
  37. };
  38. var s = QUnit.testStart, d = QUnit.testDone;
  39. QUnit.testStart = function () {
  40. s.apply(this, arguments);
  41. mySetup();
  42. };
  43. QUnit.testDone = function () {
  44. _d();
  45. d.apply(this, arguments);
  46. };
  47. })()