michael@0: /* michael@0: * Copyright 2012, Mozilla Foundation and contributors michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: 'use strict'; michael@0: // michael@0: michael@0: // THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT michael@0: // DO NOT EDIT IT DIRECTLY michael@0: michael@0: var exports = {}; michael@0: michael@0: var TEST_URI = "data:text/html;charset=utf-8,

gcli-testJs.js

"; michael@0: michael@0: function test() { michael@0: return Task.spawn(function() { michael@0: let options = yield helpers.openTab(TEST_URI); michael@0: yield helpers.openToolbar(options); michael@0: gcli.addItems(mockCommands.items); michael@0: michael@0: yield helpers.runTests(options, exports); michael@0: michael@0: gcli.removeItems(mockCommands.items); michael@0: yield helpers.closeToolbar(options); michael@0: yield helpers.closeTab(options); michael@0: }).then(finish, helpers.handleError); michael@0: } michael@0: michael@0: // michael@0: michael@0: // var assert = require('../testharness/assert'); michael@0: // var helpers = require('./helpers'); michael@0: var javascript = require('gcli/types/javascript'); michael@0: michael@0: var tempWindow; michael@0: michael@0: exports.setup = function(options) { michael@0: if (options.isNoDom) { michael@0: return; michael@0: } michael@0: michael@0: tempWindow = javascript.getGlobalObject(); michael@0: Object.defineProperty(options.window, 'donteval', { michael@0: get: function() { michael@0: assert.ok(false, 'donteval should not be used'); michael@0: return { cant: '', touch: '', 'this': '' }; michael@0: }, michael@0: enumerable: true, michael@0: configurable : true michael@0: }); michael@0: javascript.setGlobalObject(options.window); michael@0: }; michael@0: michael@0: exports.shutdown = function(options) { michael@0: if (options.isNoDom) { michael@0: return; michael@0: } michael@0: michael@0: javascript.setGlobalObject(tempWindow); michael@0: tempWindow = undefined; michael@0: delete options.window.donteval; michael@0: }; michael@0: michael@0: function jsTestAllowed(options) { michael@0: return options.isRemote || options.isNoDom || michael@0: options.requisition.canon.getCommand('{') == null; michael@0: } michael@0: michael@0: exports.testBasic = function(options) { michael@0: return helpers.audit(options, [ michael@0: { michael@0: skipRemainingIf: jsTestAllowed, michael@0: setup: '{', michael@0: check: { michael@0: input: '{', michael@0: hints: '', michael@0: markup: 'V', michael@0: cursor: 1, michael@0: current: 'javascript', michael@0: status: 'ERROR', michael@0: predictions: [ ], michael@0: unassigned: [ ], michael@0: args: { michael@0: command: { name: '{' }, michael@0: javascript: { michael@0: value: undefined, michael@0: arg: '{', michael@0: status: 'INCOMPLETE' michael@0: } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: '{ ', michael@0: check: { michael@0: input: '{ ', michael@0: hints: '', michael@0: markup: 'VV', michael@0: cursor: 2, michael@0: current: 'javascript', michael@0: status: 'ERROR', michael@0: predictions: [ ], michael@0: unassigned: [ ], michael@0: args: { michael@0: command: { name: '{' }, michael@0: javascript: { michael@0: value: undefined, michael@0: arg: '{ ', michael@0: status: 'INCOMPLETE' michael@0: } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: '{ w', michael@0: check: { michael@0: input: '{ w', michael@0: hints: 'indow', michael@0: markup: 'VVI', michael@0: cursor: 3, michael@0: current: 'javascript', michael@0: status: 'ERROR', michael@0: predictionsContains: [ 'window' ], michael@0: unassigned: [ ], michael@0: args: { michael@0: command: { name: '{' }, michael@0: javascript: { michael@0: value: 'w', michael@0: arg: '{ w', michael@0: status: 'INCOMPLETE' michael@0: } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: '{ windo', michael@0: check: { michael@0: input: '{ windo', michael@0: hints: 'w', michael@0: markup: 'VVIIIII', michael@0: cursor: 7, michael@0: current: 'javascript', michael@0: status: 'ERROR', michael@0: predictions: [ 'window' ], michael@0: unassigned: [ ], michael@0: args: { michael@0: command: { name: '{' }, michael@0: javascript: { michael@0: value: 'windo', michael@0: arg: '{ windo', michael@0: status: 'INCOMPLETE' michael@0: } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: '{ window', michael@0: check: { michael@0: input: '{ window', michael@0: hints: '', michael@0: markup: 'VVVVVVVV', michael@0: cursor: 8, michael@0: current: 'javascript', michael@0: status: 'VALID', michael@0: predictions: [ ], michael@0: unassigned: [ ], michael@0: args: { michael@0: command: { name: '{' }, michael@0: javascript: { michael@0: value: 'window', michael@0: arg: '{ window', michael@0: status: 'VALID', michael@0: message: '' michael@0: } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: '{ window.do', michael@0: check: { michael@0: input: '{ window.do', michael@0: hints: 'cument', michael@0: markup: 'VVIIIIIIIII', michael@0: cursor: 11, michael@0: current: 'javascript', michael@0: status: 'ERROR', michael@0: predictionsContains: [ 'window.document' ], michael@0: unassigned: [ ], michael@0: args: { michael@0: command: { name: '{' }, michael@0: javascript: { michael@0: value: 'window.do', michael@0: arg: '{ window.do', michael@0: status: 'INCOMPLETE' michael@0: } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: '{ window.document.title', michael@0: check: { michael@0: input: '{ window.document.title', michael@0: hints: '', michael@0: markup: 'VVVVVVVVVVVVVVVVVVVVVVV', michael@0: cursor: 23, michael@0: current: 'javascript', michael@0: status: 'VALID', michael@0: predictions: [ ], michael@0: unassigned: [ ], michael@0: args: { michael@0: command: { name: '{' }, michael@0: javascript: { michael@0: value: 'window.document.title', michael@0: arg: '{ window.document.title', michael@0: status: 'VALID', michael@0: message: '' michael@0: } michael@0: } michael@0: } michael@0: } michael@0: ]); michael@0: }; michael@0: michael@0: exports.testDocument = function(options) { michael@0: return helpers.audit(options, [ michael@0: { michael@0: skipRemainingIf: jsTestAllowed, michael@0: setup: '{ docu', michael@0: check: { michael@0: input: '{ docu', michael@0: hints: 'ment', michael@0: markup: 'VVIIII', michael@0: cursor: 6, michael@0: current: 'javascript', michael@0: status: 'ERROR', michael@0: predictions: [ 'document' ], michael@0: unassigned: [ ], michael@0: args: { michael@0: command: { name: '{' }, michael@0: javascript: { michael@0: value: 'docu', michael@0: arg: '{ docu', michael@0: status: 'INCOMPLETE' michael@0: } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: '{ docu', michael@0: check: { michael@0: input: '{ document', michael@0: hints: '', michael@0: markup: 'VVVVVVVVVV', michael@0: cursor: 10, michael@0: current: 'javascript', michael@0: status: 'VALID', michael@0: predictions: [ ], michael@0: unassigned: [ ], michael@0: args: { michael@0: command: { name: '{' }, michael@0: javascript: { michael@0: value: 'document', michael@0: arg: '{ document', michael@0: status: 'VALID', michael@0: message: '' michael@0: } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: '{ document.titl', michael@0: check: { michael@0: input: '{ document.titl', michael@0: hints: 'e', michael@0: markup: 'VVIIIIIIIIIIIII', michael@0: cursor: 15, michael@0: current: 'javascript', michael@0: status: 'ERROR', michael@0: predictions: [ 'document.title' ], michael@0: unassigned: [ ], michael@0: args: { michael@0: command: { name: '{' }, michael@0: javascript: { michael@0: value: 'document.titl', michael@0: arg: '{ document.titl', michael@0: status: 'INCOMPLETE' michael@0: } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: '{ document.titl', michael@0: check: { michael@0: input: '{ document.title ', michael@0: hints: '', michael@0: markup: 'VVVVVVVVVVVVVVVVV', michael@0: cursor: 17, michael@0: current: 'javascript', michael@0: status: 'VALID', michael@0: predictions: [ ], michael@0: unassigned: [ ], michael@0: args: { michael@0: command: { name: '{' }, michael@0: javascript: { michael@0: value: 'document.title', michael@0: arg: '{ document.title ', michael@0: status: 'VALID', michael@0: message: '' michael@0: } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: '{ document.title', michael@0: check: { michael@0: input: '{ document.title', michael@0: hints: '', michael@0: markup: 'VVVVVVVVVVVVVVVV', michael@0: cursor: 16, michael@0: current: 'javascript', michael@0: status: 'VALID', michael@0: predictions: [ ], michael@0: unassigned: [ ], michael@0: args: { michael@0: command: { name: '{' }, michael@0: javascript: { michael@0: value: 'document.title', michael@0: arg: '{ document.title', michael@0: status: 'VALID', michael@0: message: '' michael@0: } michael@0: } michael@0: } michael@0: } michael@0: ]); michael@0: }; michael@0: michael@0: exports.testDonteval = function(options) { michael@0: if (!options.isNoDom) { michael@0: // nodom causes an eval here, maybe that's node/v8? michael@0: assert.ok('donteval' in options.window, 'donteval exists'); michael@0: } michael@0: michael@0: return helpers.audit(options, [ michael@0: { michael@0: skipRemainingIf: jsTestAllowed, michael@0: setup: '{ don', michael@0: check: { michael@0: input: '{ don', michael@0: hints: 'teval', michael@0: markup: 'VVIII', michael@0: cursor: 5, michael@0: current: 'javascript', michael@0: status: 'ERROR', michael@0: predictions: [ 'donteval' ], michael@0: unassigned: [ ], michael@0: args: { michael@0: command: { name: '{' }, michael@0: javascript: { michael@0: value: 'don', michael@0: arg: '{ don', michael@0: status: 'INCOMPLETE' michael@0: } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: '{ donteval', michael@0: check: { michael@0: input: '{ donteval', michael@0: hints: '', michael@0: markup: 'VVVVVVVVVV', michael@0: cursor: 10, michael@0: current: 'javascript', michael@0: status: 'VALID', michael@0: predictions: [ ], michael@0: unassigned: [ ], michael@0: args: { michael@0: command: { name: '{' }, michael@0: javascript: { michael@0: value: 'donteval', michael@0: arg: '{ donteval', michael@0: status: 'VALID', michael@0: message: '' michael@0: } michael@0: } michael@0: } michael@0: }, michael@0: /* michael@0: // This is a controversial test - technically we can tell that it's an error michael@0: // because 'donteval.' is a syntax error, however donteval is unsafe so we michael@0: // are playing safe by bailing out early. It's enough of a corner case that michael@0: // I don't think it warrants fixing michael@0: { michael@0: setup: '{ donteval.', michael@0: check: { michael@0: input: '{ donteval.', michael@0: hints: '', michael@0: markup: 'VVVVVVVVVVV', michael@0: cursor: 11, michael@0: current: 'javascript', michael@0: status: 'VALID', michael@0: predictions: [ ], michael@0: unassigned: [ ], michael@0: args: { michael@0: command: { name: '{' }, michael@0: javascript: { michael@0: value: 'donteval.', michael@0: arg: '{ donteval.', michael@0: status: 'VALID', michael@0: message: '' michael@0: } michael@0: } michael@0: } michael@0: }, michael@0: */ michael@0: { michael@0: setup: '{ donteval.cant', michael@0: check: { michael@0: input: '{ donteval.cant', michael@0: hints: '', michael@0: markup: 'VVVVVVVVVVVVVVV', michael@0: cursor: 15, michael@0: current: 'javascript', michael@0: status: 'VALID', michael@0: predictions: [ ], michael@0: unassigned: [ ], michael@0: args: { michael@0: command: { name: '{' }, michael@0: javascript: { michael@0: value: 'donteval.cant', michael@0: arg: '{ donteval.cant', michael@0: status: 'VALID', michael@0: message: '' michael@0: } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: '{ donteval.xxx', michael@0: check: { michael@0: input: '{ donteval.xxx', michael@0: hints: '', michael@0: markup: 'VVVVVVVVVVVVVV', michael@0: cursor: 14, michael@0: current: 'javascript', michael@0: status: 'VALID', michael@0: predictions: [ ], michael@0: unassigned: [ ], michael@0: args: { michael@0: command: { name: '{' }, michael@0: javascript: { michael@0: value: 'donteval.xxx', michael@0: arg: '{ donteval.xxx', michael@0: status: 'VALID', michael@0: message: '' michael@0: } michael@0: } michael@0: } michael@0: } michael@0: ]); michael@0: }; michael@0: michael@0: exports.testExec = function(options) { michael@0: return helpers.audit(options, [ michael@0: { michael@0: skipRemainingIf: jsTestAllowed, michael@0: setup: '{ 1+1', michael@0: check: { michael@0: input: '{ 1+1', michael@0: hints: '', michael@0: markup: 'VVVVV', michael@0: cursor: 5, michael@0: current: 'javascript', michael@0: status: 'VALID', michael@0: options: [ ], michael@0: message: '', michael@0: predictions: [ ], michael@0: unassigned: [ ], michael@0: args: { michael@0: javascript: { michael@0: value: '1+1', michael@0: arg: '{ 1+1', michael@0: status: 'VALID', michael@0: message: '' michael@0: } michael@0: } michael@0: }, michael@0: exec: { michael@0: output: '2', michael@0: type: 'number', michael@0: error: false michael@0: } michael@0: }, michael@0: { michael@0: setup: '{ 1+1 }', michael@0: check: { michael@0: input: '{ 1+1 }', michael@0: hints: '', michael@0: markup: 'VVVVVVV', michael@0: cursor: 7, michael@0: current: 'javascript', michael@0: status: 'VALID', michael@0: options: [ ], michael@0: message: '', michael@0: predictions: [ ], michael@0: unassigned: [ ], michael@0: args: { michael@0: javascript: { michael@0: value: '1+1', michael@0: arg: '{ 1+1 }', michael@0: status: 'VALID', michael@0: message: '' michael@0: } michael@0: } michael@0: }, michael@0: exec: { michael@0: output: '2', michael@0: type: 'number', michael@0: error: false michael@0: } michael@0: }, michael@0: { michael@0: setup: '{ "hello"', michael@0: check: { michael@0: input: '{ "hello"', michael@0: hints: '', michael@0: markup: 'VVVVVVVVV', michael@0: cursor: 9, michael@0: current: 'javascript', michael@0: status: 'VALID', michael@0: options: [ ], michael@0: message: '', michael@0: predictions: [ ], michael@0: unassigned: [ ], michael@0: args: { michael@0: javascript: { michael@0: value: '"hello"', michael@0: arg: '{ "hello"', michael@0: status: 'VALID', michael@0: message: '' michael@0: } michael@0: } michael@0: }, michael@0: exec: { michael@0: output: 'hello', michael@0: type: 'string', michael@0: error: false michael@0: } michael@0: }, michael@0: { michael@0: setup: '{ "hello" + 1', michael@0: check: { michael@0: input: '{ "hello" + 1', michael@0: hints: '', michael@0: markup: 'VVVVVVVVVVVVV', michael@0: cursor: 13, michael@0: current: 'javascript', michael@0: status: 'VALID', michael@0: options: [ ], michael@0: message: '', michael@0: predictions: [ ], michael@0: unassigned: [ ], michael@0: args: { michael@0: javascript: { michael@0: value: '"hello" + 1', michael@0: arg: '{ "hello" + 1', michael@0: status: 'VALID', michael@0: message: '' michael@0: } michael@0: } michael@0: }, michael@0: exec: { michael@0: output: 'hello1', michael@0: type: 'string', michael@0: error: false michael@0: } michael@0: } michael@0: ]); michael@0: };