browser/devtools/styleeditor/test/browser_styleeditor_pretty.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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