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