browser/devtools/styleeditor/test/browser_styleeditor_cmd_edit.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/styleeditor/test/browser_styleeditor_cmd_edit.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,206 @@
     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 edit command works
     1.8 +
     1.9 +const TEST_URI = "http://example.com/browser/browser/devtools/styleeditor/" +
    1.10 +                 "test/browser_styleeditor_cmd_edit.html";
    1.11 +
    1.12 +function test() {
    1.13 +  return Task.spawn(spawnTest).then(finish, helpers.handleError);
    1.14 +}
    1.15 +
    1.16 +function spawnTest() {
    1.17 +  let options = yield helpers.openTab(TEST_URI);
    1.18 +  yield helpers.openToolbar(options);
    1.19 +
    1.20 +  yield helpers.audit(options, [
    1.21 +    {
    1.22 +      setup: "edit",
    1.23 +      check: {
    1.24 +        input:  'edit',
    1.25 +        hints:      ' <resource> [line]',
    1.26 +        markup: 'VVVV',
    1.27 +        status: 'ERROR',
    1.28 +        args: {
    1.29 +          resource: { status: 'INCOMPLETE' },
    1.30 +          line: { status: 'VALID' },
    1.31 +        }
    1.32 +      },
    1.33 +    },
    1.34 +    {
    1.35 +      setup: "edit i",
    1.36 +      check: {
    1.37 +        input:  'edit i',
    1.38 +        hints:        'nline-css [line]',
    1.39 +        markup: 'VVVVVI',
    1.40 +        status: 'ERROR',
    1.41 +        args: {
    1.42 +          resource: { arg: ' i', status: 'INCOMPLETE' },
    1.43 +          line: { status: 'VALID' },
    1.44 +        }
    1.45 +      },
    1.46 +    },
    1.47 +    {
    1.48 +      setup: "edit c",
    1.49 +      check: {
    1.50 +        input:  'edit c',
    1.51 +        hints:        'ss#style2 [line]',
    1.52 +        markup: 'VVVVVI',
    1.53 +        status: 'ERROR',
    1.54 +        args: {
    1.55 +          resource: { arg: ' c', status: 'INCOMPLETE' },
    1.56 +          line: { status: 'VALID' },
    1.57 +        }
    1.58 +      },
    1.59 +    },
    1.60 +    {
    1.61 +      setup: "edit http",
    1.62 +      check: {
    1.63 +        input:  'edit http',
    1.64 +        hints:           '://example.com/browser/browser/devtools/styleeditor/test/resources_inpage1.css [line]',
    1.65 +        markup: 'VVVVVIIII',
    1.66 +        status: 'ERROR',
    1.67 +        args: {
    1.68 +          resource: {
    1.69 +            arg: ' http',
    1.70 +            status: 'INCOMPLETE',
    1.71 +            message: 'Value required for \'resource\'.'
    1.72 +          },
    1.73 +          line: { status: 'VALID' },
    1.74 +        }
    1.75 +      },
    1.76 +    },
    1.77 +    {
    1.78 +      setup: "edit page1",
    1.79 +      check: {
    1.80 +        input:  'edit page1',
    1.81 +        hints:            ' [line] -> http://example.com/browser/browser/devtools/styleeditor/test/resources_inpage1.css',
    1.82 +        markup: 'VVVVVIIIII',
    1.83 +        status: 'ERROR',
    1.84 +        args: {
    1.85 +          resource: {
    1.86 +            arg: ' page1',
    1.87 +            status: 'INCOMPLETE',
    1.88 +            message: 'Value required for \'resource\'.'
    1.89 +          },
    1.90 +          line: { status: 'VALID' },
    1.91 +        }
    1.92 +      },
    1.93 +    },
    1.94 +    {
    1.95 +      setup: "edit page2",
    1.96 +      check: {
    1.97 +        input:  'edit page2',
    1.98 +        hints:            ' [line] -> http://example.com/browser/browser/devtools/styleeditor/test/resources_inpage2.css',
    1.99 +        markup: 'VVVVVIIIII',
   1.100 +        status: 'ERROR',
   1.101 +        args: {
   1.102 +          resource: {
   1.103 +            arg: ' page2',
   1.104 +            status: 'INCOMPLETE',
   1.105 +            message: 'Value required for \'resource\'.'
   1.106 +          },
   1.107 +          line: { status: 'VALID' },
   1.108 +        }
   1.109 +      },
   1.110 +    },
   1.111 +    {
   1.112 +      setup: "edit stylez",
   1.113 +      check: {
   1.114 +        input:  'edit stylez',
   1.115 +        hints:             ' [line]',
   1.116 +        markup: 'VVVVVEEEEEE',
   1.117 +        status: 'ERROR',
   1.118 +        args: {
   1.119 +          resource: { arg: ' stylez', status: 'ERROR', message: 'Can\'t use \'stylez\'.' },
   1.120 +          line: { status: 'VALID' },
   1.121 +        }
   1.122 +      },
   1.123 +    },
   1.124 +    {
   1.125 +      setup: "edit css#style2",
   1.126 +      check: {
   1.127 +        input:  'edit css#style2',
   1.128 +        hints:                 ' [line]',
   1.129 +        markup: 'VVVVVVVVVVVVVVV',
   1.130 +        status: 'VALID',
   1.131 +        args: {
   1.132 +          resource: { arg: ' css#style2', status: 'VALID', message: '' },
   1.133 +          line: { status: 'VALID' },
   1.134 +        }
   1.135 +      },
   1.136 +    },
   1.137 +    {
   1.138 +      setup: "edit css#style2 5",
   1.139 +      check: {
   1.140 +        input:  'edit css#style2 5',
   1.141 +        hints:                   '',
   1.142 +        markup: 'VVVVVVVVVVVVVVVVV',
   1.143 +        status: 'VALID',
   1.144 +        args: {
   1.145 +          resource: { arg: ' css#style2', status: 'VALID', message: '' },
   1.146 +          line: { value: 5, arg: ' 5', status: 'VALID' },
   1.147 +        }
   1.148 +      },
   1.149 +    },
   1.150 +    {
   1.151 +      setup: "edit css#style2 0",
   1.152 +      check: {
   1.153 +        input:  'edit css#style2 0',
   1.154 +        hints:                   '',
   1.155 +        markup: 'VVVVVVVVVVVVVVVVE',
   1.156 +        status: 'ERROR',
   1.157 +        args: {
   1.158 +          resource: { arg: ' css#style2', status: 'VALID', message: '' },
   1.159 +          line: { arg: ' 0', status: 'ERROR', message: '0 is smaller than minimum allowed: 1.' },
   1.160 +        }
   1.161 +      },
   1.162 +    },
   1.163 +    {
   1.164 +      setup: "edit css#style2 -1",
   1.165 +      check: {
   1.166 +        input:  'edit css#style2 -1',
   1.167 +        hints:                    '',
   1.168 +        markup: 'VVVVVVVVVVVVVVVVEE',
   1.169 +        status: 'ERROR',
   1.170 +        args: {
   1.171 +          resource: { arg: ' css#style2', status: 'VALID', message: '' },
   1.172 +          line: { arg: ' -1', status: 'ERROR', message: '-1 is smaller than minimum allowed: 1.' },
   1.173 +        }
   1.174 +      },
   1.175 +    }
   1.176 +  ]);
   1.177 +
   1.178 +  let toolbox = gDevTools.getToolbox(options.target);
   1.179 +  ok(toolbox == null, 'toolbox is closed');
   1.180 +
   1.181 +  yield helpers.audit(options, [
   1.182 +    {
   1.183 +      setup: "edit css#style2",
   1.184 +      check: {
   1.185 +        input: "edit css#style2",
   1.186 +        args: {
   1.187 +          resource: {
   1.188 +            value: function(resource) {
   1.189 +              let style2 = options.window.document.getElementById("style2");
   1.190 +              return resource.element.ownerNode == style2;
   1.191 +            }
   1.192 +          }
   1.193 +        }
   1.194 +      },
   1.195 +      exec: { output: "" }
   1.196 +    },
   1.197 +  ]);
   1.198 +
   1.199 +  let toolbox = gDevTools.getToolbox(options.target);
   1.200 +  ok(toolbox != null, "toolbox is open");
   1.201 +
   1.202 +  let styleEditor = toolbox.getCurrentPanel();
   1.203 +  ok(typeof styleEditor.selectStyleSheet === "function", "styleeditor is open");
   1.204 +
   1.205 +  yield toolbox.destroy();
   1.206 +
   1.207 +  yield helpers.closeToolbar(options);
   1.208 +  yield helpers.closeTab(options);
   1.209 +}

mercurial