michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Tests that the edit command works michael@0: michael@0: const TEST_URI = "http://example.com/browser/browser/devtools/styleeditor/" + michael@0: "test/browser_styleeditor_cmd_edit.html"; michael@0: michael@0: function test() { michael@0: return Task.spawn(spawnTest).then(finish, helpers.handleError); michael@0: } michael@0: michael@0: function spawnTest() { michael@0: let options = yield helpers.openTab(TEST_URI); michael@0: yield helpers.openToolbar(options); michael@0: michael@0: yield helpers.audit(options, [ michael@0: { michael@0: setup: "edit", michael@0: check: { michael@0: input: 'edit', michael@0: hints: ' [line]', michael@0: markup: 'VVVV', michael@0: status: 'ERROR', michael@0: args: { michael@0: resource: { status: 'INCOMPLETE' }, michael@0: line: { status: 'VALID' }, michael@0: } michael@0: }, michael@0: }, michael@0: { michael@0: setup: "edit i", michael@0: check: { michael@0: input: 'edit i', michael@0: hints: 'nline-css [line]', michael@0: markup: 'VVVVVI', michael@0: status: 'ERROR', michael@0: args: { michael@0: resource: { arg: ' i', status: 'INCOMPLETE' }, michael@0: line: { status: 'VALID' }, michael@0: } michael@0: }, michael@0: }, michael@0: { michael@0: setup: "edit c", michael@0: check: { michael@0: input: 'edit c', michael@0: hints: 'ss#style2 [line]', michael@0: markup: 'VVVVVI', michael@0: status: 'ERROR', michael@0: args: { michael@0: resource: { arg: ' c', status: 'INCOMPLETE' }, michael@0: line: { status: 'VALID' }, michael@0: } michael@0: }, michael@0: }, michael@0: { michael@0: setup: "edit http", michael@0: check: { michael@0: input: 'edit http', michael@0: hints: '://example.com/browser/browser/devtools/styleeditor/test/resources_inpage1.css [line]', michael@0: markup: 'VVVVVIIII', michael@0: status: 'ERROR', michael@0: args: { michael@0: resource: { michael@0: arg: ' http', michael@0: status: 'INCOMPLETE', michael@0: message: 'Value required for \'resource\'.' michael@0: }, michael@0: line: { status: 'VALID' }, michael@0: } michael@0: }, michael@0: }, michael@0: { michael@0: setup: "edit page1", michael@0: check: { michael@0: input: 'edit page1', michael@0: hints: ' [line] -> http://example.com/browser/browser/devtools/styleeditor/test/resources_inpage1.css', michael@0: markup: 'VVVVVIIIII', michael@0: status: 'ERROR', michael@0: args: { michael@0: resource: { michael@0: arg: ' page1', michael@0: status: 'INCOMPLETE', michael@0: message: 'Value required for \'resource\'.' michael@0: }, michael@0: line: { status: 'VALID' }, michael@0: } michael@0: }, michael@0: }, michael@0: { michael@0: setup: "edit page2", michael@0: check: { michael@0: input: 'edit page2', michael@0: hints: ' [line] -> http://example.com/browser/browser/devtools/styleeditor/test/resources_inpage2.css', michael@0: markup: 'VVVVVIIIII', michael@0: status: 'ERROR', michael@0: args: { michael@0: resource: { michael@0: arg: ' page2', michael@0: status: 'INCOMPLETE', michael@0: message: 'Value required for \'resource\'.' michael@0: }, michael@0: line: { status: 'VALID' }, michael@0: } michael@0: }, michael@0: }, michael@0: { michael@0: setup: "edit stylez", michael@0: check: { michael@0: input: 'edit stylez', michael@0: hints: ' [line]', michael@0: markup: 'VVVVVEEEEEE', michael@0: status: 'ERROR', michael@0: args: { michael@0: resource: { arg: ' stylez', status: 'ERROR', message: 'Can\'t use \'stylez\'.' }, michael@0: line: { status: 'VALID' }, michael@0: } michael@0: }, michael@0: }, michael@0: { michael@0: setup: "edit css#style2", michael@0: check: { michael@0: input: 'edit css#style2', michael@0: hints: ' [line]', michael@0: markup: 'VVVVVVVVVVVVVVV', michael@0: status: 'VALID', michael@0: args: { michael@0: resource: { arg: ' css#style2', status: 'VALID', message: '' }, michael@0: line: { status: 'VALID' }, michael@0: } michael@0: }, michael@0: }, michael@0: { michael@0: setup: "edit css#style2 5", michael@0: check: { michael@0: input: 'edit css#style2 5', michael@0: hints: '', michael@0: markup: 'VVVVVVVVVVVVVVVVV', michael@0: status: 'VALID', michael@0: args: { michael@0: resource: { arg: ' css#style2', status: 'VALID', message: '' }, michael@0: line: { value: 5, arg: ' 5', status: 'VALID' }, michael@0: } michael@0: }, michael@0: }, michael@0: { michael@0: setup: "edit css#style2 0", michael@0: check: { michael@0: input: 'edit css#style2 0', michael@0: hints: '', michael@0: markup: 'VVVVVVVVVVVVVVVVE', michael@0: status: 'ERROR', michael@0: args: { michael@0: resource: { arg: ' css#style2', status: 'VALID', message: '' }, michael@0: line: { arg: ' 0', status: 'ERROR', message: '0 is smaller than minimum allowed: 1.' }, michael@0: } michael@0: }, michael@0: }, michael@0: { michael@0: setup: "edit css#style2 -1", michael@0: check: { michael@0: input: 'edit css#style2 -1', michael@0: hints: '', michael@0: markup: 'VVVVVVVVVVVVVVVVEE', michael@0: status: 'ERROR', michael@0: args: { michael@0: resource: { arg: ' css#style2', status: 'VALID', message: '' }, michael@0: line: { arg: ' -1', status: 'ERROR', message: '-1 is smaller than minimum allowed: 1.' }, michael@0: } michael@0: }, michael@0: } michael@0: ]); michael@0: michael@0: let toolbox = gDevTools.getToolbox(options.target); michael@0: ok(toolbox == null, 'toolbox is closed'); michael@0: michael@0: yield helpers.audit(options, [ michael@0: { michael@0: setup: "edit css#style2", michael@0: check: { michael@0: input: "edit css#style2", michael@0: args: { michael@0: resource: { michael@0: value: function(resource) { michael@0: let style2 = options.window.document.getElementById("style2"); michael@0: return resource.element.ownerNode == style2; michael@0: } michael@0: } michael@0: } michael@0: }, michael@0: exec: { output: "" } michael@0: }, michael@0: ]); michael@0: michael@0: let toolbox = gDevTools.getToolbox(options.target); michael@0: ok(toolbox != null, "toolbox is open"); michael@0: michael@0: let styleEditor = toolbox.getCurrentPanel(); michael@0: ok(typeof styleEditor.selectStyleSheet === "function", "styleeditor is open"); michael@0: michael@0: yield toolbox.destroy(); michael@0: michael@0: yield helpers.closeToolbar(options); michael@0: yield helpers.closeTab(options); michael@0: }