diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/debugger/test/mochitest/browser_dbg_auto-pretty-print-02.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-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/debugger/test/mochitest/browser_dbg_auto-pretty-print-02.js')
-rw-r--r-- | devtools/client/debugger/test/mochitest/browser_dbg_auto-pretty-print-02.js | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_auto-pretty-print-02.js b/devtools/client/debugger/test/mochitest/browser_dbg_auto-pretty-print-02.js new file mode 100644 index 000000000..432bc73d2 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg_auto-pretty-print-02.js @@ -0,0 +1,126 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Test that auto pretty printing doesn't accidentally toggle + * pretty printing off when we switch to a minified source + * that is already pretty printed. + */ + +const TAB_URL = EXAMPLE_URL + "doc_auto-pretty-print-02.html"; + +var gTab, gDebuggee, gPanel, gDebugger; +var gEditor, gSources, gPrefs, gOptions, gView; + +var gFirstSource = EXAMPLE_URL + "code_ugly-6.js"; +var gSecondSource = EXAMPLE_URL + "code_ugly-7.js"; + +var gOriginalPref = Services.prefs.getBoolPref("devtools.debugger.auto-pretty-print"); +Services.prefs.setBoolPref("devtools.debugger.auto-pretty-print", true); + +function test() { + let options = { + source: gFirstSource, + line: 1 + }; + initDebugger(TAB_URL, options).then(([aTab, aDebuggee, aPanel]) => { + const gTab = aTab; + const gDebuggee = aDebuggee; + const gPanel = aPanel; + const gDebugger = gPanel.panelWin; + const gEditor = gDebugger.DebuggerView.editor; + const gSources = gDebugger.DebuggerView.Sources; + const gPrefs = gDebugger.Prefs; + const gOptions = gDebugger.DebuggerView.Options; + const gView = gDebugger.DebuggerView; + + // Should be on by default. + testAutoPrettyPrintOn(); + + Task.spawn(function* () { + + testSourceIsUgly(); + + yield waitForSourceShown(gPanel, gFirstSource); + testSourceIsPretty(); + testPrettyPrintButtonOn(); + + // select second source + yield selectSecondSource(); + testSecondSourceLabel(); + + // select first source + yield selectFirstSource(); + testFirstSourceLabel(); + testPrettyPrintButtonOn(); + + // Disable auto pretty printing so it does not affect the following tests. + yield disableAutoPrettyPrint(); + + closeDebuggerAndFinish(gPanel) + .then(null, aError => { + ok(false, "Got an error: " + DevToolsUtils.safeErrorString(aError)); + }); + }); + + function selectSecondSource() { + let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.SOURCE_SHOWN, 2); + gSources.selectedIndex = 1; + return finished; + } + + function selectFirstSource() { + let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.SOURCE_SHOWN); + gSources.selectedIndex = 0; + return finished; + } + + function testSourceIsUgly() { + ok(!gEditor.getText().includes("\n "), + "The source shouldn't be pretty printed yet."); + } + + function testFirstSourceLabel() { + let source = gSources.selectedItem.attachment.source; + ok(source.url === gFirstSource, + "First source url is correct."); + } + + function testSecondSourceLabel() { + let source = gSources.selectedItem.attachment.source; + ok(source.url === gSecondSource, + "Second source url is correct."); + } + + function testAutoPrettyPrintOn() { + is(gPrefs.autoPrettyPrint, true, + "The auto-pretty-print pref should be on."); + is(gOptions._autoPrettyPrint.getAttribute("checked"), "true", + "The Auto pretty print menu item should be checked."); + } + + function testPrettyPrintButtonOn() { + is(gDebugger.document.getElementById("pretty-print").checked, true, + "The button should be checked when the source is selected."); + } + + function disableAutoPrettyPrint() { + gOptions._autoPrettyPrint.setAttribute("checked", "false"); + gOptions._toggleAutoPrettyPrint(); + gOptions._onPopupHidden(); + info("Disabled auto pretty printing."); + } + + function testSourceIsPretty() { + ok(gEditor.getText().includes("\n "), + "The source should be pretty printed."); + } + + registerCleanupFunction(function () { + Services.prefs.setBoolPref("devtools.debugger.auto-pretty-print", gOriginalPref); + }); + + }); +} |