browser/devtools/commandline/test/browser_cmd_pref3.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 // Tests that the pref commands work
     6 let prefBranch = Cc["@mozilla.org/preferences-service;1"]
     7                     .getService(Ci.nsIPrefService).getBranch(null)
     8                     .QueryInterface(Ci.nsIPrefBranch2);
    10 let supportsString = Cc["@mozilla.org/supports-string;1"]
    11                       .createInstance(Ci.nsISupportsString);
    13 let settings = require("gcli/settings");
    15 const TEST_URI = "data:text/html;charset=utf-8,gcli-pref3";
    17 function test() {
    18   return Task.spawn(spawnTest).then(finish, helpers.handleError);
    19 }
    21 function spawnTest() {
    22   let options = yield helpers.openTab(TEST_URI);
    23   yield helpers.openToolbar(options);
    25   let remoteHostOrig = prefBranch.getComplexValue("devtools.debugger.remote-host",
    26                                                   Ci.nsISupportsString).data;
    27   info("originally: devtools.debugger.remote-host = " + remoteHostOrig);
    29   yield helpers.audit(options, [
    30     {
    31       setup: 'pref show devtools.debugger.remote-host',
    32       check: {
    33         args: {
    34           setting: { value: settings.getSetting("devtools.debugger.remote-host") }
    35         },
    36       },
    37       exec: {
    38         output: new RegExp("^devtools\.debugger\.remote-host: " + remoteHostOrig + "$"),
    39       },
    40     },
    41     {
    42       setup: 'pref set devtools.debugger.remote-host e.com',
    43       check: {
    44         args: {
    45           setting: { value: settings.getSetting("devtools.debugger.remote-host") },
    46           value: { value: "e.com" }
    47         },
    48       },
    49       exec: {
    50         output: '',
    51       },
    52     },
    53     {
    54       setup: 'pref show devtools.debugger.remote-host',
    55       check: {
    56         args: {
    57           setting: { value: settings.getSetting("devtools.debugger.remote-host") }
    58         },
    59       },
    60       exec: {
    61         output: new RegExp("^devtools\.debugger\.remote-host: e.com$"),
    62       },
    63       post: function() {
    64         var ecom = prefBranch.getComplexValue("devtools.debugger.remote-host",
    65                                               Ci.nsISupportsString).data;
    66         is(ecom, "e.com", "devtools.debugger.remote-host is e.com");
    67       }
    68     },
    69     {
    70       setup: 'pref set devtools.debugger.remote-host moz.foo',
    71       check: {
    72         args: {
    73           setting: { value: settings.getSetting("devtools.debugger.remote-host") },
    74           value: { value: "moz.foo" }
    75         },
    76       },
    77       exec: {
    78         output: '',
    79       },
    80     },
    81     {
    82       setup: 'pref show devtools.debugger.remote-host',
    83       check: {
    84         args: {
    85           setting: { value: settings.getSetting("devtools.debugger.remote-host") }
    86         },
    87       },
    88       exec: {
    89         output: new RegExp("^devtools\.debugger\.remote-host: moz.foo$"),
    90       },
    91       post: function() {
    92         var mozfoo = prefBranch.getComplexValue("devtools.debugger.remote-host",
    93                                                 Ci.nsISupportsString).data;
    94         is(mozfoo, "moz.foo", "devtools.debugger.remote-host is moz.foo");
    95       }
    96     },
    97   ]);
    99   supportsString.data = remoteHostOrig;
   100   prefBranch.setComplexValue("devtools.debugger.remote-host",
   101                              Ci.nsISupportsString, supportsString);
   103   yield helpers.closeToolbar(options);
   104   yield helpers.closeTab(options);
   105 }

mercurial