browser/devtools/debugger/test/browser_dbg_editor-mode.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial