browser/devtools/commandline/test/browser_gcli_pref2.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/commandline/test/browser_gcli_pref2.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,152 @@
     1.4 +/*
     1.5 + * Copyright 2012, Mozilla Foundation and contributors
     1.6 + *
     1.7 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + * you may not use this file except in compliance with the License.
     1.9 + * You may obtain a copy of the License at
    1.10 + *
    1.11 + * http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + * Unless required by applicable law or agreed to in writing, software
    1.14 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.16 + * See the License for the specific language governing permissions and
    1.17 + * limitations under the License.
    1.18 + */
    1.19 +
    1.20 +'use strict';
    1.21 +// <INJECTED SOURCE:START>
    1.22 +
    1.23 +// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
    1.24 +// DO NOT EDIT IT DIRECTLY
    1.25 +
    1.26 +var exports = {};
    1.27 +
    1.28 +var TEST_URI = "data:text/html;charset=utf-8,<p id='gcli-input'>gcli-testPref2.js</p>";
    1.29 +
    1.30 +function test() {
    1.31 +  return Task.spawn(function() {
    1.32 +    let options = yield helpers.openTab(TEST_URI);
    1.33 +    yield helpers.openToolbar(options);
    1.34 +    gcli.addItems(mockCommands.items);
    1.35 +
    1.36 +    yield helpers.runTests(options, exports);
    1.37 +
    1.38 +    gcli.removeItems(mockCommands.items);
    1.39 +    yield helpers.closeToolbar(options);
    1.40 +    yield helpers.closeTab(options);
    1.41 +  }).then(finish, helpers.handleError);
    1.42 +}
    1.43 +
    1.44 +// <INJECTED SOURCE:END>
    1.45 +
    1.46 +// var assert = require('../testharness/assert');
    1.47 +// var helpers = require('./helpers');
    1.48 +var mockSettings = require('./mockSettings');
    1.49 +var settings = require('gcli/settings');
    1.50 +
    1.51 +exports.testPrefExec = function(options) {
    1.52 +  if (options.requisition.canon.getCommand('pref') == null) {
    1.53 +    assert.log('Skipping test; missing pref command.');
    1.54 +    return;
    1.55 +  }
    1.56 +
    1.57 +  if (options.isRemote) {
    1.58 +    assert.log('Skipping test which assumes local settings.');
    1.59 +    return;
    1.60 +  }
    1.61 +
    1.62 +  var allowSet = settings.getSetting('allowSet');
    1.63 +  var initialAllowSet = allowSet.value;
    1.64 +  allowSet.value = false;
    1.65 +
    1.66 +  assert.is(mockSettings.tempNumber.value, 42, 'set to 42');
    1.67 +
    1.68 +  return helpers.audit(options, [
    1.69 +    {
    1.70 +      // Delegated remote types can't transfer value types so we only test for
    1.71 +      // the value of 'value' when we're local
    1.72 +      skipIf: options.isRemote,
    1.73 +      setup: 'pref set tempNumber 4',
    1.74 +      check: {
    1.75 +        setting: { value: mockSettings.tempNumber },
    1.76 +        args: { value: { value: 4 } }
    1.77 +      }
    1.78 +    },
    1.79 +    {
    1.80 +      skipRemainingIf: options.isNoDom,
    1.81 +      setup:    'pref set tempNumber 4',
    1.82 +      check: {
    1.83 +        input:  'pref set tempNumber 4',
    1.84 +        hints:                       '',
    1.85 +        markup: 'VVVVVVVVVVVVVVVVVVVVV',
    1.86 +        cursor: 21,
    1.87 +        current: 'value',
    1.88 +        status: 'VALID',
    1.89 +        predictions: [ ],
    1.90 +        unassigned: [ ],
    1.91 +        args: {
    1.92 +          command: { name: 'pref set' },
    1.93 +          setting: {
    1.94 +            arg: ' tempNumber',
    1.95 +            status: 'VALID',
    1.96 +            message: ''
    1.97 +          },
    1.98 +          value: {
    1.99 +            arg: ' 4',
   1.100 +            status: 'VALID',
   1.101 +            message: ''
   1.102 +          }
   1.103 +        }
   1.104 +      },
   1.105 +      exec: {
   1.106 +        output: [ /void your warranty/, /I promise/ ]
   1.107 +      },
   1.108 +      post: function() {
   1.109 +        assert.is(mockSettings.tempNumber.value, 42, 'still set to 42');
   1.110 +        allowSet.value = true;
   1.111 +      }
   1.112 +    },
   1.113 +    {
   1.114 +      setup:    'pref set tempNumber 4',
   1.115 +      exec: {
   1.116 +        output: ''
   1.117 +      },
   1.118 +      post: function() {
   1.119 +        assert.is(mockSettings.tempNumber.value, 4, 'set to 4');
   1.120 +      }
   1.121 +    },
   1.122 +    {
   1.123 +      setup:    'pref reset tempNumber',
   1.124 +      check: {
   1.125 +        args: {
   1.126 +          command: { name: 'pref reset' },
   1.127 +          setting: { value: mockSettings.tempNumber }
   1.128 +        }
   1.129 +      },
   1.130 +      exec: {
   1.131 +        output: ''
   1.132 +      },
   1.133 +      post: function() {
   1.134 +        assert.is(mockSettings.tempNumber.value, 42, 'reset to 42');
   1.135 +
   1.136 +        allowSet.value = initialAllowSet;
   1.137 +      }
   1.138 +    },
   1.139 +    {
   1.140 +      skipRemainingIf: function commandPrefListMissing() {
   1.141 +        return options.requisition.canon.getCommand('pref list') == null;
   1.142 +      },
   1.143 +      setup:    'pref list tempNum',
   1.144 +      check: {
   1.145 +        args: {
   1.146 +          command: { name: 'pref list' },
   1.147 +          search: { value: 'tempNum' }
   1.148 +        }
   1.149 +      },
   1.150 +      exec: {
   1.151 +        output: /tempNum/
   1.152 +      }
   1.153 +    },
   1.154 +  ]);
   1.155 +};

mercurial