browser/devtools/commandline/test/browser_gcli_pref2.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:cf9fe714694e
1 /*
2 * Copyright 2012, Mozilla Foundation and contributors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 'use strict';
18 // <INJECTED SOURCE:START>
19
20 // THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
21 // DO NOT EDIT IT DIRECTLY
22
23 var exports = {};
24
25 var TEST_URI = "data:text/html;charset=utf-8,<p id='gcli-input'>gcli-testPref2.js</p>";
26
27 function test() {
28 return Task.spawn(function() {
29 let options = yield helpers.openTab(TEST_URI);
30 yield helpers.openToolbar(options);
31 gcli.addItems(mockCommands.items);
32
33 yield helpers.runTests(options, exports);
34
35 gcli.removeItems(mockCommands.items);
36 yield helpers.closeToolbar(options);
37 yield helpers.closeTab(options);
38 }).then(finish, helpers.handleError);
39 }
40
41 // <INJECTED SOURCE:END>
42
43 // var assert = require('../testharness/assert');
44 // var helpers = require('./helpers');
45 var mockSettings = require('./mockSettings');
46 var settings = require('gcli/settings');
47
48 exports.testPrefExec = function(options) {
49 if (options.requisition.canon.getCommand('pref') == null) {
50 assert.log('Skipping test; missing pref command.');
51 return;
52 }
53
54 if (options.isRemote) {
55 assert.log('Skipping test which assumes local settings.');
56 return;
57 }
58
59 var allowSet = settings.getSetting('allowSet');
60 var initialAllowSet = allowSet.value;
61 allowSet.value = false;
62
63 assert.is(mockSettings.tempNumber.value, 42, 'set to 42');
64
65 return helpers.audit(options, [
66 {
67 // Delegated remote types can't transfer value types so we only test for
68 // the value of 'value' when we're local
69 skipIf: options.isRemote,
70 setup: 'pref set tempNumber 4',
71 check: {
72 setting: { value: mockSettings.tempNumber },
73 args: { value: { value: 4 } }
74 }
75 },
76 {
77 skipRemainingIf: options.isNoDom,
78 setup: 'pref set tempNumber 4',
79 check: {
80 input: 'pref set tempNumber 4',
81 hints: '',
82 markup: 'VVVVVVVVVVVVVVVVVVVVV',
83 cursor: 21,
84 current: 'value',
85 status: 'VALID',
86 predictions: [ ],
87 unassigned: [ ],
88 args: {
89 command: { name: 'pref set' },
90 setting: {
91 arg: ' tempNumber',
92 status: 'VALID',
93 message: ''
94 },
95 value: {
96 arg: ' 4',
97 status: 'VALID',
98 message: ''
99 }
100 }
101 },
102 exec: {
103 output: [ /void your warranty/, /I promise/ ]
104 },
105 post: function() {
106 assert.is(mockSettings.tempNumber.value, 42, 'still set to 42');
107 allowSet.value = true;
108 }
109 },
110 {
111 setup: 'pref set tempNumber 4',
112 exec: {
113 output: ''
114 },
115 post: function() {
116 assert.is(mockSettings.tempNumber.value, 4, 'set to 4');
117 }
118 },
119 {
120 setup: 'pref reset tempNumber',
121 check: {
122 args: {
123 command: { name: 'pref reset' },
124 setting: { value: mockSettings.tempNumber }
125 }
126 },
127 exec: {
128 output: ''
129 },
130 post: function() {
131 assert.is(mockSettings.tempNumber.value, 42, 'reset to 42');
132
133 allowSet.value = initialAllowSet;
134 }
135 },
136 {
137 skipRemainingIf: function commandPrefListMissing() {
138 return options.requisition.canon.getCommand('pref list') == null;
139 },
140 setup: 'pref list tempNum',
141 check: {
142 args: {
143 command: { name: 'pref list' },
144 search: { value: 'tempNum' }
145 }
146 },
147 exec: {
148 output: /tempNum/
149 }
150 },
151 ]);
152 };

mercurial