browser/devtools/debugger/test/browser_dbg_cmd-break.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/debugger/test/browser_dbg_cmd-break.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,200 @@
     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 + * Tests that the break commands works as they should.
     1.9 + */
    1.10 +
    1.11 +const TAB_URL = EXAMPLE_URL + "doc_cmd-break.html";
    1.12 +
    1.13 +function test() {
    1.14 +  let gPanel, gDebugger, gThreadClient;
    1.15 +  let gLineNumber;
    1.16 +
    1.17 +  helpers.addTabWithToolbar(TAB_URL, aOptions => {
    1.18 +    return helpers.audit(aOptions, [
    1.19 +      {
    1.20 +        setup: 'break',
    1.21 +        check: {
    1.22 +          input:  'break',
    1.23 +          hints:       ' add line',
    1.24 +          markup: 'IIIII',
    1.25 +          status: 'ERROR',
    1.26 +        }
    1.27 +      },
    1.28 +      {
    1.29 +        setup: 'break add',
    1.30 +        check: {
    1.31 +          input:  'break add',
    1.32 +          hints:           ' line',
    1.33 +          markup: 'IIIIIVIII',
    1.34 +          status: 'ERROR'
    1.35 +        }
    1.36 +      },
    1.37 +      {
    1.38 +        setup: 'break add line',
    1.39 +        check: {
    1.40 +          input:  'break add line',
    1.41 +          hints:                ' <file> <line>',
    1.42 +          markup: 'VVVVVVVVVVVVVV',
    1.43 +          status: 'ERROR'
    1.44 +        }
    1.45 +      },
    1.46 +      {
    1.47 +        name: 'open toolbox',
    1.48 +        setup: function() {
    1.49 +          return initDebugger(gBrowser.selectedTab).then(([aTab, aDebuggee, aPanel]) => {
    1.50 +            // Spin the event loop before causing the debuggee to pause, to allow
    1.51 +            // this function to return first.
    1.52 +            executeSoon(() => aDebuggee.firstCall());
    1.53 +
    1.54 +            return waitForSourceAndCaretAndScopes(aPanel, ".html", 1).then(() => {
    1.55 +              gPanel = aPanel;
    1.56 +              gDebugger = gPanel.panelWin;
    1.57 +              gThreadClient = gPanel.panelWin.gThreadClient;
    1.58 +              gLineNumber = '' + aOptions.window.wrappedJSObject.gLineNumber;
    1.59 +            });
    1.60 +          });
    1.61 +        },
    1.62 +        post: function() {
    1.63 +          ok(gThreadClient, "Debugger client exists.");
    1.64 +          is(gLineNumber, 1, "gLineNumber is correct.");
    1.65 +        },
    1.66 +      },
    1.67 +      {
    1.68 +        name: 'break add line .../doc_cmd-break.html 14',
    1.69 +        setup: function() {
    1.70 +          // We have to setup in a function to allow gLineNumber to be initialized.
    1.71 +          let line = 'break add line ' + TAB_URL + ' ' + gLineNumber;
    1.72 +          return helpers.setInput(aOptions, line);
    1.73 +        },
    1.74 +        check: {
    1.75 +          hints: '',
    1.76 +          status: 'VALID',
    1.77 +          message: '',
    1.78 +          args: {
    1.79 +            file: { value: TAB_URL, message: '' },
    1.80 +            line: { value: 1 }
    1.81 +          }
    1.82 +        },
    1.83 +        exec: {
    1.84 +          output: 'Added breakpoint'
    1.85 +        }
    1.86 +      },
    1.87 +      {
    1.88 +        setup: 'break add line ' + TAB_URL + ' 17',
    1.89 +        check: {
    1.90 +          hints: '',
    1.91 +          status: 'VALID',
    1.92 +          message: '',
    1.93 +          args: {
    1.94 +            file: { value: TAB_URL, message: '' },
    1.95 +            line: { value: 17 }
    1.96 +          }
    1.97 +        },
    1.98 +        exec: {
    1.99 +          output: 'Added breakpoint'
   1.100 +        }
   1.101 +      },
   1.102 +      {
   1.103 +        setup: 'break list',
   1.104 +        check: {
   1.105 +          input:  'break list',
   1.106 +          hints:            '',
   1.107 +          markup: 'VVVVVVVVVV',
   1.108 +          status: 'VALID'
   1.109 +        },
   1.110 +        exec: {
   1.111 +          output: [
   1.112 +            /Source/, /Remove/,
   1.113 +            /doc_cmd-break\.html:1/,
   1.114 +            /doc_cmd-break\.html:1/
   1.115 +          ]
   1.116 +        }
   1.117 +      },
   1.118 +      {
   1.119 +        name: 'cleanup',
   1.120 +        setup: function() {
   1.121 +          let deferred = promise.defer();
   1.122 +          gThreadClient.resume(deferred.resolve);
   1.123 +          return deferred.promise;
   1.124 +        }
   1.125 +      },
   1.126 +      {
   1.127 +        setup: 'break del 1',
   1.128 +        check: {
   1.129 +          input:  'break del 1',
   1.130 +          hints:              ' -> doc_cmd-break.html:1',
   1.131 +          markup: 'VVVVVVVVVVI',
   1.132 +          status: 'ERROR',
   1.133 +          args: {
   1.134 +            breakpoint: {
   1.135 +              status: 'INCOMPLETE',
   1.136 +              message: 'Value required for \'breakpoint\'.'
   1.137 +            }
   1.138 +          }
   1.139 +        }
   1.140 +      },
   1.141 +      {
   1.142 +        setup: 'break del doc_cmd-break.html:1',
   1.143 +        check: {
   1.144 +          input:  'break del doc_cmd-break.html:1',
   1.145 +          hints:                                 '',
   1.146 +          markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVV',
   1.147 +          status: 'VALID',
   1.148 +          args: {
   1.149 +            breakpoint: { arg: ' doc_cmd-break.html:1' },
   1.150 +          }
   1.151 +        },
   1.152 +        exec: {
   1.153 +          output: 'Breakpoint removed'
   1.154 +        }
   1.155 +      },
   1.156 +      {
   1.157 +        setup: 'break list',
   1.158 +        check: {
   1.159 +          input:  'break list',
   1.160 +          hints:            '',
   1.161 +          markup: 'VVVVVVVVVV',
   1.162 +          status: 'VALID'
   1.163 +        },
   1.164 +        exec: {
   1.165 +          output: [
   1.166 +            /Source/, /Remove/,
   1.167 +            /doc_cmd-break\.html:17/
   1.168 +          ]
   1.169 +        }
   1.170 +      },
   1.171 +      {
   1.172 +        setup: 'break del doc_cmd-break.html:17',
   1.173 +        check: {
   1.174 +          input:  'break del doc_cmd-break.html:17',
   1.175 +          hints:                                 '',
   1.176 +          markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV',
   1.177 +          status: 'VALID',
   1.178 +          args: {
   1.179 +            breakpoint: { arg: ' doc_cmd-break.html:17' },
   1.180 +          }
   1.181 +        },
   1.182 +        exec: {
   1.183 +          output: 'Breakpoint removed'
   1.184 +        }
   1.185 +      },
   1.186 +      {
   1.187 +        setup: 'break list',
   1.188 +        check: {
   1.189 +          input:  'break list',
   1.190 +          hints:            '',
   1.191 +          markup: 'VVVVVVVVVV',
   1.192 +          status: 'VALID'
   1.193 +        },
   1.194 +        exec: {
   1.195 +          output: 'No breakpoints set'
   1.196 +        },
   1.197 +        post: function() {
   1.198 +          return teardown(gPanel, { noTabRemoval: true });
   1.199 +        }
   1.200 +      },
   1.201 +    ]);
   1.202 +  }).then(finish);
   1.203 +}

mercurial