michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: "use strict"; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: setup((ed, win) => { michael@0: // appendTo michael@0: let src = win.document.querySelector("iframe").getAttribute("src"); michael@0: ok(~src.indexOf(".CodeMirror"), "correct iframe is there"); michael@0: michael@0: // getOption/setOption michael@0: ok(ed.getOption("styleActiveLine"), "getOption works"); michael@0: ed.setOption("styleActiveLine", false); michael@0: ok(!ed.getOption("styleActiveLine"), "setOption works"); michael@0: michael@0: // Language modes michael@0: is(ed.getMode(), Editor.modes.text, "getMode"); michael@0: ed.setMode(Editor.modes.js); michael@0: is(ed.getMode(), Editor.modes.js, "setMode"); michael@0: michael@0: // Content michael@0: is(ed.getText(), "Hello.", "getText"); michael@0: ed.setText("Hi.\nHow are you?"); michael@0: is(ed.getText(), "Hi.\nHow are you?", "setText"); michael@0: is(ed.getText(1), "How are you?", "getText(num)"); michael@0: is(ed.getText(5), "", "getText(num) when num is out of scope"); michael@0: michael@0: ed.replaceText("YOU", { line: 1, ch: 8 }, { line: 1, ch: 11 }); michael@0: is(ed.getText(1), "How are YOU?", "replaceText(str, from, to)"); michael@0: ed.replaceText("you?", { line: 1, ch: 8 }); michael@0: is(ed.getText(1), "How are you?", "replaceText(str, from)"); michael@0: ed.replaceText("Hello."); michael@0: is(ed.getText(), "Hello.", "replaceText(str)"); michael@0: michael@0: ed.insertText(", sir/madam", { line: 0, ch: 5}); michael@0: is(ed.getText(), "Hello, sir/madam.", "insertText"); michael@0: michael@0: // Add-ons michael@0: ed.extend({ whoami: () => "Anton", whereami: () => "Mozilla" }); michael@0: is(ed.whoami(), "Anton", "extend/1"); michael@0: is(ed.whereami(), "Mozilla", "extend/2"); michael@0: michael@0: // Line classes michael@0: ed.setText("Hello!\nHow are you?"); michael@0: ok(!ed.hasLineClass(0, "test"), "no test line class"); michael@0: ed.addLineClass(0, "test"); michael@0: ok(ed.hasLineClass(0, "test"), "test line class is there"); michael@0: ed.removeLineClass(0, "test"); michael@0: ok(!ed.hasLineClass(0, "test"), "test line class is gone"); michael@0: michael@0: // Font size michael@0: let size = ed.getFontSize(); michael@0: is("number", typeof size, "we have the default font size"); michael@0: ed.setFontSize(ed.getFontSize() + 1); michael@0: is(ed.getFontSize(), size + 1, "new font size was set"); michael@0: michael@0: teardown(ed, win); michael@0: }); michael@0: }