Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 | } |