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 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * Make sure that updating the editor mode sets the right highlighting engine, |
michael@0 | 6 | * and source URIs with extra query parameters also get the right engine. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | const TAB_URL = EXAMPLE_URL + "doc_editor-mode.html"; |
michael@0 | 10 | |
michael@0 | 11 | let gTab, gDebuggee, gPanel, gDebugger; |
michael@0 | 12 | let gEditor, gSources; |
michael@0 | 13 | |
michael@0 | 14 | function test() { |
michael@0 | 15 | initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
michael@0 | 16 | gTab = aTab; |
michael@0 | 17 | gDebuggee = aDebuggee; |
michael@0 | 18 | gPanel = aPanel; |
michael@0 | 19 | gDebugger = gPanel.panelWin; |
michael@0 | 20 | gEditor = gDebugger.DebuggerView.editor; |
michael@0 | 21 | gSources = gDebugger.DebuggerView.Sources; |
michael@0 | 22 | |
michael@0 | 23 | waitForSourceAndCaretAndScopes(gPanel, "code_test-editor-mode", 1) |
michael@0 | 24 | .then(testInitialSource) |
michael@0 | 25 | .then(testSwitch1) |
michael@0 | 26 | .then(testSwitch2) |
michael@0 | 27 | .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) |
michael@0 | 28 | .then(null, aError => { |
michael@0 | 29 | ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
michael@0 | 30 | }); |
michael@0 | 31 | |
michael@0 | 32 | gDebuggee.firstCall(); |
michael@0 | 33 | }); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | function testInitialSource() { |
michael@0 | 37 | is(gSources.itemCount, 3, |
michael@0 | 38 | "Found the expected number of sources."); |
michael@0 | 39 | |
michael@0 | 40 | is(gEditor.getMode().name, "text", |
michael@0 | 41 | "Found the expected editor mode."); |
michael@0 | 42 | is(gEditor.getText().search(/firstCall/), -1, |
michael@0 | 43 | "The first source is not displayed."); |
michael@0 | 44 | is(gEditor.getText().search(/debugger/), 141, |
michael@0 | 45 | "The second source is displayed."); |
michael@0 | 46 | is(gEditor.getText().search(/banana/), -1, |
michael@0 | 47 | "The third source is not displayed."); |
michael@0 | 48 | |
michael@0 | 49 | let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.SOURCE_SHOWN); |
michael@0 | 50 | gSources.selectedItem = e => e.attachment.label == "code_script-switching-01.js"; |
michael@0 | 51 | return finished; |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | function testSwitch1() { |
michael@0 | 55 | is(gSources.itemCount, 3, |
michael@0 | 56 | "Found the expected number of sources."); |
michael@0 | 57 | |
michael@0 | 58 | is(gEditor.getMode().name, "javascript", |
michael@0 | 59 | "Found the expected editor mode."); |
michael@0 | 60 | is(gEditor.getText().search(/firstCall/), 118, |
michael@0 | 61 | "The first source is displayed."); |
michael@0 | 62 | is(gEditor.getText().search(/debugger/), -1, |
michael@0 | 63 | "The second source is not displayed."); |
michael@0 | 64 | is(gEditor.getText().search(/banana/), -1, |
michael@0 | 65 | "The third source is not displayed."); |
michael@0 | 66 | |
michael@0 | 67 | let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.SOURCE_SHOWN); |
michael@0 | 68 | gSources.selectedItem = e => e.attachment.label == "doc_editor-mode.html"; |
michael@0 | 69 | return finished; |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | function testSwitch2() { |
michael@0 | 73 | is(gSources.itemCount, 3, |
michael@0 | 74 | "Found the expected number of sources."); |
michael@0 | 75 | |
michael@0 | 76 | is(gEditor.getMode().name, "htmlmixed", |
michael@0 | 77 | "Found the expected editor mode."); |
michael@0 | 78 | is(gEditor.getText().search(/firstCall/), -1, |
michael@0 | 79 | "The first source is not displayed."); |
michael@0 | 80 | is(gEditor.getText().search(/debugger/), -1, |
michael@0 | 81 | "The second source is not displayed."); |
michael@0 | 82 | is(gEditor.getText().search(/banana/), 443, |
michael@0 | 83 | "The third source is displayed."); |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | registerCleanupFunction(function() { |
michael@0 | 87 | gTab = null; |
michael@0 | 88 | gDebuggee = null; |
michael@0 | 89 | gPanel = null; |
michael@0 | 90 | gDebugger = null; |
michael@0 | 91 | gEditor = null; |
michael@0 | 92 | gSources = null; |
michael@0 | 93 | }); |