michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: const TESTCASE_URI = TEST_BASE + "minified.html"; michael@0: michael@0: let gUI; michael@0: michael@0: function test() michael@0: { michael@0: waitForExplicitFinish(); michael@0: michael@0: addTabAndCheckOnStyleEditorAdded(panel => gUI = panel.UI, editor => { michael@0: editor.getSourceEditor().then(function() { michael@0: testEditor(editor); michael@0: }); michael@0: }); michael@0: michael@0: content.location = TESTCASE_URI; michael@0: } michael@0: michael@0: let editorTestedCount = 0; michael@0: function testEditor(aEditor) michael@0: { michael@0: if (aEditor.styleSheet.styleSheetIndex == 0) { michael@0: 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"; michael@0: let prettifiedSourceRE = new RegExp(prettifiedSource); michael@0: michael@0: ok(prettifiedSourceRE.test(aEditor.sourceEditor.getText()), michael@0: "minified source has been prettified automatically"); michael@0: editorTestedCount++; michael@0: let summary = gUI.editors[1].summary; michael@0: EventUtils.synthesizeMouseAtCenter(summary, {}, gPanelWindow); michael@0: } michael@0: michael@0: if (aEditor.styleSheet.styleSheetIndex == 1) { michael@0: let originalSource = "body \{ background\: red; \}\r?\ndiv \{\r?\nfont\-size\: 5em;\r?\ncolor\: red\r?\n\}"; michael@0: let originalSourceRE = new RegExp(originalSource); michael@0: michael@0: ok(originalSourceRE.test(aEditor.sourceEditor.getText()), michael@0: "non-minified source has been left untouched"); michael@0: editorTestedCount++; michael@0: } michael@0: michael@0: if (editorTestedCount == 2) { michael@0: gUI = null; michael@0: finish(); michael@0: } michael@0: }