summaryrefslogtreecommitdiffstats
path: root/devtools/client/sourceeditor/test/browser_editor_addons.js
blob: 6a7e9ca4261ad24739df740f449554984191488c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

function test() {
  waitForExplicitFinish();

  setup((ed, win) => {
    let doc = win.document.querySelector("iframe").contentWindow.document;

    // trailingspace.js
    ed.setText("Hello   ");
    ed.setOption("showTrailingSpace", false);
    ok(!doc.querySelector(".cm-trailingspace"));
    ed.setOption("showTrailingSpace", true);
    ok(doc.querySelector(".cm-trailingspace"));

    // foldcode.js and foldgutter.js
    ed.setMode(Editor.modes.js);
    ed.setText("function main() {\nreturn 'Hello, World!';\n}");
    executeSoon(() => testFold(doc, ed, win));
  });
}

function testFold(doc, ed, win) {
  // Wait until folding arrow is there.
  if (!doc.querySelector(".CodeMirror-foldgutter-open")) {
    executeSoon(() => testFold(doc, ed, win));
    return;
  }

  teardown(ed, win);
}