Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 "use strict";
7 const TWO_SPACES_CODE = [
8 "/*",
9 " * tricky comment block",
10 " */",
11 "div {",
12 " color: red;",
13 " background: blue;",
14 "}",
15 " ",
16 "span {",
17 " padding-left: 10px;",
18 "}"
19 ].join("\n");
21 const FOUR_SPACES_CODE = [
22 "var obj = {",
23 " addNumbers: function() {",
24 " var x = 5;",
25 " var y = 18;",
26 " return x + y;",
27 " },",
28 " ",
29 " /*",
30 " * Do some stuff to two numbers",
31 " * ",
32 " * @param x",
33 " * @param y",
34 " * ",
35 " * @return the result of doing stuff",
36 " */",
37 " subtractNumbers: function(x, y) {",
38 " var x += 7;",
39 " var y += 18;",
40 " var result = x - y;",
41 " result %= 2;",
42 " }",
43 "}"
44 ].join("\n");
46 const TABS_CODE = [
47 "/*",
48 " * tricky comment block",
49 " */",
50 "div {",
51 "\tcolor: red;",
52 "\tbackground: blue;",
53 "}",
54 "",
55 "span {",
56 "\tpadding-left: 10px;",
57 "}"
58 ].join("\n");
60 const NONE_CODE = [
61 "var x = 0;",
62 " // stray thing",
63 "var y = 9;",
64 " ",
65 ""
66 ].join("\n");
68 function test() {
69 waitForExplicitFinish();
71 setup((ed, win) => {
72 is(ed.getOption("indentUnit"), 2,
73 "2 spaces before code added");
74 is(ed.getOption("indentWithTabs"), false,
75 "spaces is default");
77 ed.setText(NONE_CODE);
78 is(ed.getOption("indentUnit"), 2,
79 "2 spaces after un-detectable code");
80 is(ed.getOption("indentWithTabs"), false,
81 "spaces still set after un-detectable code");
83 ed.setText(FOUR_SPACES_CODE);
84 is(ed.getOption("indentUnit"), 4,
85 "4 spaces detected in 4 space code");
86 is(ed.getOption("indentWithTabs"), false,
87 "spaces detected in 4 space code");
89 ed.setText(TWO_SPACES_CODE);
90 is(ed.getOption("indentUnit"), 2,
91 "2 spaces detected in 2 space code");
92 is(ed.getOption("indentWithTabs"), false,
93 "spaces detected in 2 space code");
95 ed.setText(TABS_CODE);
96 is(ed.getOption("indentUnit"), 2,
97 "2 space indentation unit");
98 is(ed.getOption("indentWithTabs"), true,
99 "tabs detected in majority tabs code");
101 teardown(ed, win);
102 });
103 }