|
1 /* vim: set ts=2 et sw=2 tw=80: */ |
|
2 /* Any copyright is dedicated to the Public Domain. |
|
3 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
4 |
|
5 function test() |
|
6 { |
|
7 waitForExplicitFinish(); |
|
8 |
|
9 gBrowser.selectedTab = gBrowser.addTab(); |
|
10 gBrowser.selectedBrowser.addEventListener("load", function onLoad() { |
|
11 gBrowser.selectedBrowser.removeEventListener("load", onLoad, true); |
|
12 openScratchpad(runTests); |
|
13 }, true); |
|
14 |
|
15 content.location = "data:text/html;charset=utf8,test Scratchpad pretty print."; |
|
16 } |
|
17 |
|
18 let gTabsize; |
|
19 |
|
20 function runTests(sw) |
|
21 { |
|
22 gTabsize = Services.prefs.getIntPref("devtools.editor.tabsize"); |
|
23 Services.prefs.setIntPref("devtools.editor.tabsize", 6); |
|
24 const space = " ".repeat(6); |
|
25 |
|
26 const sp = sw.Scratchpad; |
|
27 sp.setText("function main() { console.log(5); }"); |
|
28 sp.prettyPrint().then(() => { |
|
29 const prettyText = sp.getText(); |
|
30 ok(prettyText.contains(space)); |
|
31 finish(); |
|
32 }).then(null, error => { |
|
33 ok(false, error); |
|
34 }); |
|
35 } |
|
36 |
|
37 registerCleanupFunction(function () { |
|
38 Services.prefs.setIntPref("devtools.editor.tabsize", gTabsize); |
|
39 gTabsize = null; |
|
40 }); |