browser/devtools/styleeditor/test/browser_styleeditor_cmd_edit.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.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 // Tests that the edit command works
michael@0 5
michael@0 6 const TEST_URI = "http://example.com/browser/browser/devtools/styleeditor/" +
michael@0 7 "test/browser_styleeditor_cmd_edit.html";
michael@0 8
michael@0 9 function test() {
michael@0 10 return Task.spawn(spawnTest).then(finish, helpers.handleError);
michael@0 11 }
michael@0 12
michael@0 13 function spawnTest() {
michael@0 14 let options = yield helpers.openTab(TEST_URI);
michael@0 15 yield helpers.openToolbar(options);
michael@0 16
michael@0 17 yield helpers.audit(options, [
michael@0 18 {
michael@0 19 setup: "edit",
michael@0 20 check: {
michael@0 21 input: 'edit',
michael@0 22 hints: ' <resource> [line]',
michael@0 23 markup: 'VVVV',
michael@0 24 status: 'ERROR',
michael@0 25 args: {
michael@0 26 resource: { status: 'INCOMPLETE' },
michael@0 27 line: { status: 'VALID' },
michael@0 28 }
michael@0 29 },
michael@0 30 },
michael@0 31 {
michael@0 32 setup: "edit i",
michael@0 33 check: {
michael@0 34 input: 'edit i',
michael@0 35 hints: 'nline-css [line]',
michael@0 36 markup: 'VVVVVI',
michael@0 37 status: 'ERROR',
michael@0 38 args: {
michael@0 39 resource: { arg: ' i', status: 'INCOMPLETE' },
michael@0 40 line: { status: 'VALID' },
michael@0 41 }
michael@0 42 },
michael@0 43 },
michael@0 44 {
michael@0 45 setup: "edit c",
michael@0 46 check: {
michael@0 47 input: 'edit c',
michael@0 48 hints: 'ss#style2 [line]',
michael@0 49 markup: 'VVVVVI',
michael@0 50 status: 'ERROR',
michael@0 51 args: {
michael@0 52 resource: { arg: ' c', status: 'INCOMPLETE' },
michael@0 53 line: { status: 'VALID' },
michael@0 54 }
michael@0 55 },
michael@0 56 },
michael@0 57 {
michael@0 58 setup: "edit http",
michael@0 59 check: {
michael@0 60 input: 'edit http',
michael@0 61 hints: '://example.com/browser/browser/devtools/styleeditor/test/resources_inpage1.css [line]',
michael@0 62 markup: 'VVVVVIIII',
michael@0 63 status: 'ERROR',
michael@0 64 args: {
michael@0 65 resource: {
michael@0 66 arg: ' http',
michael@0 67 status: 'INCOMPLETE',
michael@0 68 message: 'Value required for \'resource\'.'
michael@0 69 },
michael@0 70 line: { status: 'VALID' },
michael@0 71 }
michael@0 72 },
michael@0 73 },
michael@0 74 {
michael@0 75 setup: "edit page1",
michael@0 76 check: {
michael@0 77 input: 'edit page1',
michael@0 78 hints: ' [line] -> http://example.com/browser/browser/devtools/styleeditor/test/resources_inpage1.css',
michael@0 79 markup: 'VVVVVIIIII',
michael@0 80 status: 'ERROR',
michael@0 81 args: {
michael@0 82 resource: {
michael@0 83 arg: ' page1',
michael@0 84 status: 'INCOMPLETE',
michael@0 85 message: 'Value required for \'resource\'.'
michael@0 86 },
michael@0 87 line: { status: 'VALID' },
michael@0 88 }
michael@0 89 },
michael@0 90 },
michael@0 91 {
michael@0 92 setup: "edit page2",
michael@0 93 check: {
michael@0 94 input: 'edit page2',
michael@0 95 hints: ' [line] -> http://example.com/browser/browser/devtools/styleeditor/test/resources_inpage2.css',
michael@0 96 markup: 'VVVVVIIIII',
michael@0 97 status: 'ERROR',
michael@0 98 args: {
michael@0 99 resource: {
michael@0 100 arg: ' page2',
michael@0 101 status: 'INCOMPLETE',
michael@0 102 message: 'Value required for \'resource\'.'
michael@0 103 },
michael@0 104 line: { status: 'VALID' },
michael@0 105 }
michael@0 106 },
michael@0 107 },
michael@0 108 {
michael@0 109 setup: "edit stylez",
michael@0 110 check: {
michael@0 111 input: 'edit stylez',
michael@0 112 hints: ' [line]',
michael@0 113 markup: 'VVVVVEEEEEE',
michael@0 114 status: 'ERROR',
michael@0 115 args: {
michael@0 116 resource: { arg: ' stylez', status: 'ERROR', message: 'Can\'t use \'stylez\'.' },
michael@0 117 line: { status: 'VALID' },
michael@0 118 }
michael@0 119 },
michael@0 120 },
michael@0 121 {
michael@0 122 setup: "edit css#style2",
michael@0 123 check: {
michael@0 124 input: 'edit css#style2',
michael@0 125 hints: ' [line]',
michael@0 126 markup: 'VVVVVVVVVVVVVVV',
michael@0 127 status: 'VALID',
michael@0 128 args: {
michael@0 129 resource: { arg: ' css#style2', status: 'VALID', message: '' },
michael@0 130 line: { status: 'VALID' },
michael@0 131 }
michael@0 132 },
michael@0 133 },
michael@0 134 {
michael@0 135 setup: "edit css#style2 5",
michael@0 136 check: {
michael@0 137 input: 'edit css#style2 5',
michael@0 138 hints: '',
michael@0 139 markup: 'VVVVVVVVVVVVVVVVV',
michael@0 140 status: 'VALID',
michael@0 141 args: {
michael@0 142 resource: { arg: ' css#style2', status: 'VALID', message: '' },
michael@0 143 line: { value: 5, arg: ' 5', status: 'VALID' },
michael@0 144 }
michael@0 145 },
michael@0 146 },
michael@0 147 {
michael@0 148 setup: "edit css#style2 0",
michael@0 149 check: {
michael@0 150 input: 'edit css#style2 0',
michael@0 151 hints: '',
michael@0 152 markup: 'VVVVVVVVVVVVVVVVE',
michael@0 153 status: 'ERROR',
michael@0 154 args: {
michael@0 155 resource: { arg: ' css#style2', status: 'VALID', message: '' },
michael@0 156 line: { arg: ' 0', status: 'ERROR', message: '0 is smaller than minimum allowed: 1.' },
michael@0 157 }
michael@0 158 },
michael@0 159 },
michael@0 160 {
michael@0 161 setup: "edit css#style2 -1",
michael@0 162 check: {
michael@0 163 input: 'edit css#style2 -1',
michael@0 164 hints: '',
michael@0 165 markup: 'VVVVVVVVVVVVVVVVEE',
michael@0 166 status: 'ERROR',
michael@0 167 args: {
michael@0 168 resource: { arg: ' css#style2', status: 'VALID', message: '' },
michael@0 169 line: { arg: ' -1', status: 'ERROR', message: '-1 is smaller than minimum allowed: 1.' },
michael@0 170 }
michael@0 171 },
michael@0 172 }
michael@0 173 ]);
michael@0 174
michael@0 175 let toolbox = gDevTools.getToolbox(options.target);
michael@0 176 ok(toolbox == null, 'toolbox is closed');
michael@0 177
michael@0 178 yield helpers.audit(options, [
michael@0 179 {
michael@0 180 setup: "edit css#style2",
michael@0 181 check: {
michael@0 182 input: "edit css#style2",
michael@0 183 args: {
michael@0 184 resource: {
michael@0 185 value: function(resource) {
michael@0 186 let style2 = options.window.document.getElementById("style2");
michael@0 187 return resource.element.ownerNode == style2;
michael@0 188 }
michael@0 189 }
michael@0 190 }
michael@0 191 },
michael@0 192 exec: { output: "" }
michael@0 193 },
michael@0 194 ]);
michael@0 195
michael@0 196 let toolbox = gDevTools.getToolbox(options.target);
michael@0 197 ok(toolbox != null, "toolbox is open");
michael@0 198
michael@0 199 let styleEditor = toolbox.getCurrentPanel();
michael@0 200 ok(typeof styleEditor.selectStyleSheet === "function", "styleeditor is open");
michael@0 201
michael@0 202 yield toolbox.destroy();
michael@0 203
michael@0 204 yield helpers.closeToolbar(options);
michael@0 205 yield helpers.closeTab(options);
michael@0 206 }

mercurial