catchremoteimage.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. module( 'plugins.catchremoteimage' );
  2. test( '成功远程图片抓取', function () {
  3. UEDITOR_CONFIG.UEDITOR_HOME_URL = '../../../';
  4. for (var config in window.UEDITOR_CONFIG) {
  5. if (typeof(window.UEDITOR_CONFIG[config]) == 'string'){
  6. window.UEDITOR_CONFIG[config] = window.UEDITOR_CONFIG[config].replace('_test/tools/br/', '');
  7. }
  8. }
  9. var editor = new UE.Editor({'autoFloatEnabled':false});
  10. stop();
  11. setTimeout(function(){
  12. var div = document.body.appendChild( document.createElement( 'div' ) );
  13. editor.render( div );
  14. editor.ready(function(){
  15. var body = editor.body;
  16. editor.setContent( '<p><img src="http://img0.bdstatic.com/static/common/widget/search_box_search/logo/logo_3b6de4c.png"><img src="http://news.baidu.com/resource/img/logo_news_137_46.png"></p>' );
  17. editor.fireEvent( "catchRemoteImage" );
  18. var count = 0;
  19. var handler = setInterval( function () {
  20. count++;
  21. var imgs = body.getElementsByTagName( 'img' );
  22. var src = imgs [1].getAttribute( 'src' );
  23. if ( /upload/.test( src ) ) {
  24. clearInterval( handler );
  25. // ok( /upload/.test( imgs[0].getAttribute( 'src' ) ), '图片已经被转存到本地' );
  26. // equal( imgs[0].getAttribute( 'src' ), imgs[0].getAttribute( '_src' ), '查看_src' );
  27. // equal( imgs[1].getAttribute( 'src' ), imgs[1].getAttribute( '_src' ), '查看_src' );
  28. equal( imgs.length, 2, '2个图片' );
  29. start();
  30. } else if ( count > 100 ) {
  31. clearInterval( handler );
  32. ok( false, '超时,文件获取失败' );
  33. start();
  34. }
  35. }, 100 );
  36. te.dom.push( div );
  37. },50);
  38. },100);
  39. } );
  40. //test( '失败远程图片抓取', function () {
  41. ////超时太长了,而且就是一个alert,alert出来还会影响后面跑用例,先占个坑
  42. //} );