tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_editor_autocomplete_basic.js (1462B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const AUTOCOMPLETION_PREF = "devtools.editor.autocomplete";
      7 
      8 // Test to make sure that different autocompletion modes can be created,
      9 // switched, and destroyed.  This doesn't test the actual autocompletion
     10 // popups, only their integration with the editor.
     11 async function test() {
     12  waitForExplicitFinish();
     13  const { ed, win } = await setup();
     14  const edWin = ed.container.contentWindow.wrappedJSObject;
     15  testJS(ed, edWin);
     16  testCSS(ed, edWin);
     17  testPref(ed, edWin);
     18  teardown(ed, win);
     19 }
     20 
     21 function testJS(ed) {
     22  ok(!ed.getOption("autocomplete"), "Autocompletion is not set");
     23 
     24  ed.setMode(Editor.modes.javascript);
     25  ed.setOption("autocomplete", true);
     26 
     27  ok(ed.getOption("autocomplete"), "Autocompletion is set");
     28 }
     29 
     30 function testCSS(ed) {
     31  ok(ed.getOption("autocomplete"), "Autocompletion is set");
     32 
     33  ed.setMode(Editor.modes.css);
     34  ed.setOption("autocomplete", true);
     35 
     36  ok(ed.getOption("autocomplete"), "Autocompletion is still set");
     37 }
     38 
     39 function testPref(ed) {
     40  ed.setMode(Editor.modes.javascript);
     41  ed.setOption("autocomplete", true);
     42 
     43  ok(ed.getOption("autocomplete"), "Autocompletion is set");
     44 
     45  info("Preffing autocompletion off");
     46  Services.prefs.setBoolPref(AUTOCOMPLETION_PREF, false);
     47 
     48  ok(ed.getOption("autocomplete"), "Autocompletion is still set");
     49 
     50  Services.prefs.clearUserPref(AUTOCOMPLETION_PREF);
     51 }