|
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 const TESTCASE_URI = TEST_BASE + "minified.html"; |
|
6 |
|
7 let gUI; |
|
8 |
|
9 function test() |
|
10 { |
|
11 waitForExplicitFinish(); |
|
12 |
|
13 addTabAndCheckOnStyleEditorAdded(panel => gUI = panel.UI, editor => { |
|
14 editor.getSourceEditor().then(function() { |
|
15 testEditor(editor); |
|
16 }); |
|
17 }); |
|
18 |
|
19 content.location = TESTCASE_URI; |
|
20 } |
|
21 |
|
22 let editorTestedCount = 0; |
|
23 function testEditor(aEditor) |
|
24 { |
|
25 if (aEditor.styleSheet.styleSheetIndex == 0) { |
|
26 let prettifiedSource = "body\{\r?\n\tbackground\:white;\r?\n\}\r?\n\r?\ndiv\{\r?\n\tfont\-size\:4em;\r?\n\tcolor\:red\r?\n\}\r?\n\r?\nspan\{\r?\n\tcolor\:green;\r?\n\}\r?\n"; |
|
27 let prettifiedSourceRE = new RegExp(prettifiedSource); |
|
28 |
|
29 ok(prettifiedSourceRE.test(aEditor.sourceEditor.getText()), |
|
30 "minified source has been prettified automatically"); |
|
31 editorTestedCount++; |
|
32 let summary = gUI.editors[1].summary; |
|
33 EventUtils.synthesizeMouseAtCenter(summary, {}, gPanelWindow); |
|
34 } |
|
35 |
|
36 if (aEditor.styleSheet.styleSheetIndex == 1) { |
|
37 let originalSource = "body \{ background\: red; \}\r?\ndiv \{\r?\nfont\-size\: 5em;\r?\ncolor\: red\r?\n\}"; |
|
38 let originalSourceRE = new RegExp(originalSource); |
|
39 |
|
40 ok(originalSourceRE.test(aEditor.sourceEditor.getText()), |
|
41 "non-minified source has been left untouched"); |
|
42 editorTestedCount++; |
|
43 } |
|
44 |
|
45 if (editorTestedCount == 2) { |
|
46 gUI = null; |
|
47 finish(); |
|
48 } |
|
49 } |