browser/devtools/commandline/test/browser_cmd_calllog_chrome.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/commandline/test/browser_cmd_calllog_chrome.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,116 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +* http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +// Tests that the calllog commands works as they should
     1.8 +
     1.9 +const TEST_URI = "data:text/html;charset=utf-8,cmd-calllog-chrome";
    1.10 +
    1.11 +let tests = {};
    1.12 +
    1.13 +function test() {
    1.14 +  return Task.spawn(function() {
    1.15 +    let options = yield helpers.openTab(TEST_URI);
    1.16 +    yield helpers.openToolbar(options);
    1.17 +
    1.18 +    yield helpers.runTests(options, tests);
    1.19 +
    1.20 +    yield helpers.closeToolbar(options);
    1.21 +    yield helpers.closeTab(options);
    1.22 +  }).then(finish, helpers.handleError);
    1.23 +}
    1.24 +
    1.25 +tests.testCallLogStatus = function(options) {
    1.26 +  return helpers.audit(options, [
    1.27 +    {
    1.28 +      setup: "calllog",
    1.29 +      check: {
    1.30 +        status: "ERROR",
    1.31 +        emptyParameters: [ " " ]
    1.32 +      }
    1.33 +    },
    1.34 +    {
    1.35 +      setup: "calllog chromestop",
    1.36 +      check: {
    1.37 +        status: "VALID",
    1.38 +        emptyParameters: [ " " ]
    1.39 +      }
    1.40 +    },
    1.41 +    {
    1.42 +      setup: "calllog chromestart content-variable window",
    1.43 +      check: {
    1.44 +        status: "VALID",
    1.45 +        emptyParameters: [ " " ]
    1.46 +      }
    1.47 +    },
    1.48 +    {
    1.49 +      setup: "calllog chromestart javascript \"({a1: function() {this.a2()},a2: function() {}});\"",
    1.50 +      check: {
    1.51 +        status: "VALID",
    1.52 +        emptyParameters: [ " " ]
    1.53 +      }
    1.54 +    },
    1.55 +  ]);
    1.56 +};
    1.57 +
    1.58 +tests.testCallLogExec = function(options) {
    1.59 +  let deferred = promise.defer();
    1.60 +
    1.61 +  function onWebConsoleOpen(subject) {
    1.62 +    Services.obs.removeObserver(onWebConsoleOpen, "web-console-created");
    1.63 +
    1.64 +    subject.QueryInterface(Ci.nsISupportsString);
    1.65 +    let hud = HUDService.getHudReferenceById(subject.data);
    1.66 +    ok(hud, "console open");
    1.67 +
    1.68 +    helpers.audit(options, [
    1.69 +      {
    1.70 +        setup: "calllog chromestop",
    1.71 +        exec: {
    1.72 +          output: /Stopped call logging/,
    1.73 +        }
    1.74 +      },
    1.75 +      {
    1.76 +        setup: "calllog chromestart javascript XXX",
    1.77 +        exec: {
    1.78 +          output: /following exception/,
    1.79 +        }
    1.80 +      },
    1.81 +      {
    1.82 +        setup: "console clear",
    1.83 +        exec: {
    1.84 +          output: '',
    1.85 +        },
    1.86 +        post: function() {
    1.87 +          let labels = hud.jsterm.outputNode.querySelectorAll(".webconsole-msg-output");
    1.88 +          is(labels.length, 0, "no output in console");
    1.89 +        }
    1.90 +      },
    1.91 +      {
    1.92 +        setup: "console close",
    1.93 +        exec: {
    1.94 +          output: '',
    1.95 +        },
    1.96 +      },
    1.97 +    ]).then(function() {
    1.98 +      deferred.resolve();
    1.99 +    });
   1.100 +  }
   1.101 +  Services.obs.addObserver(onWebConsoleOpen, "web-console-created", false);
   1.102 +
   1.103 +  helpers.audit(options, [
   1.104 +    {
   1.105 +      setup: "calllog chromestop",
   1.106 +      exec: {
   1.107 +        output: /No call logging/
   1.108 +      }
   1.109 +    },
   1.110 +    {
   1.111 +      setup: "calllog chromestart javascript \"({a1: function() {this.a2()},a2: function() {}});\"",
   1.112 +      exec: {
   1.113 +        output: /Call logging started/,
   1.114 +      }
   1.115 +    },
   1.116 +  ]);
   1.117 +
   1.118 +  return deferred.promise;
   1.119 +};

mercurial