summaryrefslogtreecommitdiffstats
path: root/devtools/client/shared/sourceeditor/test/browser_editor_addons.js
blob: 85aec38ec34068cfd229dc292f1803ef25745f18 (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

async function test() {
  waitForExplicitFinish();

  const { ed, win } = await setup();
  const 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);
}