1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/styleeditor/test/browser_styleeditor_pretty.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 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 +const TESTCASE_URI = TEST_BASE + "minified.html"; 1.9 + 1.10 +let gUI; 1.11 + 1.12 +function test() 1.13 +{ 1.14 + waitForExplicitFinish(); 1.15 + 1.16 + addTabAndCheckOnStyleEditorAdded(panel => gUI = panel.UI, editor => { 1.17 + editor.getSourceEditor().then(function() { 1.18 + testEditor(editor); 1.19 + }); 1.20 + }); 1.21 + 1.22 + content.location = TESTCASE_URI; 1.23 +} 1.24 + 1.25 +let editorTestedCount = 0; 1.26 +function testEditor(aEditor) 1.27 +{ 1.28 + if (aEditor.styleSheet.styleSheetIndex == 0) { 1.29 + 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"; 1.30 + let prettifiedSourceRE = new RegExp(prettifiedSource); 1.31 + 1.32 + ok(prettifiedSourceRE.test(aEditor.sourceEditor.getText()), 1.33 + "minified source has been prettified automatically"); 1.34 + editorTestedCount++; 1.35 + let summary = gUI.editors[1].summary; 1.36 + EventUtils.synthesizeMouseAtCenter(summary, {}, gPanelWindow); 1.37 + } 1.38 + 1.39 + if (aEditor.styleSheet.styleSheetIndex == 1) { 1.40 + let originalSource = "body \{ background\: red; \}\r?\ndiv \{\r?\nfont\-size\: 5em;\r?\ncolor\: red\r?\n\}"; 1.41 + let originalSourceRE = new RegExp(originalSource); 1.42 + 1.43 + ok(originalSourceRE.test(aEditor.sourceEditor.getText()), 1.44 + "non-minified source has been left untouched"); 1.45 + editorTestedCount++; 1.46 + } 1.47 + 1.48 + if (editorTestedCount == 2) { 1.49 + gUI = null; 1.50 + finish(); 1.51 + } 1.52 +}