michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Make sure that prettifying HTML sources doesn't do anything. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_included-script.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: let gEditor, gSources, gControllerSources; michael@0: michael@0: function test() { michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: gTab = aTab; michael@0: gDebuggee = aDebuggee; michael@0: gPanel = aPanel; michael@0: gDebugger = gPanel.panelWin; michael@0: gEditor = gDebugger.DebuggerView.editor; michael@0: gSources = gDebugger.DebuggerView.Sources; michael@0: gControllerSources = gDebugger.DebuggerController.SourceScripts; michael@0: michael@0: Task.spawn(function() { michael@0: yield waitForSourceShown(gPanel, TAB_URL); michael@0: michael@0: // From this point onward, the source editor's text should never change. michael@0: gEditor.once("change", () => { michael@0: ok(false, "The source editor text shouldn't have changed."); michael@0: }); michael@0: michael@0: is(gSources.selectedValue, TAB_URL, michael@0: "The correct source is currently selected."); michael@0: ok(gEditor.getText().contains("myFunction"), michael@0: "The source shouldn't be pretty printed yet."); michael@0: michael@0: clickPrettyPrintButton(); michael@0: michael@0: let { source } = gSources.selectedItem.attachment; michael@0: try { michael@0: yield gControllerSources.togglePrettyPrint(source); michael@0: ok(false, "The promise for a prettified source should be rejected!"); michael@0: } catch ([source, error]) { michael@0: is(error, "Can't prettify non-javascript files.", michael@0: "The promise was correctly rejected with a meaningful message."); michael@0: } michael@0: michael@0: let [source, text] = yield gControllerSources.getText(source); michael@0: is(gSources.selectedValue, TAB_URL, michael@0: "The correct source is still selected."); michael@0: ok(gEditor.getText().contains("myFunction"), michael@0: "The displayed source hasn't changed."); michael@0: ok(text.contains("myFunction"), michael@0: "The cached source text wasn't altered in any way."); michael@0: michael@0: yield closeDebuggerAndFinish(gPanel); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function clickPrettyPrintButton() { michael@0: gDebugger.document.getElementById("pretty-print").click(); michael@0: } michael@0: michael@0: function prepareDebugger(aPanel) { michael@0: aPanel._view.Sources.preferredSource = TAB_URL; michael@0: } michael@0: michael@0: registerCleanupFunction(function() { michael@0: gTab = null; michael@0: gDebuggee = null; michael@0: gPanel = null; michael@0: gDebugger = null; michael@0: gEditor = null; michael@0: gSources = null; michael@0: gControllerSources = null; michael@0: });