browser/devtools/styleeditor/test/browser_styleeditor_pretty.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 2 /* Any copyright is dedicated to the Public Domain.
michael@0 3 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 4
michael@0 5 const TESTCASE_URI = TEST_BASE + "minified.html";
michael@0 6
michael@0 7 let gUI;
michael@0 8
michael@0 9 function test()
michael@0 10 {
michael@0 11 waitForExplicitFinish();
michael@0 12
michael@0 13 addTabAndCheckOnStyleEditorAdded(panel => gUI = panel.UI, editor => {
michael@0 14 editor.getSourceEditor().then(function() {
michael@0 15 testEditor(editor);
michael@0 16 });
michael@0 17 });
michael@0 18
michael@0 19 content.location = TESTCASE_URI;
michael@0 20 }
michael@0 21
michael@0 22 let editorTestedCount = 0;
michael@0 23 function testEditor(aEditor)
michael@0 24 {
michael@0 25 if (aEditor.styleSheet.styleSheetIndex == 0) {
michael@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";
michael@0 27 let prettifiedSourceRE = new RegExp(prettifiedSource);
michael@0 28
michael@0 29 ok(prettifiedSourceRE.test(aEditor.sourceEditor.getText()),
michael@0 30 "minified source has been prettified automatically");
michael@0 31 editorTestedCount++;
michael@0 32 let summary = gUI.editors[1].summary;
michael@0 33 EventUtils.synthesizeMouseAtCenter(summary, {}, gPanelWindow);
michael@0 34 }
michael@0 35
michael@0 36 if (aEditor.styleSheet.styleSheetIndex == 1) {
michael@0 37 let originalSource = "body \{ background\: red; \}\r?\ndiv \{\r?\nfont\-size\: 5em;\r?\ncolor\: red\r?\n\}";
michael@0 38 let originalSourceRE = new RegExp(originalSource);
michael@0 39
michael@0 40 ok(originalSourceRE.test(aEditor.sourceEditor.getText()),
michael@0 41 "non-minified source has been left untouched");
michael@0 42 editorTestedCount++;
michael@0 43 }
michael@0 44
michael@0 45 if (editorTestedCount == 2) {
michael@0 46 gUI = null;
michael@0 47 finish();
michael@0 48 }
michael@0 49 }

mercurial