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

     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/ */
     5 const TESTCASE_URI = TEST_BASE + "minified.html";
     7 let gUI;
     9 function test()
    10 {
    11   waitForExplicitFinish();
    13   addTabAndCheckOnStyleEditorAdded(panel => gUI = panel.UI, editor => {
    14     editor.getSourceEditor().then(function() {
    15       testEditor(editor);
    16     });
    17   });
    19   content.location = TESTCASE_URI;
    20 }
    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);
    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   }
    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);
    40     ok(originalSourceRE.test(aEditor.sourceEditor.getText()),
    41        "non-minified source has been left untouched");
    42     editorTestedCount++;
    43   }
    45   if (editorTestedCount == 2) {
    46     gUI = null;
    47     finish();
    48   }
    49 }

mercurial