summaryrefslogtreecommitdiffstats
path: root/devtools/client/styleeditor/test/browser_styleeditor_pretty.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/client/styleeditor/test/browser_styleeditor_pretty.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/styleeditor/test/browser_styleeditor_pretty.js')
-rw-r--r--devtools/client/styleeditor/test/browser_styleeditor_pretty.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/devtools/client/styleeditor/test/browser_styleeditor_pretty.js b/devtools/client/styleeditor/test/browser_styleeditor_pretty.js
new file mode 100644
index 000000000..212cab12d
--- /dev/null
+++ b/devtools/client/styleeditor/test/browser_styleeditor_pretty.js
@@ -0,0 +1,68 @@
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
+
+// Test that minified sheets are automatically prettified but other are left
+// untouched.
+
+const TESTCASE_URI = TEST_BASE_HTTP + "minified.html";
+
+/*
+ body {
+ background:white;
+ }
+ div {
+ font-size:4em;
+ color:red
+ }
+ span {
+ color:green;
+ }
+*/
+const PRETTIFIED_SOURCE = "" +
+"body \{\r?\n" +
+ "\tbackground\:white;\r?\n" +
+"\}\r?\n" +
+"div \{\r?\n" +
+ "\tfont\-size\:4em;\r?\n" +
+ "\tcolor\:red\r?\n" +
+"\}\r?\n" +
+"span \{\r?\n" +
+ "\tcolor\:green;\r?\n" +
+"\}\r?\n";
+
+/*
+ body { background: red; }
+ div {
+ font-size: 5em;
+ color: red
+ }
+*/
+const ORIGINAL_SOURCE = "" +
+"body \{ background\: red; \}\r?\n" +
+"div \{\r?\n" +
+ "font\-size\: 5em;\r?\n" +
+ "color\: red\r?\n" +
+"\}";
+
+add_task(function* () {
+ let { ui } = yield openStyleEditorForURL(TESTCASE_URI);
+ is(ui.editors.length, 2, "Two sheets present.");
+
+ info("Testing minified style sheet.");
+ let editor = yield ui.editors[0].getSourceEditor();
+
+ let prettifiedSourceRE = new RegExp(PRETTIFIED_SOURCE);
+ ok(prettifiedSourceRE.test(editor.sourceEditor.getText()),
+ "minified source has been prettified automatically");
+
+ info("Selecting second, non-minified style sheet.");
+ yield ui.selectStyleSheet(ui.editors[1].styleSheet);
+
+ editor = ui.editors[1];
+
+ let originalSourceRE = new RegExp(ORIGINAL_SOURCE);
+ ok(originalSourceRE.test(editor.sourceEditor.getText()),
+ "non-minified source has been left untouched");
+});