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 updating the editor mode sets the right highlighting engine, michael@0: * and source URIs with extra query parameters also get the right engine. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_editor-mode.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: let gEditor, gSources; 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: michael@0: waitForSourceAndCaretAndScopes(gPanel, "code_test-editor-mode", 1) michael@0: .then(testInitialSource) michael@0: .then(testSwitch1) michael@0: .then(testSwitch2) michael@0: .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) michael@0: .then(null, aError => { michael@0: ok(false, "Got an error: " + aError.message + "\n" + aError.stack); michael@0: }); michael@0: michael@0: gDebuggee.firstCall(); michael@0: }); michael@0: } michael@0: michael@0: function testInitialSource() { michael@0: is(gSources.itemCount, 3, michael@0: "Found the expected number of sources."); michael@0: michael@0: is(gEditor.getMode().name, "text", michael@0: "Found the expected editor mode."); michael@0: is(gEditor.getText().search(/firstCall/), -1, michael@0: "The first source is not displayed."); michael@0: is(gEditor.getText().search(/debugger/), 141, michael@0: "The second source is displayed."); michael@0: is(gEditor.getText().search(/banana/), -1, michael@0: "The third source is not displayed."); michael@0: michael@0: let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.SOURCE_SHOWN); michael@0: gSources.selectedItem = e => e.attachment.label == "code_script-switching-01.js"; michael@0: return finished; michael@0: } michael@0: michael@0: function testSwitch1() { michael@0: is(gSources.itemCount, 3, michael@0: "Found the expected number of sources."); michael@0: michael@0: is(gEditor.getMode().name, "javascript", michael@0: "Found the expected editor mode."); michael@0: is(gEditor.getText().search(/firstCall/), 118, michael@0: "The first source is displayed."); michael@0: is(gEditor.getText().search(/debugger/), -1, michael@0: "The second source is not displayed."); michael@0: is(gEditor.getText().search(/banana/), -1, michael@0: "The third source is not displayed."); michael@0: michael@0: let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.SOURCE_SHOWN); michael@0: gSources.selectedItem = e => e.attachment.label == "doc_editor-mode.html"; michael@0: return finished; michael@0: } michael@0: michael@0: function testSwitch2() { michael@0: is(gSources.itemCount, 3, michael@0: "Found the expected number of sources."); michael@0: michael@0: is(gEditor.getMode().name, "htmlmixed", michael@0: "Found the expected editor mode."); michael@0: is(gEditor.getText().search(/firstCall/), -1, michael@0: "The first source is not displayed."); michael@0: is(gEditor.getText().search(/debugger/), -1, michael@0: "The second source is not displayed."); michael@0: is(gEditor.getText().search(/banana/), 443, michael@0: "The third source is displayed."); 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: });