Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rename www/ to test/

  • Loading branch information...
commit 17296d2eb12690e0b31886a6ad06eedeced4c73e 1 parent 14fb1f6
@ragiragi ragiragi authored
Showing with 11,221 additions and 11,225 deletions.
  1. +3 −7 README.markdown
  2. +50 −50 {www → test}/benchmark/_benchmark_suites.js
  3. +10 −10 {www → test}/benchmark/access_cssText.js
  4. +54 −54 {www → test}/benchmark/array_each.js
  5. +9 −9 {www → test}/benchmark/cloneNode.js
  6. +27 −27 {www → test}/benchmark/function_call.js
  7. +56 −56 {www → test}/benchmark/kindOf.js
  8. +14 −14 {www → test}/benchmark/localStorage.js
  9. +44 −44 {www → test}/benchmark/normalize_text.js
  10. +28 −28 {www → test}/benchmark/regexp.js
  11. 0  {www → test}/testcase/Assistant.js
  12. +182 −182 {www → test}/testcase/align_test.js
  13. 0  {www → test}/testcase/autosaver_test.js
  14. +52 −52 {www → test}/testcase/backcolor_test.js
  15. +123 −123 {www → test}/testcase/backspace_test.js
  16. +382 −382 {www → test}/testcase/bold_test.js
  17. +167 −167 {www → test}/testcase/domutil_test.js
  18. 0  {www → test}/testcase/editor_loader_test.js
  19. +41 −41 {www → test}/testcase/fixing_test.js
  20. 0  {www → test}/testcase/fixture/broken_dummy.js
  21. 0  {www → test}/testcase/fixture/dummy.js
  22. 0  {www → test}/testcase/fixture/value1.js
  23. 0  {www → test}/testcase/fixture/value2.js
  24. +85 −85 {www → test}/testcase/flatten_test.js
  25. +266 −266 {www → test}/testcase/fontTool_test.js
  26. +74 −74 {www → test}/testcase/fontfamily_test.js
  27. +43 −43 {www → test}/testcase/fontsize_test.js
  28. +25 −25 {www → test}/testcase/forecolor_test.js
  29. +319 −319 {www → test}/testcase/history_test.js
  30. +707 −707 {www → test}/testcase/indent_test.js
  31. +25 −25 {www → test}/testcase/infinite_loop_test.js
  32. +2,228 −2,228 {www → test}/testcase/lib/benchmark.js
  33. 0  {www → test}/testcase/lib/diff_match_patch.js
  34. 0  {www → test}/testcase/lib/qunit_2b3e049.css
  35. +1,267 −1,267 {www → test}/testcase/lib/qunit_2b3e049_patched.js
  36. +214 −214 {www → test}/testcase/lib/qunit_f2b99a6.css
  37. +1,441 −1,441 {www → test}/testcase/lib/qunit_f2b99a6.js
  38. +218 −218 {www → test}/testcase/lib/qunit_f2b99a6_patched.css
  39. +1,449 −1,449 {www → test}/testcase/lib/qunit_f2b99a6_patched.js
  40. 0  {www → test}/testcase/lib/sizzle-1.5.1.js
  41. +17 −17 {www → test}/testcase/moreless_test.js
  42. +287 −287 {www → test}/testcase/outdent_test.js
  43. 0  {www → test}/testcase/paste_test.js
  44. 0  {www → test}/testcase/processor_test.js
  45. 0  {www → test}/testcase/processor_webkit_test.js
  46. +41 −41 {www → test}/testcase/richtextbox_test.js
  47. +340 −340 {www → test}/testcase/styledlist_test.js
  48. +791 −791 {www → test}/testcase/tableedit.js
  49. 0  {www → test}/testcase/testsuites.js
  50. 0  {www → test}/testcase/txlib_test.js
  51. +71 −71 {www → test}/testcase/underline_test.js
  52. 0  {www → test}/testcase/webfontloader_test.js
  53. +71 −71 {www → test}/testcase/well_formed_test.js
  54. 0  {www → test}/testcase/wysiwyg_panel_test.js
  55. 0  {www → test}/testrunner.html
  56. 0  {www → test}/testrunner_benchmark.html
  57. 0  {www → test}/testrunner_loader.html
