1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_editor-mode.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,93 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Make sure that updating the editor mode sets the right highlighting engine, 1.9 + * and source URIs with extra query parameters also get the right engine. 1.10 + */ 1.11 + 1.12 +const TAB_URL = EXAMPLE_URL + "doc_editor-mode.html"; 1.13 + 1.14 +let gTab, gDebuggee, gPanel, gDebugger; 1.15 +let gEditor, gSources; 1.16 + 1.17 +function test() { 1.18 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.19 + gTab = aTab; 1.20 + gDebuggee = aDebuggee; 1.21 + gPanel = aPanel; 1.22 + gDebugger = gPanel.panelWin; 1.23 + gEditor = gDebugger.DebuggerView.editor; 1.24 + gSources = gDebugger.DebuggerView.Sources; 1.25 + 1.26 + waitForSourceAndCaretAndScopes(gPanel, "code_test-editor-mode", 1) 1.27 + .then(testInitialSource) 1.28 + .then(testSwitch1) 1.29 + .then(testSwitch2) 1.30 + .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) 1.31 + .then(null, aError => { 1.32 + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); 1.33 + }); 1.34 + 1.35 + gDebuggee.firstCall(); 1.36 + }); 1.37 +} 1.38 + 1.39 +function testInitialSource() { 1.40 + is(gSources.itemCount, 3, 1.41 + "Found the expected number of sources."); 1.42 + 1.43 + is(gEditor.getMode().name, "text", 1.44 + "Found the expected editor mode."); 1.45 + is(gEditor.getText().search(/firstCall/), -1, 1.46 + "The first source is not displayed."); 1.47 + is(gEditor.getText().search(/debugger/), 141, 1.48 + "The second source is displayed."); 1.49 + is(gEditor.getText().search(/banana/), -1, 1.50 + "The third source is not displayed."); 1.51 + 1.52 + let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.SOURCE_SHOWN); 1.53 + gSources.selectedItem = e => e.attachment.label == "code_script-switching-01.js"; 1.54 + return finished; 1.55 +} 1.56 + 1.57 +function testSwitch1() { 1.58 + is(gSources.itemCount, 3, 1.59 + "Found the expected number of sources."); 1.60 + 1.61 + is(gEditor.getMode().name, "javascript", 1.62 + "Found the expected editor mode."); 1.63 + is(gEditor.getText().search(/firstCall/), 118, 1.64 + "The first source is displayed."); 1.65 + is(gEditor.getText().search(/debugger/), -1, 1.66 + "The second source is not displayed."); 1.67 + is(gEditor.getText().search(/banana/), -1, 1.68 + "The third source is not displayed."); 1.69 + 1.70 + let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.SOURCE_SHOWN); 1.71 + gSources.selectedItem = e => e.attachment.label == "doc_editor-mode.html"; 1.72 + return finished; 1.73 +} 1.74 + 1.75 +function testSwitch2() { 1.76 + is(gSources.itemCount, 3, 1.77 + "Found the expected number of sources."); 1.78 + 1.79 + is(gEditor.getMode().name, "htmlmixed", 1.80 + "Found the expected editor mode."); 1.81 + is(gEditor.getText().search(/firstCall/), -1, 1.82 + "The first source is not displayed."); 1.83 + is(gEditor.getText().search(/debugger/), -1, 1.84 + "The second source is not displayed."); 1.85 + is(gEditor.getText().search(/banana/), 443, 1.86 + "The third source is displayed."); 1.87 +} 1.88 + 1.89 +registerCleanupFunction(function() { 1.90 + gTab = null; 1.91 + gDebuggee = null; 1.92 + gPanel = null; 1.93 + gDebugger = null; 1.94 + gEditor = null; 1.95 + gSources = null; 1.96 +});