browser/devtools/scratchpad/test/browser_scratchpad_pprint-02.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/scratchpad/test/browser_scratchpad_pprint-02.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,40 @@
     1.4 +/* vim: set ts=2 et sw=2 tw=80: */
     1.5 +/* Any copyright is dedicated to the Public Domain.
     1.6 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.7 +
     1.8 +function test()
     1.9 +{
    1.10 +  waitForExplicitFinish();
    1.11 +
    1.12 +  gBrowser.selectedTab = gBrowser.addTab();
    1.13 +  gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
    1.14 +    gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
    1.15 +    openScratchpad(runTests);
    1.16 +  }, true);
    1.17 +
    1.18 +  content.location = "data:text/html;charset=utf8,test Scratchpad pretty print.";
    1.19 +}
    1.20 +
    1.21 +let gTabsize;
    1.22 +
    1.23 +function runTests(sw)
    1.24 +{
    1.25 +  gTabsize = Services.prefs.getIntPref("devtools.editor.tabsize");
    1.26 +  Services.prefs.setIntPref("devtools.editor.tabsize", 6);
    1.27 +  const space = " ".repeat(6);
    1.28 +
    1.29 +  const sp = sw.Scratchpad;
    1.30 +  sp.setText("function main() { console.log(5); }");
    1.31 +  sp.prettyPrint().then(() => {
    1.32 +    const prettyText = sp.getText();
    1.33 +    ok(prettyText.contains(space));
    1.34 +    finish();
    1.35 +  }).then(null, error => {
    1.36 +    ok(false, error);
    1.37 +  });
    1.38 +}
    1.39 +
    1.40 +registerCleanupFunction(function () {
    1.41 +  Services.prefs.setIntPref("devtools.editor.tabsize", gTabsize);
    1.42 +  gTabsize = null;
    1.43 +});

mercurial