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 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 2 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 4 | |
michael@0 | 5 | "use strict"; |
michael@0 | 6 | |
michael@0 | 7 | function test() { |
michael@0 | 8 | waitForExplicitFinish(); |
michael@0 | 9 | setup((ed, win) => { |
michael@0 | 10 | // appendTo |
michael@0 | 11 | let src = win.document.querySelector("iframe").getAttribute("src"); |
michael@0 | 12 | ok(~src.indexOf(".CodeMirror"), "correct iframe is there"); |
michael@0 | 13 | |
michael@0 | 14 | // getOption/setOption |
michael@0 | 15 | ok(ed.getOption("styleActiveLine"), "getOption works"); |
michael@0 | 16 | ed.setOption("styleActiveLine", false); |
michael@0 | 17 | ok(!ed.getOption("styleActiveLine"), "setOption works"); |
michael@0 | 18 | |
michael@0 | 19 | // Language modes |
michael@0 | 20 | is(ed.getMode(), Editor.modes.text, "getMode"); |
michael@0 | 21 | ed.setMode(Editor.modes.js); |
michael@0 | 22 | is(ed.getMode(), Editor.modes.js, "setMode"); |
michael@0 | 23 | |
michael@0 | 24 | // Content |
michael@0 | 25 | is(ed.getText(), "Hello.", "getText"); |
michael@0 | 26 | ed.setText("Hi.\nHow are you?"); |
michael@0 | 27 | is(ed.getText(), "Hi.\nHow are you?", "setText"); |
michael@0 | 28 | is(ed.getText(1), "How are you?", "getText(num)"); |
michael@0 | 29 | is(ed.getText(5), "", "getText(num) when num is out of scope"); |
michael@0 | 30 | |
michael@0 | 31 | ed.replaceText("YOU", { line: 1, ch: 8 }, { line: 1, ch: 11 }); |
michael@0 | 32 | is(ed.getText(1), "How are YOU?", "replaceText(str, from, to)"); |
michael@0 | 33 | ed.replaceText("you?", { line: 1, ch: 8 }); |
michael@0 | 34 | is(ed.getText(1), "How are you?", "replaceText(str, from)"); |
michael@0 | 35 | ed.replaceText("Hello."); |
michael@0 | 36 | is(ed.getText(), "Hello.", "replaceText(str)"); |
michael@0 | 37 | |
michael@0 | 38 | ed.insertText(", sir/madam", { line: 0, ch: 5}); |
michael@0 | 39 | is(ed.getText(), "Hello, sir/madam.", "insertText"); |
michael@0 | 40 | |
michael@0 | 41 | // Add-ons |
michael@0 | 42 | ed.extend({ whoami: () => "Anton", whereami: () => "Mozilla" }); |
michael@0 | 43 | is(ed.whoami(), "Anton", "extend/1"); |
michael@0 | 44 | is(ed.whereami(), "Mozilla", "extend/2"); |
michael@0 | 45 | |
michael@0 | 46 | // Line classes |
michael@0 | 47 | ed.setText("Hello!\nHow are you?"); |
michael@0 | 48 | ok(!ed.hasLineClass(0, "test"), "no test line class"); |
michael@0 | 49 | ed.addLineClass(0, "test"); |
michael@0 | 50 | ok(ed.hasLineClass(0, "test"), "test line class is there"); |
michael@0 | 51 | ed.removeLineClass(0, "test"); |
michael@0 | 52 | ok(!ed.hasLineClass(0, "test"), "test line class is gone"); |
michael@0 | 53 | |
michael@0 | 54 | // Font size |
michael@0 | 55 | let size = ed.getFontSize(); |
michael@0 | 56 | is("number", typeof size, "we have the default font size"); |
michael@0 | 57 | ed.setFontSize(ed.getFontSize() + 1); |
michael@0 | 58 | is(ed.getFontSize(), size + 1, "new font size was set"); |
michael@0 | 59 | |
michael@0 | 60 | teardown(ed, win); |
michael@0 | 61 | }); |
michael@0 | 62 | } |