View
10 README.markdown
@@ -1,10 +1,6 @@
Daum Editor - The Daum Open Source WYSIWYG Web Editor
======================================================
-- `www/editor.html`
-- `daumeditor/js/editor.js`
-- `daumeditor/css/editor.css`
-
Setting up a development environment
------------------------------------
@@ -19,11 +15,11 @@ e.g. `httpd.conf`
Test Case
-e.g. `http://yourhostname/DaumEditor/www/testrunner.html`
+e.g. `http://yourhostname/DaumEditor/test/testrunner.html`
Sample
-e.g. `http://yourhostname/DaumEditor/www/editor.html`
+e.g. `http://yourhostname/DaumEditor/src/pages/editor.html`
Accessing with local url(file://) is also supported. but not recommended.
@@ -45,7 +41,7 @@ e.g.
`DaumEditor$ ant`
4. test
-`open 'build/dist/www/editor.html' in your browser`
+`open 'build/dist/pages/editor.html' in your browser`
Install
------------------------------------------
View
100 www/benchmark/_benchmark_suites.js → test/benchmark/_benchmark_suites.js
@@ -1,51 +1,51 @@
-(function() {
- var benches = [
- "benchmark/regexp.js",
- "benchmark/access_cssText.js",
- "benchmark/array_each.js",
- "benchmark/cloneNode.js",
- "benchmark/function_call.js",
- "benchmark/kindOf.js",
- "benchmark/normalize_text.js",
- "benchmark/localStorage.js"
- ];
-
- function importScript(url, encoding, context, success) {
- if (url == _NULL && url != "") {
- return;
- }
- encoding = encoding || "utf-8";
- context = context || _DOC;
- try {
- var head = context.getElementsByTagName("head")[0] || context.documentElement;
- var script = context.createElement("script");
- script.type = "text/javascript";
- script.charset = encoding;
- script.src = url;
-
- var done = _FALSE;
- script.onload = script.onreadystatechange = function() {
- if (!done && (!this.readyState ||
- this.readyState === "loaded" || this.readyState === "complete")) {
- done = _TRUE;
- if (success) {
- success();
- }
-
- // Handle memory leak in IE
- script.onload = script.onreadystatechange = _NULL;
- if (head && script.parentNode) {
- head.removeChild(script);
- }
- }
- };
- head.insertBefore(script, head.firstChild);
- } catch(e) {
- console.log(e)
- }
- }
-
- for (var i = 0; i < benches.length; i++) {
- importScript(benches[i]);
- }
+(function() {
+ var benches = [
+ "benchmark/regexp.js",
+ "benchmark/access_cssText.js",
+ "benchmark/array_each.js",
+ "benchmark/cloneNode.js",
+ "benchmark/function_call.js",
+ "benchmark/kindOf.js",
+ "benchmark/normalize_text.js",
+ "benchmark/localStorage.js"
+ ];
+
+ function importScript(url, encoding, context, success) {
+ if (url == _NULL && url != "") {
+ return;
+ }
+ encoding = encoding || "utf-8";
+ context = context || _DOC;
+ try {
+ var head = context.getElementsByTagName("head")[0] || context.documentElement;
+ var script = context.createElement("script");
+ script.type = "text/javascript";
+ script.charset = encoding;
+ script.src = url;
+
+ var done = _FALSE;
+ script.onload = script.onreadystatechange = function() {
+ if (!done && (!this.readyState ||
+ this.readyState === "loaded" || this.readyState === "complete")) {
+ done = _TRUE;
+ if (success) {
+ success();
+ }
+
+ // Handle memory leak in IE
+ script.onload = script.onreadystatechange = _NULL;
+ if (head && script.parentNode) {
+ head.removeChild(script);
+ }
+ }
+ };
+ head.insertBefore(script, head.firstChild);
+ } catch(e) {
+ console.log(e)
+ }
+ }
+
+ for (var i = 0; i < benches.length; i++) {
+ importScript(benches[i]);
+ }
})();
View
20 www/benchmark/access_cssText.js → test/benchmark/access_cssText.js
@@ -1,11 +1,11 @@
-var node = document.createElement("div");
-node.style.cssText = "font-weight: bold";
-
-suite("access cssText");
-
-bench(".access", function() {
- var value = node.style.cssText;
-});
-bench("getAttribute", function() {
- var value = node.getAttribute("style");
+var node = document.createElement("div");
+node.style.cssText = "font-weight: bold";
+
+suite("access cssText");
+
+bench(".access", function() {
+ var value = node.style.cssText;
+});
+bench("getAttribute", function() {
+ var value = node.getAttribute("style");
});
View
108 www/benchmark/array_each.js → test/benchmark/array_each.js
@@ -1,55 +1,55 @@
-suite("array each");
-
-var contains = function(array, value) {
- for (var i = 0; i < array.length; i++) {
- if (array[i] == value) {
- return true;
- }
- }
- return false;
-};
-
-Array.prototype.contains = function(value) {
- for (var i = 0; i < this.length; i++) {
- if (this[i] == value) {
- return true;
- }
- }
- return false;
-};
-
-Array.prototype.newEach = function(fn) {
- try {
- for (var i = 0; i < this.length; i++) {
- fn(this[i]);
- }
- } catch (e) {
- if (e != $break) {
- throw e;
- }
- }
-};
-
-function eachContains(array, value) {
- var found = false;
- array.newEach(function(obj) {
- if (obj == value) {
- found = true;
- throw $break;
- }
- });
- return found;
-}
-
-bench("using loop w/o prototype", function() {
- var arr = [1,2,3,4,5,6,7,8,9];
- contains(arr, 9);
-});
-bench("using loop w/ prototype", function() {
- var arr = [1,2,3,4,5,6,7,8,9];
- arr.contains(9);
-});
-bench("using newEach", function() {
- var arr = [1,2,3,4,5,6,7,8,9];
- eachContains(arr, 9);
+suite("array each");
+
+var contains = function(array, value) {
+ for (var i = 0; i < array.length; i++) {
+ if (array[i] == value) {
+ return true;
+ }
+ }
+ return false;
+};
+
+Array.prototype.contains = function(value) {
+ for (var i = 0; i < this.length; i++) {
+ if (this[i] == value) {
+ return true;
+ }
+ }
+ return false;
+};
+
+Array.prototype.newEach = function(fn) {
+ try {
+ for (var i = 0; i < this.length; i++) {
+ fn(this[i]);
+ }
+ } catch (e) {
+ if (e != $break) {
+ throw e;
+ }
+ }
+};
+
+function eachContains(array, value) {
+ var found = false;
+ array.newEach(function(obj) {
+ if (obj == value) {
+ found = true;
+ throw $break;
+ }
+ });
+ return found;
+}
+
+bench("using loop w/o prototype", function() {
+ var arr = [1,2,3,4,5,6,7,8,9];
+ contains(arr, 9);
+});
+bench("using loop w/ prototype", function() {
+ var arr = [1,2,3,4,5,6,7,8,9];
+ arr.contains(9);
+});
+bench("using newEach", function() {
+ var arr = [1,2,3,4,5,6,7,8,9];
+ eachContains(arr, 9);
});
View
18 www/benchmark/cloneNode.js → test/benchmark/cloneNode.js
@@ -1,10 +1,10 @@
-var testDiv = document.createElement("div");
-
-suite("cloneNode");
-
-bench("clone으로 node 만들기", function() {
- testDiv.cloneNode(false);
-});
-bench("createElement로 node 만들기", function() {
- document.createElement("DIV");
+var testDiv = document.createElement("div");
+
+suite("cloneNode");
+
+bench("clone으로 node 만들기", function() {
+ testDiv.cloneNode(false);
+});
+bench("createElement로 node 만들기", function() {
+ document.createElement("DIV");
});
View
54 www/benchmark/function_call.js → test/benchmark/function_call.js
@@ -1,27 +1,27 @@
-suite("function call");
-
-bench("one empty var-function", function() {
- var a = function() {
- };
- var b = 1;
-});
-bench("one var-function with variable", function() {
- var a = function() {
- var c = 10;
- };
- var b = 1;
-});
-bench("use function keyword", function() {
- function a() {
- }
- var b = 1;
-});
-bench("use function keyword with variable", function() {
- function a() {
- var c = 10;
- }
- var b = 1;
-});
-bench("비교군", function() {
- var b = 1;
-});
+suite("function call");
+
+bench("one empty var-function", function() {
+ var a = function() {
+ };
+ var b = 1;
+});
+bench("one var-function with variable", function() {
+ var a = function() {
+ var c = 10;
+ };
+ var b = 1;
+});
+bench("use function keyword", function() {
+ function a() {
+ }
+ var b = 1;
+});
+bench("use function keyword with variable", function() {
+ function a() {
+ var c = 10;
+ }
+ var b = 1;
+});
+bench("비교군", function() {
+ var b = 1;
+});
View
112 www/benchmark/kindOf.js → test/benchmark/kindOf.js
@@ -1,57 +1,57 @@
-var div, REGEXP_PARAGRAPH, MAP_PARAGRAPH;
-
-suite("kindOf", {
- onStart: function() {
- div = document.createElement("div");
- div.className = "div";
- REGEXP_PARAGRAPH = new RegExp(['p','li','dd','dt','h1','h2','h3','h4','h5','h6','td','th','div','caption'].join('|'), "i");
- MAP_PARAGRAPH = new $tx.Set("SPAN", "FONT", "U", "I", "B", "EM", "STRONG", "BIG", "SMALL", "A", "SUB", "SUP",
- "TT", "DFN", "CODE", "SAMP", "KBD", "VAR", "CITE", "ABBR", "ACRONYM", "Q", "BDO", "LABEL", "DIV")
- }
-});
-
-bench("kindOf로 element 종류 판단하기", function() {
- $tom.kindOf(div, '%paragraph');
-});
-bench("regexp + tagName으로 element 종류 판단하기", function() {
- var REGEXP_PARAGRAPH = new RegExp(['p','li','dd','dt','h1','h2','h3','h4','h5','h6','td','th','div','caption'].join('|'), "i");
- return REGEXP_PARAGRAPH.test(div.tagName);
-});
-bench("compiled regexp + tagName으로 element 종류 판단하기", function() {
- return REGEXP_PARAGRAPH.test(div.tagName);
-});
-bench("map으로 element 종류 판단하기", function() {
- return MAP_PARAGRAPH[div.tagName];
-});
-
-bench("old kindOf - %block", function() {
- $tom.kindOf_old(div, '%block');
-});
-bench("old kindOf - %element", function() {
- $tom.kindOf_old(div, '%element');
-});
-bench("old kindOf - %text", function() {
- $tom.kindOf_old(div, '%text');
-});
-bench("old kindOf - div.txc-image", function() {
- $tom.kindOf_old(div, 'div.txc-image');
-});
-bench("old kindOf - p,li,dd,dt,h1,h2,h3,h4,h5,h6", function() {
- $tom.kindOf_old(div, 'p,li,dd,dt,h1,h2,h3,h4,h5,h6');
-});
-
-bench("new kindOf - %block", function() {
- $tom.kindOf(div, '%block');
-});
-bench("new kindOf - %element", function() {
- $tom.kindOf(div, '%element');
-});
-bench("new kindOf - %text", function() {
- $tom.kindOf(div, '%text');
-});
-bench("new kindOf - div.txc-image", function() {
- $tom.kindOf(div, 'div.txc-image');
-});
-bench("new kindOf - p,li,dd,dt,h1,h2,h3,h4,h5,h6", function() {
- $tom.kindOf(div, 'p,li,dd,dt,h1,h2,h3,h4,h5,h6');
+var div, REGEXP_PARAGRAPH, MAP_PARAGRAPH;
+
+suite("kindOf", {
+ onStart: function() {
+ div = document.createElement("div");
+ div.className = "div";
+ REGEXP_PARAGRAPH = new RegExp(['p','li','dd','dt','h1','h2','h3','h4','h5','h6','td','th','div','caption'].join('|'), "i");
+ MAP_PARAGRAPH = new $tx.Set("SPAN", "FONT", "U", "I", "B", "EM", "STRONG", "BIG", "SMALL", "A", "SUB", "SUP",
+ "TT", "DFN", "CODE", "SAMP", "KBD", "VAR", "CITE", "ABBR", "ACRONYM", "Q", "BDO", "LABEL", "DIV")
+ }
+});
+
+bench("kindOf로 element 종류 판단하기", function() {
+ $tom.kindOf(div, '%paragraph');
+});
+bench("regexp + tagName으로 element 종류 판단하기", function() {
+ var REGEXP_PARAGRAPH = new RegExp(['p','li','dd','dt','h1','h2','h3','h4','h5','h6','td','th','div','caption'].join('|'), "i");
+ return REGEXP_PARAGRAPH.test(div.tagName);
+});
+bench("compiled regexp + tagName으로 element 종류 판단하기", function() {
+ return REGEXP_PARAGRAPH.test(div.tagName);
+});
+bench("map으로 element 종류 판단하기", function() {
+ return MAP_PARAGRAPH[div.tagName];
+});
+
+bench("old kindOf - %block", function() {
+ $tom.kindOf_old(div, '%block');
+});
+bench("old kindOf - %element", function() {
+ $tom.kindOf_old(div, '%element');
+});
+bench("old kindOf - %text", function() {
+ $tom.kindOf_old(div, '%text');
+});
+bench("old kindOf - div.txc-image", function() {
+ $tom.kindOf_old(div, 'div.txc-image');
+});
+bench("old kindOf - p,li,dd,dt,h1,h2,h3,h4,h5,h6", function() {
+ $tom.kindOf_old(div, 'p,li,dd,dt,h1,h2,h3,h4,h5,h6');
+});
+
+bench("new kindOf - %block", function() {
+ $tom.kindOf(div, '%block');
+});
+bench("new kindOf - %element", function() {
+ $tom.kindOf(div, '%element');
+});
+bench("new kindOf - %text", function() {
+ $tom.kindOf(div, '%text');
+});
+bench("new kindOf - div.txc-image", function() {
+ $tom.kindOf(div, 'div.txc-image');
+});
+bench("new kindOf - p,li,dd,dt,h1,h2,h3,h4,h5,h6", function() {
+ $tom.kindOf(div, 'p,li,dd,dt,h1,h2,h3,h4,h5,h6');
});
View
28 www/benchmark/localStorage.js → test/benchmark/localStorage.js
@@ -1,15 +1,15 @@
-if (window.localStorage) {
- suite("localStorage", {
- onStart: function() {
- localStorage.setItem("key", "value");
- }
- });
-
- bench("setItem", function() {
- localStorage.setItem("key", "other");
- });
-
- bench("getItem", function() {
- localStorage.getItem("key");
- });
+if (window.localStorage) {
+ suite("localStorage", {
+ onStart: function() {
+ localStorage.setItem("key", "value");
+ }
+ });
+
+ bench("setItem", function() {
+ localStorage.setItem("key", "other");
+ });
+
+ bench("getItem", function() {
+ localStorage.getItem("key");
+ });
}
View
88 www/benchmark/normalize_text.js → test/benchmark/normalize_text.js
@@ -1,44 +1,44 @@
-suite("normalize");
-
-function normalizeText_(firstTextNode) {
- while ($tom.isText(firstTextNode.nextSibling)) {
- firstTextNode.nodeValue += firstTextNode.nextSibling.nodeValue;
- $tom.remove(firstTextNode.nextSibling);
- }
-}
-function normalizeText(node) {
- var child = node.firstChild;
- while (child) {
- if ($tom.isText(child)) {
- normalizeText_(child);
- }
- child = child.nextSibling;
- }
-}
-
-bench("create element", function() {
- var a = document.createElement("div");
- a.innerHTML = "Hello";
- var firstChild = a.firstChild;
-});
-bench("split", function() {
- var a = document.createElement("div");
- a.innerHTML = "Hello";
- var firstChild = a.firstChild;
- firstChild.splitText(2);
-});
-bench("normalize", function() {
- var a = document.createElement("div");
- a.innerHTML = "Hello";
- var firstChild = a.firstChild;
- firstChild.splitText(2);
- a.normalize();
-});
-bench("custom normalize", function() {
- var a = document.createElement("div");
- a.innerHTML = "Hello";
- var firstChild = a.firstChild;
- firstChild.splitText(2);
- normalizeText(a);
-});
-
+suite("normalize");
+
+function normalizeText_(firstTextNode) {
+ while ($tom.isText(firstTextNode.nextSibling)) {
+ firstTextNode.nodeValue += firstTextNode.nextSibling.nodeValue;
+ $tom.remove(firstTextNode.nextSibling);
+ }
+}
+function normalizeText(node) {
+ var child = node.firstChild;
+ while (child) {
+ if ($tom.isText(child)) {
+ normalizeText_(child);
+ }
+ child = child.nextSibling;
+ }
+}
+
+bench("create element", function() {
+ var a = document.createElement("div");
+ a.innerHTML = "Hello";
+ var firstChild = a.firstChild;
+});
+bench("split", function() {
+ var a = document.createElement("div");
+ a.innerHTML = "Hello";
+ var firstChild = a.firstChild;
+ firstChild.splitText(2);
+});
+bench("normalize", function() {
+ var a = document.createElement("div");
+ a.innerHTML = "Hello";
+ var firstChild = a.firstChild;
+ firstChild.splitText(2);
+ a.normalize();
+});
+bench("custom normalize", function() {
+ var a = document.createElement("div");
+ a.innerHTML = "Hello";
+ var firstChild = a.firstChild;
+ firstChild.splitText(2);
+ normalizeText(a);
+});
+
View
56 www/benchmark/regexp.js → test/benchmark/regexp.js
@@ -1,28 +1,28 @@
-var o = /o/;
-suite("regular expression");
-
-bench("empty function", function() {
-});
-bench("create one regexp", function() {
- /o/;
-});
-bench("create complex regexp", function() {
- /style=(['"])([^\1]+?);? ?\1/g;
-});
-bench("create/test one regexp", function() {
- /o/.test('Hello World');
-});
-bench("prepared/test one regexp", function() {
- o.test('Hello World');
-});
-
-suite("replace all");
-bench("using split+join", function() {
- "HellooldwordWorld".split("oldword").join("newword");
-});
-bench("using regexp object", function() {
- "HellooldwordWorld".replace(new RegExp("oldword", "g"), "newword");
-});
-bench("using regexp literal", function() {
- "HellooldwordWorld".replace(/oldword/g, "newword");
-});
+var o = /o/;
+suite("regular expression");
+
+bench("empty function", function() {
+});
+bench("create one regexp", function() {
+ /o/;
+});
+bench("create complex regexp", function() {
+ /style=(['"])([^\1]+?);? ?\1/g;
+});
+bench("create/test one regexp", function() {
+ /o/.test('Hello World');
+});
+bench("prepared/test one regexp", function() {
+ o.test('Hello World');
+});
+
+suite("replace all");
+bench("using split+join", function() {
+ "HellooldwordWorld".split("oldword").join("newword");
+});
+bench("using regexp object", function() {
+ "HellooldwordWorld".replace(new RegExp("oldword", "g"), "newword");
+});
+bench("using regexp literal", function() {
+ "HellooldwordWorld".replace(/oldword/g, "newword");
+});
View
0  www/testcase/Assistant.js → test/testcase/Assistant.js
File renamed without changes
View
364 www/testcase/align_test.js → test/testcase/align_test.js
@@ -1,182 +1,182 @@
-function testAlign(alignDirection) {
- var TABLE_STYLE = {border: "1", width: 500};
- var IMG_SIZE = {width: 50, height: 50};
- var currentToolName = "align" + alignDirection;
-
- function alignHtmlEqual(node, templateHTML) {
- var propertyValue = (alignDirection == "full") ? "justify" : alignDirection;
- htmlEqual(node, templateHTML.replace(/#{direction}/g, propertyValue));
- }
-
- var tool;
- var canvas;
- module("align > " + alignDirection, {
- setup: function() {
- tool = assi.getTool(currentToolName);
- tool.imageAlignMode = false;
- canvas = assi.canvas;
- }
- });
-
- test("P를 " + alignDirection, function() {
- var p = ax.p("Hello");
- assi.setContentElement(p);
- assi.selectNodeContents(p);
- assi.assertToolExecution(currentToolName, null, function() {
- equal($tx.getStyle(p, "textAlign"), tool.constructor.__TextModeProps.paragraph.style.textAlign);
- });
- });
-
- test("P에 table이 포함된 경우에 " + alignDirection, function() {
- var p = ax.p("hi", assi.getHTML(ax.table(TABLE_STYLE, ax.tr(ax.td("table")))));
- assi.setContentElement(p);
- assi.selectNodeContents(p);
- assi.assertToolExecution(currentToolName, null, function() {
- equal(p.style.textAlign, tool.constructor.__TextModeProps.paragraph.style.textAlign);
- equal(assi.byTag("table").getAttribute("align"), tool.constructor.__TextModeProps.paragraph.style.textAlign);
- });
- });
-
- test("P에 button이 포함된 경우에" + alignDirection, function() {
- var p = ax.p('<button><blockquote>block</blockquote></button> text');
- assi.setContentElement(p);
- var button = assi.byTag("button");
- if ($tx.msie) {
- var range = assi.createControlRangeFrom(button);
- range.select();
- } else {
- assi.selectForNodes(p, 0, p, 1);
- }
- assi.assertToolExecution(currentToolName, null, function() {
- equal(p.style.textAlign, tool.constructor.__TextModeProps.paragraph.style.textAlign);
- equal(button.style.cssText, "");
- equal($tx.getStyle(assi.byTag("blockquote"), "margin").replace(/0px|0pt/g, "0"), tool.constructor.__TextModeProps.button.style.margin);
- });
- });
-
- test("IMG를 " + alignDirection, function() {
- var img = ax.img(IMG_SIZE);
- var p = ax.p(img);
- assi.setContentElement(p);
- if ($tx.msie) {
- var range = assi.createControlRangeFrom(img);
- range.select();
- } else {
- assi.selectNodeContents(p);
- }
- tool.imageAlignMode = true;
- assi.assertToolExecution(currentToolName, null, function() {
- if (tool.constructor.__ImageModeProps.paragraph) {
- equal($tx.getStyle(p, "textAlign"), tool.constructor.__ImageModeProps.paragraph.style.textAlign);
- } else {
- equal(p.style.cssText, "");
- }
- equal($tx.getStyle(img, "clear"), tool.constructor.__ImageModeProps.image.style.clear);
- equal($tx.getStyle(img, "float"), tool.constructor.__ImageModeProps.image.style.float);
- equal(img.style.marginLeft, tool.constructor.__ImageModeProps.image.style.marginLeft);
- equal(img.style.marginRight, tool.constructor.__ImageModeProps.image.style.marginRight);
- tool.imageAlignMode = false;
- });
- });
-
- test("text,p,h1,align이 속성으로 지정된 p가 각각 들어있는 td를 선택하여" + alignDirection + "정렬", function() {
- var table = ax.table(TABLE_STYLE, ax.tr(ax.td(ax.p("Hello")), ax.td("World"), ax.td(ax.h1("!!")), ax.td(ax.p({align: "right"}, "no attribute!"))));
- assi.setContent(assi.getHTML(table));
-
- var originalGetTdArr = assi.processor.table.getTdArr;
- var cell1 = assi.byTag("td", 0);
- var cell2 = assi.byTag("td", 1);
- var cell3 = assi.byTag("td", 2);
- var cell4 = assi.byTag("td", 3);
- assi.processor.table.getTdArr = function() {
- return [cell1, cell2, cell3, cell4];
- };
-
- assi.assertToolExecution(currentToolName, null, function() {
- alignHtmlEqual(cell1, '<p style="text-align:#{direction}">Hello</p>');
- alignHtmlEqual(cell2, '<p style="text-align:#{direction}">World</p>');
- alignHtmlEqual(cell3, '<h1 style="text-align:#{direction}">!!</h1>');
- alignHtmlEqual(cell4, '<p style="text-align:#{direction}">no attribute!</p>');
- assi.processor.table.getTdArr = originalGetTdArr;
- });
- });
-
- test("list가 들어있는 td 두 개를 선택하여 " + alignDirection + " 정렬", function() {
- var table = ax.table(TABLE_STYLE, ax.tr(ax.td(ax.ol(ax.li("Hello"), ax.li("World"))), ax.td(ax.ul(ax.li("Hello2"))), ax.td(ax.p("!!"))));
- assi.setContent(assi.getHTML(table));
-
- var originalGetTdArr = assi.processor.table.getTdArr;
- var cell1 = assi.byTag("td", 0);
- var cell2 = assi.byTag("td", 1);
- assi.processor.table.getTdArr = function() {
- return [cell1, cell2];
- };
-
- assi.assertToolExecution(currentToolName, null, function() {
- alignHtmlEqual(cell1, '<ol><li style="text-align:#{direction}">Hello</li><li style="text-align:#{direction}">World</li></ol>');
- alignHtmlEqual(cell2, '<ul><li style="text-align:#{direction}">Hello2</li></ul>');
- alignHtmlEqual(assi.byTag("td", 2), '<p>!!</p>');
- assi.processor.table.getTdArr = originalGetTdArr;
- });
- });
-
- test("img가 들어있는 td를 선택하여 " + alignDirection + " 정렬", function() {
- var table = ax.table(TABLE_STYLE, ax.tr(ax.td(ax.img(IMG_SIZE), "Hello"), ax.td(ax.img(IMG_SIZE)), ax.td(ax.p("!!"))));
- assi.setContent(assi.getHTML(table));
-
- var originalGetTdArr = assi.processor.table.getTdArr;
- var cell1 = assi.byTag("td", 0);
- var cell2 = assi.byTag("td", 1);
- assi.processor.table.getTdArr = function() {
- return [cell1, cell2];
- };
-
- assi.assertToolExecution(currentToolName, null, function() {
- var imgSize = ' height="50" width="50"';
- alignHtmlEqual(cell1, '<p style="text-align:#{direction}"><img' + imgSize + '>Hello</p>');
- alignHtmlEqual(cell2, '<p style="text-align:#{direction}"><img' + imgSize + '></p>');
- assi.processor.table.getTdArr = originalGetTdArr;
- });
- });
-
- test("imageAlignMode에서 " + currentToolName + " 정렬 버튼 눌린 상태", function() {
- var imageStyle = Object.extend(tool.constructor.__ImageModeProps.image, IMG_SIZE);
- var img = ax.img(imageStyle);
-
- var paragraphStyle = tool.constructor.__ImageModeProps.paragraph || {};
- var p = ax.p(paragraphStyle, img, "Hello");
-
- assi.setContentElement(p);
- if ($tx.msie) {
- var range = assi.createControlRangeFrom(assi.byTag("img"));
- range.select();
- } else {
- assi.selectForNodes(p, 0, p, 1);
- }
- canvas.fireElements(img);
-
- canvas.fireJobs(Trex.Ev.__CANVAS_PANEL_QUERY_STATUS, assi.createGoogRange());
- expect(2);
- equal(tool.button.currentState(), "pushed");
- equal(tool.button.elIcon.title, TXMSG("@align.image.align." + alignDirection));
- });
-
- test("텍스트모드 모드일 때 " + currentToolName + " 정렬 버튼 눌린 상태", function() {
- var paragraphStyle = tool.constructor.__TextModeProps.paragraph || {};
- var p = ax.p(paragraphStyle, "Hello");
-
- assi.setContentElement(p);
- assi.selectNodeContents(p);
- canvas.fireElements(assi.doc.body);
-
- canvas.fireJobs(Trex.Ev.__CANVAS_PANEL_QUERY_STATUS, assi.createGoogRange());
- expect(2);
- equal(tool.button.currentState(), "pushed");
- equal(tool.button.elIcon.title, TXMSG("@align.text.align." + alignDirection));
- });
-}
-testAlign("center");
-testAlign("left");
-testAlign("right");
-testAlign("full");
-
+function testAlign(alignDirection) {
+ var TABLE_STYLE = {border: "1", width: 500};
+ var IMG_SIZE = {width: 50, height: 50};
+ var currentToolName = "align" + alignDirection;
+
+ function alignHtmlEqual(node, templateHTML) {
+ var propertyValue = (alignDirection == "full") ? "justify" : alignDirection;
+ htmlEqual(node, templateHTML.replace(/#{direction}/g, propertyValue));
+ }
+
+ var tool;
+ var canvas;
+ module("align > " + alignDirection, {
+ setup: function() {
+ tool = assi.getTool(currentToolName);
+ tool.imageAlignMode = false;
+ canvas = assi.canvas;
+ }
+ });
+
+ test("P를 " + alignDirection, function() {
+ var p = ax.p("Hello");
+ assi.setContentElement(p);
+ assi.selectNodeContents(p);
+ assi.assertToolExecution(currentToolName, null, function() {
+ equal($tx.getStyle(p, "textAlign"), tool.constructor.__TextModeProps.paragraph.style.textAlign);
+ });
+ });
+
+ test("P에 table이 포함된 경우에 " + alignDirection, function() {
+ var p = ax.p("hi", assi.getHTML(ax.table(TABLE_STYLE, ax.tr(ax.td("table")))));
+ assi.setContentElement(p);
+ assi.selectNodeContents(p);
+ assi.assertToolExecution(currentToolName, null, function() {
+ equal(p.style.textAlign, tool.constructor.__TextModeProps.paragraph.style.textAlign);
+ equal(assi.byTag("table").getAttribute("align"), tool.constructor.__TextModeProps.paragraph.style.textAlign);
+ });
+ });
+
+ test("P에 button이 포함된 경우에" + alignDirection, function() {
+ var p = ax.p('<button><blockquote>block</blockquote></button> text');
+ assi.setContentElement(p);
+ var button = assi.byTag("button");
+ if ($tx.msie) {
+ var range = assi.createControlRangeFrom(button);
+ range.select();
+ } else {
+ assi.selectForNodes(p, 0, p, 1);
+ }
+ assi.assertToolExecution(currentToolName, null, function() {
+ equal(p.style.textAlign, tool.constructor.__TextModeProps.paragraph.style.textAlign);
+ equal(button.style.cssText, "");
+ equal($tx.getStyle(assi.byTag("blockquote"), "margin").replace(/0px|0pt/g, "0"), tool.constructor.__TextModeProps.button.style.margin);
+ });
+ });
+
+ test("IMG를 " + alignDirection, function() {
+ var img = ax.img(IMG_SIZE);
+ var p = ax.p(img);
+ assi.setContentElement(p);
+ if ($tx.msie) {
+ var range = assi.createControlRangeFrom(img);
+ range.select();
+ } else {
+ assi.selectNodeContents(p);
+ }
+ tool.imageAlignMode = true;
+ assi.assertToolExecution(currentToolName, null, function() {
+ if (tool.constructor.__ImageModeProps.paragraph) {
+ equal($tx.getStyle(p, "textAlign"), tool.constructor.__ImageModeProps.paragraph.style.textAlign);
+ } else {
+ equal(p.style.cssText, "");
+ }
+ equal($tx.getStyle(img, "clear"), tool.constructor.__ImageModeProps.image.style.clear);
+ equal($tx.getStyle(img, "float"), tool.constructor.__ImageModeProps.image.style.float);
+ equal(img.style.marginLeft, tool.constructor.__ImageModeProps.image.style.marginLeft);
+ equal(img.style.marginRight, tool.constructor.__ImageModeProps.image.style.marginRight);
+ tool.imageAlignMode = false;
+ });
+ });
+
+ test("text,p,h1,align이 속성으로 지정된 p가 각각 들어있는 td를 선택하여" + alignDirection + "정렬", function() {
+ var table = ax.table(TABLE_STYLE, ax.tr(ax.td(ax.p("Hello")), ax.td("World"), ax.td(ax.h1("!!")), ax.td(ax.p({align: "right"}, "no attribute!"))));
+ assi.setContent(assi.getHTML(table));
+
+ var originalGetTdArr = assi.processor.table.getTdArr;
+ var cell1 = assi.byTag("td", 0);
+ var cell2 = assi.byTag("td", 1);
+ var cell3 = assi.byTag("td", 2);
+ var cell4 = assi.byTag("td", 3);
+ assi.processor.table.getTdArr = function() {
+ return [cell1, cell2, cell3, cell4];
+ };
+
+ assi.assertToolExecution(currentToolName, null, function() {
+ alignHtmlEqual(cell1, '<p style="text-align:#{direction}">Hello</p>');
+ alignHtmlEqual(cell2, '<p style="text-align:#{direction}">World</p>');
+ alignHtmlEqual(cell3, '<h1 style="text-align:#{direction}">!!</h1>');
+ alignHtmlEqual(cell4, '<p style="text-align:#{direction}">no attribute!</p>');
+ assi.processor.table.getTdArr = originalGetTdArr;
+ });
+ });
+
+ test("list가 들어있는 td 두 개를 선택하여 " + alignDirection + " 정렬", function() {
+ var table = ax.table(TABLE_STYLE, ax.tr(ax.td(ax.ol(ax.li("Hello"), ax.li("World"))), ax.td(ax.ul(ax.li("Hello2"))), ax.td(ax.p("!!"))));
+ assi.setContent(assi.getHTML(table));
+
+ var originalGetTdArr = assi.processor.table.getTdArr;
+ var cell1 = assi.byTag("td", 0);
+ var cell2 = assi.byTag("td", 1);
+ assi.processor.table.getTdArr = function() {
+ return [cell1, cell2];
+ };
+
+ assi.assertToolExecution(currentToolName, null, function() {
+ alignHtmlEqual(cell1, '<ol><li style="text-align:#{direction}">Hello</li><li style="text-align:#{direction}">World</li></ol>');
+ alignHtmlEqual(cell2, '<ul><li style="text-align:#{direction}">Hello2</li></ul>');
+ alignHtmlEqual(assi.byTag("td", 2), '<p>!!</p>');
+ assi.processor.table.getTdArr = originalGetTdArr;
+ });
+ });
+
+ test("img가 들어있는 td를 선택하여 " + alignDirection + " 정렬", function() {
+ var table = ax.table(TABLE_STYLE, ax.tr(ax.td(ax.img(IMG_SIZE), "Hello"), ax.td(ax.img(IMG_SIZE)), ax.td(ax.p("!!"))));
+ assi.setContent(assi.getHTML(table));
+
+ var originalGetTdArr = assi.processor.table.getTdArr;
+ var cell1 = assi.byTag("td", 0);
+ var cell2 = assi.byTag("td", 1);
+ assi.processor.table.getTdArr = function() {
+ return [cell1, cell2];
+ };
+
+ assi.assertToolExecution(currentToolName, null, function() {
+ var imgSize = ' height="50" width="50"';
+ alignHtmlEqual(cell1, '<p style="text-align:#{direction}"><img' + imgSize + '>Hello</p>');
+ alignHtmlEqual(cell2, '<p style="text-align:#{direction}"><img' + imgSize + '></p>');
+ assi.processor.table.getTdArr = originalGetTdArr;
+ });
+ });
+
+ test("imageAlignMode에서 " + currentToolName + " 정렬 버튼 눌린 상태", function() {
+ var imageStyle = Object.extend(tool.constructor.__ImageModeProps.image, IMG_SIZE);
+ var img = ax.img(imageStyle);
+
+ var paragraphStyle = tool.constructor.__ImageModeProps.paragraph || {};
+ var p = ax.p(paragraphStyle, img, "Hello");
+
+ assi.setContentElement(p);
+ if ($tx.msie) {
+ var range = assi.createControlRangeFrom(assi.byTag("img"));
+ range.select();
+ } else {
+ assi.selectForNodes(p, 0, p, 1);
+ }
+ canvas.fireElements(img);
+
+ canvas.fireJobs(Trex.Ev.__CANVAS_PANEL_QUERY_STATUS, assi.createGoogRange());
+ expect(2);
+ equal(tool.button.currentState(), "pushed");
+ equal(tool.button.elIcon.title, TXMSG("@align.image.align." + alignDirection));
+ });
+
+ test("텍스트모드 모드일 때 " + currentToolName + " 정렬 버튼 눌린 상태", function() {
+ var paragraphStyle = tool.constructor.__TextModeProps.paragraph || {};
+ var p = ax.p(paragraphStyle, "Hello");
+
+ assi.setContentElement(p);
+ assi.selectNodeContents(p);
+ canvas.fireElements(assi.doc.body);
+
+ canvas.fireJobs(Trex.Ev.__CANVAS_PANEL_QUERY_STATUS, assi.createGoogRange());
+ expect(2);
+ equal(tool.button.currentState(), "pushed");
+ equal(tool.button.elIcon.title, TXMSG("@align.text.align." + alignDirection));
+ });
+}
+testAlign("center");
+testAlign("left");
+testAlign("right");
+testAlign("full");
+
View
0  www/testcase/autosaver_test.js → test/testcase/autosaver_test.js
File renamed without changes
View
104 www/testcase/backcolor_test.js → test/testcase/backcolor_test.js
@@ -1,53 +1,53 @@
-function assertBackColorExecution(color, expectedContent, expectedSelectedText) {
- assi.assertToolExecution("backcolor", color, function() {
- htmlEqual(assi.getContent(), expectedContent);
- var selectedText = goog.dom.Range.createFromWindow(assi.win).getText();
- regexpEqual(selectedText, expectedSelectedText);
- });
-}
-
-module("backcolor");
-
-!($tx.os_win && $tx.safari) && test("collapsed에서 backcolor를 #ff0000로 변경하기", function() {
- var p = ax.p(ax.span({id: "span"}, "Hello World"));
- assi.setContentElement(p);
- assi.selectForNodes(assi.$('span').firstChild, 2, assi.$('span').firstChild, 2);
- assertBackColorExecution("#ff0000", '<p><span id="span">He</span><span style="background-color: #ff0000"></span><span>llo World</span></p>', "");
-});
-
-test("selected에서 backcolor를 #0000ff에서 #ff0000로 변경하기", function() {
- var p = ax.p(ax.span({id: "span", style: { backgroundColor: "#0000ff" }}, "Hello World"));
- assi.setContentElement(p);
- assi.selectForNodes(assi.$('span').firstChild, 2, assi.$('span').firstChild, 3);
- assertBackColorExecution("#ff0000", '<p><span id="span" style="background-color:#0000ff">He</span><span style="background-color: #ff0000">l</span><span style="background-color: #0000ff">lo World</span></p>', "l");
-});
-
-test("selected에서 backcolor를 기본색으로 되돌리기", function() {
- var p = ax.p(ax.span({id: "span", style: { backgroundColor: "#ff0000", color: "#ffffff" }}, "Hello World"));
- assi.setContentElement(p);
- assi.selectForNodes(assi.$('span').firstChild, 2, assi.$('span').firstChild, 3);
- assertBackColorExecution(null, '<p><span id="span" style="background-color:#ff0000; color:#ffffff">He</span>l<span style="background-color:#ff0000; color:#ffffff">lo World</span></p>', 'l');
-
- var buttonColor = assi.getTool("backcolor").button.elButton.style.backgroundColor;
- notEqual(buttonColor, "", "되돌리기시 버튼색이 바뀌어있으면 안된다");
-});
-
-test("selected에서 글자색도 변경되는 backColor를 실행하기", function() {
- var p = ax.p(ax.span({id: "span"}, "Hello World"));
- assi.setContentElement(p);
- assi.selectForNodes(assi.$('span').firstChild, 2, assi.$('span').firstChild, 3);
- assertBackColorExecution("#ff0000|#ffffff", '<p><span id="span">He</span><span style="background-color: #ff0000; color: #ffffff">l</span><span>lo World</span></p>', "l");
-
-});
-
-test("글상자 안에서 backColor실행시 글상자 배경색 속성은 글상자에 유지되어야 한다.", function() {
- var textBoxColor = "#dbe8fb";
- var textBoxHtml = '<div style="border: #79a5e4 1px dashed; padding: 10px; background-color: '+ textBoxColor + '" class="txc-textbox"></div>';
- assi.setContent(textBoxHtml);
- var div = assi.byTag("div");
- div.innerHTML = "Hello";
- assi.selectForNodes(div.firstChild, 0, div.firstChild, 1);
- assi.assertToolExecution("backcolor", "#ff0000", function() {
- equal(Trex.Color.getHexColor(div.style.backgroundColor).toLowerCase(), textBoxColor);
- });
+function assertBackColorExecution(color, expectedContent, expectedSelectedText) {
+ assi.assertToolExecution("backcolor", color, function() {
+ htmlEqual(assi.getContent(), expectedContent);
+ var selectedText = goog.dom.Range.createFromWindow(assi.win).getText();
+ regexpEqual(selectedText, expectedSelectedText);
+ });
+}
+
+module("backcolor");
+
+!($tx.os_win && $tx.safari) && test("collapsed에서 backcolor를 #ff0000로 변경하기", function() {
+ var p = ax.p(ax.span({id: "span"}, "Hello World"));
+ assi.setContentElement(p);
+ assi.selectForNodes(assi.$('span').firstChild, 2, assi.$('span').firstChild, 2);
+ assertBackColorExecution("#ff0000", '<p><span id="span">He</span><span style="background-color: #ff0000"></span><span>llo World</span></p>', "");
+});
+
+test("selected에서 backcolor를 #0000ff에서 #ff0000로 변경하기", function() {
+ var p = ax.p(ax.span({id: "span", style: { backgroundColor: "#0000ff" }}, "Hello World"));
+ assi.setContentElement(p);
+ assi.selectForNodes(assi.$('span').firstChild, 2, assi.$('span').firstChild, 3);
+ assertBackColorExecution("#ff0000", '<p><span id="span" style="background-color:#0000ff">He</span><span style="background-color: #ff0000">l</span><span style="background-color: #0000ff">lo World</span></p>', "l");
+});
+
+test("selected에서 backcolor를 기본색으로 되돌리기", function() {
+ var p = ax.p(ax.span({id: "span", style: { backgroundColor: "#ff0000", color: "#ffffff" }}, "Hello World"));
+ assi.setContentElement(p);
+ assi.selectForNodes(assi.$('span').firstChild, 2, assi.$('span').firstChild, 3);
+ assertBackColorExecution(null, '<p><span id="span" style="background-color:#ff0000; color:#ffffff">He</span>l<span style="background-color:#ff0000; color:#ffffff">lo World</span></p>', 'l');
+
+ var buttonColor = assi.getTool("backcolor").button.elButton.style.backgroundColor;
+ notEqual(buttonColor, "", "되돌리기시 버튼색이 바뀌어있으면 안된다");
+});
+
+test("selected에서 글자색도 변경되는 backColor를 실행하기", function() {
+ var p = ax.p(ax.span({id: "span"}, "Hello World"));
+ assi.setContentElement(p);
+ assi.selectForNodes(assi.$('span').firstChild, 2, assi.$('span').firstChild, 3);
+ assertBackColorExecution("#ff0000|#ffffff", '<p><span id="span">He</span><span style="background-color: #ff0000; color: #ffffff">l</span><span>lo World</span></p>', "l");
+
+});
+
+test("글상자 안에서 backColor실행시 글상자 배경색 속성은 글상자에 유지되어야 한다.", function() {
+ var textBoxColor = "#dbe8fb";
+ var textBoxHtml = '<div style="border: #79a5e4 1px dashed; padding: 10px; background-color: '+ textBoxColor + '" class="txc-textbox"></div>';
+ assi.setContent(textBoxHtml);
+ var div = assi.byTag("div");
+ div.innerHTML = "Hello";
+ assi.selectForNodes(div.firstChild, 0, div.firstChild, 1);
+ assi.assertToolExecution("backcolor", "#ff0000", function() {
+ equal(Trex.Color.getHexColor(div.style.backgroundColor).toLowerCase(), textBoxColor);
+ });
});
View
246 www/testcase/backspace_test.js → test/testcase/backspace_test.js
@@ -1,124 +1,124 @@
-(function() {
- var INDENT_ONCE = "2em";
- var INDENT_ONCE_STYLE = {style : {marginLeft: INDENT_ONCE}};
- var SHOULD_STOP_EVENT = {
- preventDefault: function() {
- ok(true);
- },
- stopPropagation: function() {
- ok(true);
- }
- };
- var SHOULD_DEFAULT_ACTION = {
- preventDefault: function() {
- ok(false);
- },
- stopPropagation: function() {
- ok(false);
- }
- };
- module("backspace");
-
- test("selection이 있는 상태에서 backspace -> default action", function() {
- var p = ax.p(INDENT_ONCE_STYLE, "Hello");
- assi.setContentElement(p);
- assi.selectForNodes(p.firstChild, 0, p.firstChild, 1);
-
- assi.pressBackspace(SHOULD_DEFAULT_ACTION);
- });
-
- test("indented block의 처음에서 backspace -> outdent", function() {
- var p = ax.p(INDENT_ONCE_STYLE, "Hello");
- assi.setContentElement(p);
- assi.selectForNodes(p.firstChild, 0, p.firstChild, 0);
-
- expect(4);
- assi.pressBackspace(SHOULD_STOP_EVENT);
- assi.delayedAssertion(function() {
- equal(p.style.marginLeft, "", "p에 outdent가 실행되어야 한다.");
- equal(p.innerHTML, "Hello", "p의 innerHTML은 변경되지 않는다.");
- });
- });
-
- test("list item 처음에서 backspace -> outdent", function() {
- var ol = ax.ol(ax.ol(ax.li({id: "li"}, "item1"), ax.li("item2")));
- assi.setContentElement(ol);
- var li = assi.$('li');
- assi.selectForNodes(li.firstChild, 0, li.firstChild, 0);
-
- expect(3);
- assi.pressBackspace(SHOULD_STOP_EVENT);
- assi.delayedAssertion(function() {
- htmlEqual(ol.innerHTML, "<li id='li'>item1</li><ol><li>item2</li></ol>", "첫번째 list item이 outdent 되었다.");
- });
- });
-
- test("td의 텍스트 중간에서 backspace -> default action", function() {
- var table = ax.table({border: 1}, ax.tr(ax.td({id: "td"}, "Text")));
- assi.setContent(assi.getHTML(table));
- var td = assi.$('td');
- assi.selectForNodes(td.firstChild, 2, td.firstChild, 2);
-
- assi.pressBackspace(SHOULD_DEFAULT_ACTION);
- });
-
- test("indented block의 중간에서 backspace -> default action", function() {
- var p = ax.p(INDENT_ONCE_STYLE, "Hello");
- assi.setContentElement(p);
- assi.selectForNodes(p.firstChild, 2, p.firstChild, 2);
-
- assi.pressBackspace(SHOULD_DEFAULT_ACTION);
- });
-
- test("no-indent block의 처음에서 backspace -> default action", function() {
- var p = ax.p("Hello");
- assi.setContentElement(p);
- assi.selectForNodes(p.firstChild, 0, p.firstChild, 0);
-
- assi.pressBackspace(SHOULD_DEFAULT_ACTION);
- });
-
- test("list item 끝에서 backspace -> default action", function() {
- var ol = ax.ol(ax.ol(ax.li({id: "li"}, "item1"), ax.li("item2")));
- assi.setContentElement(ol);
- var li = assi.$('li');
- assi.selectForNodes(li.firstChild, 5, li.firstChild, 5);
-
- assi.pressBackspace(SHOULD_DEFAULT_ACTION);
- });
-
- test("list item 처음에서 backspace -> outdent", function() {
- var ol = ax.ol(ax.ol(ax.li({id: "li1"}, "item1"), ax.li({id: "li2"}, "item2")));
- assi.setContentElement(ol);
- var li2 = assi.$('li2');
- assi.selectForNodes(li2.firstChild, 0, li2.firstChild, 0);
-
- assi.pressBackspace(SHOULD_STOP_EVENT);
- var range = assi.createGoogRange();
- ok($tom.include(assi.$('li2'), range.getStartNode()));
- });
-
- $tx.msie &&
- test("IE test 1 : TextRange로 두번째 li의 맨처음으로 select할 수 없다.", function() {
- var ol = ax.ol(ax.ol(ax.li({id: "li1"}, "item2")), ax.li({id: "li2"}, ax.span({id:"s"}), ax.span({id:"e"}), "item2"));
- assi.setContentElement(ol);
- var textRange = assi.doc.body.createTextRange();
- textRange.moveToElementText(assi.$('s'));
- textRange.collapse(true);
- textRange.select();
- });
-
- $tx.msie &&
- test("IE test 2 : 빈 span이 두 개 있으면 두번째 li 맨처음을 select할 수 있다.", function() {
- var ol = ax.ol(ax.ol(ax.li({id: "li1"}, "item2")), ax.li({id: "li2"}, ax.span({id:"s"}), ax.span({id:"e"}), "item2"));
- assi.setContentElement(ol);
- var li2 = assi.$('li2');
- var range = goog.dom.Range.createFromNodes(assi.$("li2"), 1, assi.$("li2"), 1);
- range.select();
- $tom.remove(assi.$("s"));
- $tom.remove(assi.$("e"));
-
- range = goog.dom.Range.createFromNodes(assi.$("li2"), 0, assi.$("li2"), 0);
- range.select();
- });
+(function() {
+ var INDENT_ONCE = "2em";
+ var INDENT_ONCE_STYLE = {style : {marginLeft: INDENT_ONCE}};
+ var SHOULD_STOP_EVENT = {
+ preventDefault: function() {
+ ok(true);
+ },
+ stopPropagation: function() {
+ ok(true);
+ }
+ };
+ var SHOULD_DEFAULT_ACTION = {
+ preventDefault: function() {
+ ok(false);
+ },
+ stopPropagation: function() {
+ ok(false);
+ }
+ };
+ module("backspace");
+
+ test("selection이 있는 상태에서 backspace -> default action", function() {
+ var p = ax.p(INDENT_ONCE_STYLE, "Hello");
+ assi.setContentElement(p);
+ assi.selectForNodes(p.firstChild, 0, p.firstChild, 1);
+
+ assi.pressBackspace(SHOULD_DEFAULT_ACTION);
+ });
+
+ test("indented block의 처음에서 backspace -> outdent", function() {
+ var p = ax.p(INDENT_ONCE_STYLE, "Hello");
+ assi.setContentElement(p);
+ assi.selectForNodes(p.firstChild, 0, p.firstChild, 0);
+
+ expect(4);
+ assi.pressBackspace(SHOULD_STOP_EVENT);
+ assi.delayedAssertion(function() {
+ equal(p.style.marginLeft, "", "p에 outdent가 실행되어야 한다.");
+ equal(p.innerHTML, "Hello", "p의 innerHTML은 변경되지 않는다.");
+ });
+ });
+
+ test("list item 처음에서 backspace -> outdent", function() {
+ var ol = ax.ol(ax.ol(ax.li({id: "li"}, "item1"), ax.li("item2")));
+ assi.setContentElement(ol);
+ var li = assi.$('li');
+ assi.selectForNodes(li.firstChild, 0, li.firstChild, 0);
+
+ expect(3);
+ assi.pressBackspace(SHOULD_STOP_EVENT);
+ assi.delayedAssertion(function() {
+ htmlEqual(ol.innerHTML, "<li id='li'>item1</li><ol><li>item2</li></ol>", "첫번째 list item이 outdent 되었다.");
+ });
+ });
+
+ test("td의 텍스트 중간에서 backspace -> default action", function() {
+ var table = ax.table({border: 1}, ax.tr(ax.td({id: "td"}, "Text")));
+ assi.setContent(assi.getHTML(table));
+ var td = assi.$('td');
+ assi.selectForNodes(td.firstChild, 2, td.firstChild, 2);
+
+ assi.pressBackspace(SHOULD_DEFAULT_ACTION);
+ });
+
+ test("indented block의 중간에서 backspace -> default action", function() {
+ var p = ax.p(INDENT_ONCE_STYLE, "Hello");
+ assi.setContentElement(p);
+ assi.selectForNodes(p.firstChild, 2, p.firstChild, 2);
+
+ assi.pressBackspace(SHOULD_DEFAULT_ACTION);
+ });
+
+ test("no-indent block의 처음에서 backspace -> default action", function() {
+ var p = ax.p("Hello");
+ assi.setContentElement(p);
+ assi.selectForNodes(p.firstChild, 0, p.firstChild, 0);
+
+ assi.pressBackspace(SHOULD_DEFAULT_ACTION);
+ });
+
+ test("list item 끝에서 backspace -> default action", function() {
+ var ol = ax.ol(ax.ol(ax.li({id: "li"}, "item1"), ax.li("item2")));
+ assi.setContentElement(ol);
+ var li = assi.$('li');
+ assi.selectForNodes(li.firstChild, 5, li.firstChild, 5);
+
+ assi.pressBackspace(SHOULD_DEFAULT_ACTION);
+ });
+
+ test("list item 처음에서 backspace -> outdent", function() {
+ var ol = ax.ol(ax.ol(ax.li({id: "li1"}, "item1"), ax.li({id: "li2"}, "item2")));
+ assi.setContentElement(ol);
+ var li2 = assi.$('li2');
+ assi.selectForNodes(li2.firstChild, 0, li2.firstChild, 0);
+
+ assi.pressBackspace(SHOULD_STOP_EVENT);
+ var range = assi.createGoogRange();
+ ok($tom.include(assi.$('li2'), range.getStartNode()));
+ });
+
+ $tx.msie &&
+ test("IE test 1 : TextRange로 두번째 li의 맨처음으로 select할 수 없다.", function() {
+ var ol = ax.ol(ax.ol(ax.li({id: "li1"}, "item2")), ax.li({id: "li2"}, ax.span({id:"s"}), ax.span({id:"e"}), "item2"));
+ assi.setContentElement(ol);
+ var textRange = assi.doc.body.createTextRange();
+ textRange.moveToElementText(assi.$('s'));
+ textRange.collapse(true);
+ textRange.select();
+ });
+
+ $tx.msie &&
+ test("IE test 2 : 빈 span이 두 개 있으면 두번째 li 맨처음을 select할 수 있다.", function() {
+ var ol = ax.ol(ax.ol(ax.li({id: "li1"}, "item2")), ax.li({id: "li2"}, ax.span({id:"s"}), ax.span({id:"e"}), "item2"));
+ assi.setContentElement(ol);
+ var li2 = assi.$('li2');
+ var range = goog.dom.Range.createFromNodes(assi.$("li2"), 1, assi.$("li2"), 1);
+ range.select();
+ $tom.remove(assi.$("s"));
+ $tom.remove(assi.$("e"));
+
+ range = goog.dom.Range.createFromNodes(assi.$("li2"), 0, assi.$("li2"), 0);
+ range.select();
+ });
})();
View
764 www/testcase/bold_test.js → test/testcase/bold_test.js
@@ -1,382 +1,382 @@
-function assertBoldExecution(expectedContent, expectedSelectedText, opt_fn) {
- assi.assertToolExecution("bold", null, function() {
- htmlEqual(assi.getContent(), expectedContent);
- var selectedText = goog.dom.Range.createFromWindow(assi.win).getText();
- regexpEqual(selectedText, expectedSelectedText);
- opt_fn && opt_fn();
- });
-}
-
-!($tx.os_win && $tx.safari) && (function() {
- module("bold collapsed");
-
- test("collapsed 상태에서 TextNode를 bold하기", function() {
- assi.setContent("<p>Hello</p>");
- var p = assi.doc.body.firstChild;
- assi.selectForNodes(p.firstChild, 2, p.firstChild, 2);
- assertBoldExecution('<p>He<span style="font-weight: bold; "></span>llo</p>', "");
- });
-
- test("collapsed 상태이고 span에 포함된 TextNode에서 bold하기", function() {
- assi.setContent('<p><span style="font-style: italic; ">Hello</span></p>');
- var p = assi.doc.body.firstChild;
- assi.selectForNodes(p.firstChild.firstChild, 2, p.firstChild.firstChild, 2);
-
- var expectedContent = '<p><span style="font-style: italic; ">He</span><span style="font-style: italic; font-weight: bold; "></span><span style="font-style: italic; ">llo</span></p>';
- assertBoldExecution(expectedContent, "");
- });
-
- test("collapsed 상태이고, bold된 글자에서 bold를 하면 unbold로 된다.", function() {
- assi.setContent('<p><span style="font-weight: bold; ">Hello</span></p>');
- var p = assi.doc.body.firstChild;
- assi.selectForNodes(p.firstChild.firstChild, 2, p.firstChild.firstChild, 2);
-
- var expectedContent = '<p><span style="font-weight: bold; ">He</span><span></span><span style="font-weight: bold; ">llo</span></p>';
- assertBoldExecution(expectedContent, "");
- });
-
- test("collapsed 상태에서 2depth span[style]에서 bold", function() {
- assi.setContent('<p><span style="text-decoration: underline; ">Hello<span style="font-size: 12px; ">World</span></span></p>');
- var p = assi.doc.body.firstChild;
- var world = p.firstChild.childNodes[1].firstChild;
- assi.selectForNodes(world, 1, world, 1);
-
- var expectedContent = '<p><span style="text-decoration: underline; ">Hello</span><span style="text-decoration: underline; font-size: 12px; ">W</span><span style="text-decoration: underline; font-size: 12px; font-weight: bold"></span><span style="text-decoration: underline; font-size: 12px; ">orld</span></p>';
- assertBoldExecution(expectedContent, "");
- });
-
- test("collapsed 상태에서 B,U가 포함된 P에서 bold하기", function() {
- assi.setContent('<p><b>He<u id="u">llo</u></b></p>');
- assi.selectForNodes(assi.$("u").firstChild, 1, assi.$("u").firstChild, 1);
- var expectedContent = '<p><span style="font-weight:bold">He</span>' +
- '<span style="text-decoration:underline; font-weight:bold">l</span>' +
- '<span style="text-decoration:underline"></span>' +
- '<span style="text-decoration:underline; font-weight:bold">lo</span></p>';
- assertBoldExecution(expectedContent, "");
- });
-
- test("collapsed 상태에서 스타일이 적용된 dummy가 있는 span내에서 bold", function() {
- var span = ax.span({style: {fontSize: "20px", color: "#ff0000"}}, assi.processor.newDummy());
- var p = ax.p(span);
- assi.setContentElement(p);
- assi.selectForNodes(span.firstChild, 0, span.firstChild, 0);
-
- var expectedContent = '<p><span style="font-size:20px; color:#ff0000; font-weight:bold;"></span></p>';
- assertBoldExecution(expectedContent, "");
- });
-
- test("collapsed 상태에서 스타일이 적용된 공백있는 span 내에서 bold", function() {
- assi.setContent('<p><span style="font-size:20px; color:#ff0000;">&nbsp;</span></p>');
- var span = assi.byTag("span");
- assi.selectForNodes(span.firstChild, 0, span.firstChild, 0);
-
- var expectedContent = '<p><span style="font-size:20px; color:#ff0000; font-weight:bold;"></span><span style="font-size:20px; color:#ff0000;">&nbsp;</span></p>';
- assertBoldExecution(expectedContent, "");
- });
-
- test("style이 적용된 p에서 bold하기", function() {
- assi.setContent("<p id='p' style='font-weight:bold'>Hello</p>");
- assi.selectForNodes(assi.$('p').firstChild, 2, assi.$('p').firstChild, 2);
- var expectedContent = '<p id="p"><span style="font-weight:bold">He</span><span></span><span style="font-weight:bold">llo</span></p>';
- assertBoldExecution(expectedContent, "");
- });
-
- test("style이 적용된 div > p에서 bold하기", function() {
- var div = ax.div({style : {fontWeight: "bold"}}, ax.p("Hello", ax.span({style: {fontStyle: "italic"}}, "World")));
- assi.setContentElement(div);
- var p = assi.byTag('p');
- assi.selectForNodes(p.firstChild, 2, p.firstChild, 2);
- var expectedContent = '<div><p><span style="font-weight:bold">He</span><span></span><span style="font-weight:bold">llo</span><span style="font-weight:bold;font-style:italic;">World</span></p></div>';
- assertBoldExecution(expectedContent, "");
- });
-})();
-
-(function() {
- module("bold selected");
-
- // He~ll~o -> He<span style="font-weight: bold">ll</span>
- test("TextNode 중 일부분Select해서 bold하기", function() {
- assi.setContent("<p>Hello</p>");
- var p = assi.doc.body.firstChild;
- assi.selectForNodes(p.firstChild, 2, p.firstChild, 4);
- var expectedContent = '<p>He<span style="font-weight: bold; ">ll</span>o</p>';
- assertBoldExecution(expectedContent, "ll");
- });
-
- test("span > blockquote 인 경우", function() {
- assi.setContent("<span>Hello<blockquote>World</blockquote>");
- assi.selectNodeContents(assi.doc.body);
- var expectedContent = "<p><span style='font-weight: bold'>Hello</span>" + ($tx.msie ? " " : "") + "<blockquote><span style='font-weight: bold;'>World</span></blockquote></p>";
- assertBoldExecution(expectedContent, "Hello\\s*World");
- });
-
- test("blockquote 안에 있는 닫히지 않은 span", function() {
- assi.setContent("<blockquote><span>Hello</blockquote>World");
- assi.fix();
- assi.selectNodeContents(assi.doc.body);
- var expectedContent = "<blockquote><span style='font-weight: bold'>Hello</span></blockquote><p><span style='font-weight: bold;'>World</span></p>";
- assertBoldExecution(expectedContent, "Hello\\s*World");
- });
-
- test("span 안의 일부를 Select해서 bold하기", function() {
- assi.setContent('<p><span id="s" style="font-style: italic; ">Hello</span></p>');
- var span = assi.$('s');
- assi.selectForNodes(span.firstChild, 2, span.firstChild, 4);
- var expectedContent = '<p><span id="s" style="font-style: italic; ">He</span><span style="font-style: italic; font-weight: bold; ">ll</span><span style="font-style: italic; ">o</span></p>';
- assertBoldExecution(expectedContent, "ll");
- });
-
- test("font: bold 14px dotum", function() {
- var content = '<p><A style="font: normal normal bold 14px/normal dotum" href="about:blank"><SPAN>Hello</SPAN></A></p>';
- assi.setContent(content);
- var span = assi.byTag('span');
- assi.selectForNodes(span.firstChild, 1, span.firstChild, 2);
- var affectedNode = ax.div(ax.span("H", {style: {font: "bold 14px dotum"}}), ax.span("e", {style: {font: "14px dotum"}}), ax.span("llo", {style: {font: "bold 14px dotum"}}));
- var affectedHTML = affectedNode.innerHTML;
- var expectedContent = '<p><a href="about:blank">' + affectedHTML + '</a></p>';
- assertBoldExecution(expectedContent, "e");
- });
-
-
- test("unbold하기", function() {
- assi.setContent("<p><span style='font-weight:bold;'>Hello</span></p>");
- var p = assi.doc.body.firstChild;
- assi.selectForNodes(p.firstChild.firstChild, 0, p.firstChild.firstChild, 5);
- var expectedContent = '<p>Hello</p>';
- assertBoldExecution(expectedContent, "Hello");
- });
-
- test("2개의 span에 걸쳐 selection하고 bold", function() {
- assi.setContent("<p><span>He</span><span>llo</span></p>");
- var span1 = assi.doc.body.childNodes[0].childNodes[0];
- var span2 = assi.doc.body.childNodes[0].childNodes[1];
- assi.selectForNodes(span1.firstChild, 1, span2.firstChild, 1);
- var expectedContent = '<p><span>H</span><span style="font-weight: bold; ">e</span><span style="font-weight: bold; ">l</span><span>lo</span></p>';
- assertBoldExecution(expectedContent, "el");
- });
-
- // TODO 테스트 케이스에 추가하기
- // <span>He</span><a href="target">ll</a><span>o</span>
- // <span>He<a href="target">ll</a>o</span>
- // <span>He<a href="target"><img src="img"></a>llo</span>
- // <span>He<a href="target"><span>l</span>l</a>o</span>
-
- test("a tag의 안의 일부 Text를 bold", function() {
- assi.setContent('<p><a>Hello</a></p>');
- var p = assi.doc.body.firstChild;
- var a = p.firstChild;
- assi.selectForNodes(a.firstChild, 2, a.firstChild, 4);
- var expectedContent = '<p><a>He<span style="font-weight: bold; ">ll</span>o</a></p>';
- assertBoldExecution(expectedContent, "ll");
- });
-
- test("a tag의 안의 일부 Text를 unbold", function() {
- assi.setContent('<p><a style="font-weight:bold">Hello</a></p>');
- var p = assi.doc.body.firstChild;
- var a = p.firstChild;
- assi.selectForNodes(a.firstChild, 2, a.firstChild, 4);
- var expectedContent = '<p><a><span style="font-weight:bold;">He</span>ll<span style="font-weight:bold;">o</span></a></p>';
- assertBoldExecution(expectedContent, "ll");
- });
-
- test("a와 span 걸쳐서 select하고 bold", function() {
- assi.setContent('<p><a>Hello</a><span>World</span></p>');
- var p = assi.doc.body.firstChild;
- var a = p.firstChild;
- var span = p.childNodes[1];
- assi.selectForNodes(a.firstChild, 2, span.firstChild, 2);
- var expectedContent = '<p><a>He<span style="font-weight: bold; ">llo</span></a><span style="font-weight: bold; ">Wo</span><span>rld</span></p>';
- assertBoldExecution(expectedContent, "lloWo");
- });
-
- test("두 개의 %paragraph(p,div)를 걸쳐서 select하고 bold", function() {
- assi.setContent('<p><span>Hello</span></p><div>World</div>');
- var p1 = assi.doc.body.childNodes[0];
- var p2 = assi.doc.body.childNodes[1];
- assi.selectForNodes(p1.firstChild.firstChild, 2, p2.firstChild, 2);
- var expectedContent = '<p><span>He</span><span style="font-weight: bold; ">llo</span></p><div><span style="font-weight: bold; ">Wo</span>rld</div>';
- assertBoldExecution(expectedContent, "llo\\s*Wo");
- });
-
- test("P로 감싸여지지 않은 텍스트 노드에 대한 selected bold 처리", function() {
- assi.setContent("Hello");
- var body = assi.doc.body;
- assi.selectForNodes(body.firstChild, 2, body.firstChild, 4);
- var expectedContent = '<p>He<span style="font-weight: bold; ">ll</span>o</p>';
- assertBoldExecution(expectedContent, "ll");
- });
-
- test("P로 감쎠여지지 않은 span에 대한 selected bold 처리", function() {
- var span = ax.span("Hello");
- assi.setContentElement(span);
- assi.selectForNodes(span.firstChild, 2, span.firstChild, 4);
- var expectedContent = '<p><span>He</span><span style="font-weight: bold; ">ll</span><span>o</span></p>';
- assertBoldExecution(expectedContent, "ll");
- });
-
- test("flatten되지 않은 두 개의 P,DIV를 선택해서 bold", function() {
- assi.setContent('<p><span id="first">Hello<span>World</span></span></p><div><span>Hello<span id="second">World</span></span></div>');
- assi.selectForNodes(assi.$("first").firstChild, 2, assi.$("second").firstChild, 3);
- var expectedContent = '<p><span id="first">He</span><span style="font-weight:bold">llo</span><span style="font-weight:bold">World</span></p><div><span style="font-weight:bold">Hello</span><span id="second" style="font-weight:bold">Wor</span><span>ld</span></div>';
- assertBoldExecution(expectedContent, "lloWorld\\s*HelloWor");
- });
-
- test("두 개의 block 중첩", function() {
- assi.setContent('<div><div><span id="1">Hello<span style="font-style: italic">W<a id="2">orl</a>d</span></span></div></div>');
- assi.selectForNodes(assi.$("1").firstChild, 1, assi.$("2").firstChild, 2);
- var expectedContent = '<div><div><span id="1">H</span><span style="font-weight:bold">ello</span><span style="font-style:italic; font-weight:bold">W</span><a id="2"><span style="font-style:italic; font-weight:bold">or</span><span style="font-style:italic">l</span></a><span style="font-style:italic">d</span></div></div>';
- assertBoldExecution(expectedContent, "elloWor");
- });
-
- test("B,U가 포함된 P에서 select해서 bold하기", function() {
- assi.setContent('<p><b>He<u id="u">llo</u></b></p>');
- assi.selectForNodes(assi.$("u").firstChild, 1, assi.$("u").firstChild, 2);
- var expectedContent = '<p><span style="font-weight:bold">He</span>' +
- '<span style="text-decoration:underline; font-weight:bold">l</span>' +
- '<span style="text-decoration:underline">l</span>' +
- '<span style="text-decoration:underline; font-weight:bold">o</span></p>';
- assertBoldExecution(expectedContent, "l");
- });
-
- ignore_test &&
- test("strong > p", function() {
- var p = ax.p(ax.strong(ax.p({id: "p"}, "Hello")));
- // "<p><strong><p>Hello</p></strong></p>"
- assi.setContentElement(p);
- assi.selectForNodes(assi.$('p').firstChild, 1, assi.$('p').firstChild, 2);
- var expectedContent = "";
- assertBoldExecution(expectedContent, "e");
- });
-
- $tx.webkit &&
- test("table의 td를 두 개 걸쳐서 select bold", function() {
- var table = assi.getHTML(ax.table({border: '1'}, ax.tr(ax.td("Hello"), " ", ax.td("World"))));
- assi.setContent(table);
- assi.selectForNodes(assi.byTag("td", 0).firstChild, 2, assi.byTag("td", 1).firstChild, 2);
- var expectedContent = assi.getHTML(ax.table({border:'1'}, ax.tr(ax.td("He", ax.span({style: {fontWeight: "bold"}}, "llo")), ($tx.webkit ? "" : " "), ax.td(ax.span({style: {fontWeight: "bold"}}, "Wo"), "rld"))));
- assertBoldExecution(expectedContent, "llo\\s*Wo");
- });
-
- test("comment가 포함된 본문을 bold하기 - 한메일의 답장쓰기 ", function() {
- var html = "<span>Hello<div><!-- Comment Here --></div>World</span>";
- assi.setContent(html);
- var spanChild = assi.byTag("span", 0).childNodes;
- assi.selectForNodes(spanChild[0], 2, spanChild[2], 2);
- var expectedContent = '<p><span>He</span><span style="font-weight: bold; ">llo</span>' + ($tx.msie ? '\n' : '') + '<div><!-- Comment Here --></div><span style="font-weight: bold; ">Wo</span><span>rld</span></p>';
- assertBoldExecution(expectedContent, "llo\\s*Wo");
- });
-
- test("style이 본문 하단에 있는 경우 bold하기", function() {
- var html = "<p>Hello</p><style></style>\r\n";
- assi.setContent(html);
- assi.selectNodeContents(assi.doc.body);
- var expectedContent;
- expectedContent = '<p><span style="font-weight: bold">Hello</span></p>' + ($tx.msie ? '<span style="font-weight: bold;"></span>' : '') + '<style></style>';
- assertBoldExecution(expectedContent, $tx.msie ? "Hello\\s*\\ufeff\\s*" : "Hello\\s*");
- expectedContent = '<p>Hello</p>' + ($tx.msie ? '<span></span>' : '') + '<style></style>';
- assertBoldExecution(expectedContent, $tx.msie ? "Hello\\s*\\ufeff\\s*" : "Hello\\s*");
- });
-
- test("strong > p 형태의 이상한 구조에서 bold하기", function() {
- assi.setContentElement(ax.strong(ax.p("Hello")));
- assi.selectNodeContents(assi.doc.body);
- var expectedContent = "<p>Hello</p>";
- assertBoldExecution(expectedContent, "Hello");
- });
-
- test("too deep span을 선택해서 bold", function() {
- var html = "Hello\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span>\n" +
- "<span><span><span><span><span><span><span><span><span><span id='last'>\n" +
- "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "</span></span></span></span></span></span></span></span></span></span>\n" +
- "World";
- assi.setContent(html);
- var span = assi.$('last');
- assi.selectForNodes(span.firstChild, 1, span.firstChild, 9);
- var startedAt = new Date().getTime();
-// assi.assertToolExecution("bold", null, function() {
-// console.log(new Date().getTime() - startedAt);
-// });
- });
-})();
-
-(function() {
- module("bold - table cell");
-
- test("TD 두 개를 선택한 상태에서 bold", function() {
- var TABLE_BORDER_1 = {border: "1"};
- var BOLD_STYLE = {style: {fontWeight: "bold"}};
-
- var table = ax.table(TABLE_BORDER_1, ax.tr(ax.td("Hello"), ax.td("World"), ax.td("!!")));
- assi.setContent(assi.getHTML(table));
- var td = assi.byTag('td', 0);
- td.firstChild.splitText(2);
- var third_td = assi.byTag("td", 2);
- assi.selectForNodes(third_td, 0, third_td, 0);
- var expectedContent = assi.getHTML(ax.table(TABLE_BORDER_1, ax.tr(ax.td(ax.span(BOLD_STYLE, "Hello")), ax.td(ax.span(BOLD_STYLE, "World")), ax.td("!!"))));
-
- var originalGetTdArr = assi.processor.table.getTdArr;
- assi.processor.table.getTdArr = function() {
- return [assi.byTag("td", 0), assi.byTag("td", 1)];
- };
- assertBoldExecution(expectedContent, "", function() {
- assi.processor.table.getTdArr = originalGetTdArr;
- });
- });
-})();
-
-module("bold queryCurrentStyle");
-
-test("b태그 안에서collapsed상태에서 queryCurrentStyle", function() {
- assi.setContent("<p><b id='b'>bold</b></p>");
- assi.selectForNodes(assi.$('b').firstChild, 2, assi.$('b').firstChild, 2);
- var range = assi.createGoogRange();
- var state = assi.getTool('bold').queryCurrentStyle(range);
- equal(state, true);
-});
-
-test("b태그 안에서selected상태에서 queryCurrentStyle", function() {
- assi.setContent("<p><b id='b'>bold</b></p>");
- assi.selectForNodes(assi.$('b').firstChild, 0, assi.$('b').firstChild, 2);
- var range = assi.createGoogRange();
- var state = assi.getTool('bold').queryCurrentStyle(range);
- equal(state, true);
-});
+function assertBoldExecution(expectedContent, expectedSelectedText, opt_fn) {
+ assi.assertToolExecution("bold", null, function() {
+ htmlEqual(assi.getContent(), expectedContent);
+ var selectedText = goog.dom.Range.createFromWindow(assi.win).getText();
+ regexpEqual(selectedText, expectedSelectedText);
+ opt_fn && opt_fn();
+ });
+}
+
+!($tx.os_win && $tx.safari) && (function() {
+ module("bold collapsed");
+
+ test("collapsed 상태에서 TextNode를 bold하기", function() {
+ assi.setContent("<p>Hello</p>");
+ var p = assi.doc.body.firstChild;
+ assi.selectForNodes(p.firstChild, 2, p.firstChild, 2);
+ assertBoldExecution('<p>He<span style="font-weight: bold; "></span>llo</p>', "");
+ });
+
+ test("collapsed 상태이고 span에 포함된 TextNode에서 bold하기", function() {
+ assi.setContent('<p><span style="font-style: italic; ">Hello</span></p>');
+ var p = assi.doc.body.firstChild;
+ assi.selectForNodes(p.firstChild.firstChild, 2, p.firstChild.firstChild, 2);
+
+ var expectedContent = '<p><span style="font-style: italic; ">He</span><span style="font-style: italic; font-weight: bold; "></span><span style="font-style: italic; ">llo</span></p>';
+ assertBoldExecution(expectedContent, "");
+ });
+
+ test("collapsed 상태이고, bold된 글자에서 bold를 하면 unbold로 된다.", function() {
+ assi.setContent('<p><span style="font-weight: bold; ">Hello</span></p>');
+ var p = assi.doc.body.firstChild;
+ assi.selectForNodes(p.firstChild.firstChild, 2, p.firstChild.firstChild, 2);
+
+ var expectedContent = '<p><span style="font-weight: bold; ">He</span><span></span><span style="font-weight: bold; ">llo</span></p>';
+ assertBoldExecution(expectedContent, "");
+ });
+
+ test("collapsed 상태에서 2depth span[style]에서 bold", function() {
+ assi.setContent('<p><span style="text-decoration: underline; ">Hello<span style="font-size: 12px; ">World</span></span></p>');
+ var p = assi.doc.body.firstChild;
+ var world = p.firstChild.childNodes[1].firstChild;
+ assi.selectForNodes(world, 1, world, 1);
+
+ var expectedContent = '<p><span style="text-decoration: underline; ">Hello</span><span style="text-decoration: underline; font-size: 12px; ">W</span><span style="text-decoration: underline; font-size: 12px; font-weight: bold"></span><span style="text-decoration: underline; font-size: 12px; ">orld</span></p>';
+ assertBoldExecution(expectedContent, "");
+ });
+
+ test("collapsed 상태에서 B,U가 포함된 P에서 bold하기", function() {
+ assi.setContent('<p><b>He<u id="u">llo</u></b></p>');
+ assi.selectForNodes(assi.$("u").firstChild, 1, assi.$("u").firstChild, 1);
+ var expectedContent = '<p><span style="font-weight:bold">He</span>' +
+ '<span style="text-decoration:underline; font-weight:bold">l</span>' +
+ '<span style="text-decoration:underline"></span>' +
+ '<span style="text-decoration:underline; font-weight:bold">lo</span></p>';
+ assertBoldExecution(expectedContent, "");
+ });
+
+ test("collapsed 상태에서 스타일이 적용된 dummy가 있는 span내에서 bold", function() {
+ var span = ax.span({style: {fontSize: "20px", color: "#ff0000"}}, assi.processor.newDummy());
+ var p = ax.p(span);
+ assi.setContentElement(p);
+ assi.selectForNodes(span.firstChild, 0, span.firstChild, 0);
+
+ var expectedContent = '<p><span style="font-size:20px; color:#ff0000; font-weight:bold;"></span></p>';
+ assertBoldExecution(expectedContent, "");
+ });
+
+ test("collapsed 상태에서 스타일이 적용된 공백있는 span 내에서 bold", function() {
+ assi.setContent('<p><span style="font-size:20px; color:#ff0000;">&nbsp;</span></p>');
+ var span = assi.byTag("span");
+ assi.selectForNodes(span.firstChild, 0, span.firstChild, 0);
+
+ var expectedContent = '<p><span style="font-size:20px; color:#ff0000; font-weight:bold;"></span><span style="font-size:20px; color:#ff0000;">&nbsp;</span></p>';
+ assertBoldExecution(expectedContent, "");
+ });
+
+ test("style이 적용된 p에서 bold하기", function() {
+ assi.setContent("<p id='p' style='font-weight:bold'>Hello</p>");
+ assi.selectForNodes(assi.$('p').firstChild, 2, assi.$('p').firstChild, 2);
+ var expectedContent = '<p id="p"><span style="font-weight:bold">He</span><span></span><span style="font-weight:bold">llo</span></p>';
+ assertBoldExecution(expectedContent, "");
+ });
+
+ test("style이 적용된 div > p에서 bold하기", function() {
+ var div = ax.div({style : {fontWeight: "bold"}}, ax.p("Hello", ax.span({style: {fontStyle: "italic"}}, "World")));
+ assi.setContentElement(div);
+ var p = assi.byTag('p');
+ assi.selectForNodes(p.firstChild, 2, p.firstChild, 2);
+ var expectedContent = '<div><p><span style="font-weight:bold">He</span><span></span><span style="font-weight:bold">llo</span><span style="font-weight:bold;font-style:italic;">World</span></p></div>';
+ assertBoldExecution(expectedContent, "");
+ });
+})();
+
+(function() {
+ module("bold selected");
+
+ // He~ll~o -> He<span style="font-weight: bold">ll</span>
+ test("TextNode 중 일부분Select해서 bold하기", function() {
+ assi.setContent("<p>Hello</p>");
+ var p = assi.doc.body.firstChild;
+ assi.selectForNodes(p.firstChild, 2, p.firstChild, 4);
+ var expectedContent = '<p>He<span style="font-weight: bold; ">ll</span>o</p>';
+ assertBoldExecution(expectedContent, "ll");
+ });
+
+ test("span > blockquote 인 경우", function() {
+ assi.setContent("<span>Hello<blockquote>World</blockquote>");
+ assi.selectNodeContents(assi.doc.body);
+ var expectedContent = "<p><span style='font-weight: bold'>Hello</span>" + ($tx.msie ? " " : "") + "<blockquote><span style='font-weight: bold;'>World</span></blockquote></p>";
+ assertBoldExecution(expectedContent, "Hello\\s*World");
+ });
+
+ test("blockquote 안에 있는 닫히지 않은 span", function() {
+ assi.setContent("<blockquote><span>Hello</blockquote>World");
+ assi.fix();
+ assi.selectNodeContents(assi.doc.body);
+ var expectedContent = "<blockquote><span style='font-weight: bold'>Hello</span></blockquote><p><span style='font-weight: bold;'>World</span></p>";
+ assertBoldExecution(expectedContent, "Hello\\s*World");
+ });
+
+ test("span 안의 일부를 Select해서 bold하기", function() {
+ assi.setContent('<p><span id="s" style="font-style: italic; ">Hello</span></p>');
+ var span = assi.$('s');
+ assi.selectForNodes(span.firstChild, 2, span.firstChild, 4);
+ var expectedContent = '<p><span id="s" style="font-style: italic; ">He</span><span style="font-style: italic; font-weight: bold; ">ll</span><span style="font-style: italic; ">o</span></p>';
+ assertBoldExecution(expectedContent, "ll");
+ });
+
+ test("font: bold 14px dotum", function() {
+ var content = '<p><A style="font: normal normal bold 14px/normal dotum" href="about:blank"><SPAN>Hello</SPAN></A></p>';
+ assi.setContent(content);
+ var span = assi.byTag('span');
+ assi.selectForNodes(span.firstChild, 1, span.firstChild, 2);
+ var affectedNode = ax.div(ax.span("H", {style: {font: "bold 14px dotum"}}), ax.span("e", {style: {font: "14px dotum"}}), ax.span("llo", {style: {font: "bold 14px dotum"}}));
+ var affectedHTML = affectedNode.innerHTML;
+ var expectedContent = '<p><a href="about:blank">' + affectedHTML + '</a></p>';
+ assertBoldExecution(expectedContent, "e");
+ });
+
+
+ test("unbold하기", function() {
+ assi.setContent("<p><span style='font-weight:bold;'>Hello</span></p>");
+ var p = assi.doc.body.firstChild;
+ assi.selectForNodes(p.firstChild.firstChild, 0, p.firstChild.firstChild, 5);
+ var expectedContent = '<p>Hello</p>';
+ assertBoldExecution(expectedContent, "Hello");
+ });
+
+ test("2개의 span에 걸쳐 selection하고 bold", function() {
+ assi.setContent("<p><span>He</span><span>llo</span></p>");
+ var span1 = assi.doc.body.childNodes[0].childNodes[0];
+ var span2 = assi.doc.body.childNodes[0].childNodes[1];
+ assi.selectForNodes(span1.firstChild, 1, span2.firstChild, 1);
+ var expectedContent = '<p><span>H</span><span style="font-weight: bold; ">e</span><span style="font-weight: bold; ">l</span><span>lo</span></p>';
+ assertBoldExecution(expectedContent, "el");
+ });
+
+ // TODO 테스트 케이스에 추가하기
+ // <span>He</span><a href="target">ll</a><span>o</span>
+ // <span>He<a href="target">ll</a>o</span>
+ // <span>He<a href="target"><img src="img"></a>llo</span>
+ // <span>He<a href="target"><span>l</span>l</a>o</span>
+
+ test("a tag의 안의 일부 Text를 bold", function() {
+ assi.setContent('<p><a>Hello</a></p>');
+ var p = assi.doc.body.firstChild;
+ var a = p.firstChild;
+ assi.selectForNodes(a.firstChild, 2, a.firstChild, 4);
+ var expectedContent = '<p><a>He<span style="font-weight: bold; ">ll</span>o</a></p>';
+ assertBoldExecution(expectedContent, "ll");
+ });
+
+ test("a tag의 안의 일부 Text를 unbold", function() {
+ assi.setContent('<p><a style="font-weight:bold">Hello</a></p>');
+ var p = assi.doc.body.firstChild;
+ var a = p.firstChild;
+ assi.selectForNodes(a.firstChild, 2, a.firstChild, 4);
+ var expectedContent = '<p><a><span style="font-weight:bold;">He</span>ll<span style="font-weight:bold;">o</span></a></p>';
+ assertBoldExecution(expectedContent, "ll");
+ });
+
+ test("a와 span 걸쳐서 select하고 bold", function() {
+ assi.setContent('<p><a>Hello</a><span>World</span></p>');
+ var p = assi.doc.body.firstChild;
+ var a = p.firstChild;
+ var span = p.childNodes[1];
+ assi.selectForNodes(a.firstChild, 2, span.firstChild, 2);
+ var expectedContent = '<p><a>He<span style="font-weight: bold; ">llo</span></a><span style="font-weight: bold; ">Wo</span><span>rld</span></p>';
+ assertBoldExecution(expectedContent, "lloWo");
+ });
+
+ test("두 개의 %paragraph(p,div)를 걸쳐서 select하고 bold", function() {
+ assi.setContent('<p><span>Hello</span></p><div>World</div>');
+ var p1 = assi.doc.body.childNodes[0];
+ var p2 = assi.doc.body.childNodes[1];
+ assi.selectForNodes(p1.firstChild.firstChild, 2, p2.firstChild, 2);
+ var expectedContent = '<p><span>He</span><span style="font-weight: bold; ">llo</span></p><div><span style="font-weight: bold; ">Wo</span>rld</div>';
+ assertBoldExecution(expectedContent, "llo\\s*Wo");
+ });
+
+ test("P로 감싸여지지 않은 텍스트 노드에 대한 selected bold 처리", function() {
+ assi.setContent("Hello");
+ var body = assi.doc.body;
+ assi.selectForNodes(body.firstChild, 2, body.firstChild, 4);
+ var expectedContent = '<p>He<span style="font-weight: bold; ">ll</span>o</p>';
+ assertBoldExecution(expectedContent, "ll");
+ });
+
+ test("P로 감쎠여지지 않은 span에 대한 selected bold 처리", function() {
+ var span = ax.span("Hello");
+ assi.setContentElement(span);
+ assi.selectForNodes(span.firstChild, 2, span.firstChild, 4);
+ var expectedContent = '<p><span>He</span><span style="font-weight: bold; ">ll</span><span>o</span></p>';
+ assertBoldExecution(expectedContent, "ll");
+ });
+
+ test("flatten되지 않은 두 개의 P,DIV를 선택해서 bold", function() {
+ assi.setContent('<p><span id="first">Hello<span>World</span></span></p><div><span>Hello<span id="second">World</span></span></div>');
+ assi.selectForNodes(assi.$("first").firstChild, 2, assi.$("second").firstChild, 3);
+ var expectedContent = '<p><span id="first">He</span><span style="font-weight:bold">llo</span><span style="font-weight:bold">World</span></p><div><span style="font-weight:bold">Hello</span><span id="second" style="font-weight:bold">Wor</span><span>ld</span></div>';
+ assertBoldExecution(expectedContent, "lloWorld\\s*HelloWor");
+ });
+
+ test("두 개의 block 중첩", function() {
+ assi.setContent('<div><div><span id="1">Hello<span style="font-style: italic">W<a id="2">orl</a>d</span></span></div></div>');
+ assi.selectForNodes(assi.$("1").firstChild, 1, assi.$("2").firstChild, 2);
+ var expectedContent = '<div><div><span id="1">H</span><span style="font-weight:bold">ello</span><span style="font-style:italic; font-weight:bold">W</span><a id="2"><span style="font-style:italic; font-weight:bold">or</span><span style="font-style:italic">l</span></a><span style="font-style:italic">d</span></div></div>';
+ assertBoldExecution(expectedContent, "elloWor");
+ });
+
+ test("B,U가 포함된 P에서 select해서 bold하기", function() {
+ assi.setContent('<p><b>He<u id="u">llo</u></b></p>');
+ assi.selectForNodes(assi.$("u").firstChild, 1, assi.$("u").firstChild, 2);
+ var expectedContent = '<p><span style="font-weight:bold">He</span>' +
+ '<span style="text-decoration:underline; font-weight:bold">l</span>' +
+ '<span style="text-decoration:underline">l</span>' +
+ '<span style="text-decoration:underline; font-weight:bold">o</span></p>';
+ assertBoldExecution(expectedContent, "l");
+ });
+
+ ignore_test &&
+ test("strong > p", function() {
+ var p = ax.p(ax.strong(ax.p({id: "p"}, "Hello")));
+ // "<p><strong><p>Hello</p></strong></p>"
+ assi.setContentElement(p);
+ assi.selectForNodes(assi.$('p').firstChild, 1, assi.$('p').firstChild, 2);
+ var expectedContent = "";
+ assertBoldExecution(expectedContent, "e");
+ });
+
+ $tx.webkit &&
+ test("table의 td를 두 개 걸쳐서 select bold", function() {
+ var table = assi.getHTML(ax.table({border: '1'}, ax.tr(ax.td("Hello"), " ", ax.td("World"))));
+ assi.setContent(table);
+ assi.selectForNodes(assi.byTag("td", 0).firstChild, 2, assi.byTag("td", 1).firstChild, 2);
+ var expectedContent = assi.getHTML(ax.table({border:'1'}, ax.tr(ax.td("He", ax.span({style: {fontWeight: "bold"}}, "llo")), ($tx.webkit ? "" : " "), ax.td(ax.span({style: {fontWeight: "bold"}}, "Wo"), "rld"))));
+