id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
sequence
docstring
stringlengths
4
11.8k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
86
226
300
apache/incubator-echarts
src/component/axis/AxisBuilder.js
function (axisModel, opt) { /** * @readOnly */ this.opt = opt; /** * @readOnly */ this.axisModel = axisModel; // Default value defaults( opt, { labelOffset: 0, nameDirection: 1, tickDirection: 1, labelDirection: 1, silent: true } ); /** * @readOnly */ this.group = new graphic.Group(); // FIXME Not use a seperate text group? var dumbGroup = new graphic.Group({ position: opt.position.slice(), rotation: opt.rotation }); // this.group.add(dumbGroup); // this._dumbGroup = dumbGroup; dumbGroup.updateTransform(); this._transform = dumbGroup.transform; this._dumbGroup = dumbGroup; }
javascript
function (axisModel, opt) { /** * @readOnly */ this.opt = opt; /** * @readOnly */ this.axisModel = axisModel; // Default value defaults( opt, { labelOffset: 0, nameDirection: 1, tickDirection: 1, labelDirection: 1, silent: true } ); /** * @readOnly */ this.group = new graphic.Group(); // FIXME Not use a seperate text group? var dumbGroup = new graphic.Group({ position: opt.position.slice(), rotation: opt.rotation }); // this.group.add(dumbGroup); // this._dumbGroup = dumbGroup; dumbGroup.updateTransform(); this._transform = dumbGroup.transform; this._dumbGroup = dumbGroup; }
[ "function", "(", "axisModel", ",", "opt", ")", "{", "/**\n * @readOnly\n */", "this", ".", "opt", "=", "opt", ";", "/**\n * @readOnly\n */", "this", ".", "axisModel", "=", "axisModel", ";", "// Default value", "defaults", "(", "opt", ",", "{", "labelOffset", ":", "0", ",", "nameDirection", ":", "1", ",", "tickDirection", ":", "1", ",", "labelDirection", ":", "1", ",", "silent", ":", "true", "}", ")", ";", "/**\n * @readOnly\n */", "this", ".", "group", "=", "new", "graphic", ".", "Group", "(", ")", ";", "// FIXME Not use a seperate text group?", "var", "dumbGroup", "=", "new", "graphic", ".", "Group", "(", "{", "position", ":", "opt", ".", "position", ".", "slice", "(", ")", ",", "rotation", ":", "opt", ".", "rotation", "}", ")", ";", "// this.group.add(dumbGroup);", "// this._dumbGroup = dumbGroup;", "dumbGroup", ".", "updateTransform", "(", ")", ";", "this", ".", "_transform", "=", "dumbGroup", ".", "transform", ";", "this", ".", "_dumbGroup", "=", "dumbGroup", ";", "}" ]
A final axis is translated and rotated from a "standard axis". So opt.position and opt.rotation is required. A standard axis is and axis from [0, 0] to [0, axisExtent[1]], for example: (0, 0) ------------> (0, 50) nameDirection or tickDirection or labelDirection is 1 means tick or label is below the standard axis, whereas is -1 means above the standard axis. labelOffset means offset between label and axis, which is useful when 'onZero', where axisLabel is in the grid and label in outside grid. Tips: like always, positive rotation represents anticlockwise, and negative rotation represents clockwise. The direction of position coordinate is the same as the direction of screen coordinate. Do not need to consider axis 'inverse', which is auto processed by axis extent. @param {module:zrender/container/Group} group @param {Object} axisModel @param {Object} opt Standard axis parameters. @param {Array.<number>} opt.position [x, y] @param {number} opt.rotation by radian @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle' or 'center'. @param {number} [opt.tickDirection=1] 1 or -1 @param {number} [opt.labelDirection=1] 1 or -1 @param {number} [opt.labelOffset=0] Usefull when onZero. @param {string} [opt.axisLabelShow] default get from axisModel. @param {string} [opt.axisName] default get from axisModel. @param {number} [opt.axisNameAvailableWidth] @param {number} [opt.labelRotate] by degree, default get from axisModel. @param {number} [opt.strokeContainThreshold] Default label interval when label @param {number} [opt.nameTruncateMaxWidth]
[ "A", "final", "axis", "is", "translated", "and", "rotated", "from", "a", "standard", "axis", ".", "So", "opt", ".", "position", "and", "opt", ".", "rotation", "is", "required", "." ]
4d0ea095dc3929cb6de40c45748826e7999c7aa8
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/axis/AxisBuilder.js#L71-L113
301
apache/incubator-echarts
src/component/tooltip/TooltipContent.js
function () { // FIXME // Move this logic to ec main? var container = this._container; var stl = container.currentStyle || document.defaultView.getComputedStyle(container); var domStyle = container.style; if (domStyle.position !== 'absolute' && stl.position !== 'absolute') { domStyle.position = 'relative'; } // Hide the tooltip // PENDING // this.hide(); }
javascript
function () { // FIXME // Move this logic to ec main? var container = this._container; var stl = container.currentStyle || document.defaultView.getComputedStyle(container); var domStyle = container.style; if (domStyle.position !== 'absolute' && stl.position !== 'absolute') { domStyle.position = 'relative'; } // Hide the tooltip // PENDING // this.hide(); }
[ "function", "(", ")", "{", "// FIXME", "// Move this logic to ec main?", "var", "container", "=", "this", ".", "_container", ";", "var", "stl", "=", "container", ".", "currentStyle", "||", "document", ".", "defaultView", ".", "getComputedStyle", "(", "container", ")", ";", "var", "domStyle", "=", "container", ".", "style", ";", "if", "(", "domStyle", ".", "position", "!==", "'absolute'", "&&", "stl", ".", "position", "!==", "'absolute'", ")", "{", "domStyle", ".", "position", "=", "'relative'", ";", "}", "// Hide the tooltip", "// PENDING", "// this.hide();", "}" ]
Update when tooltip is rendered
[ "Update", "when", "tooltip", "is", "rendered" ]
4d0ea095dc3929cb6de40c45748826e7999c7aa8
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/tooltip/TooltipContent.js#L194-L207
302
apache/incubator-echarts
src/data/helper/linkList.js
getLinkedData
function getLinkedData(dataType) { var mainData = this[MAIN_DATA]; return (dataType == null || mainData == null) ? mainData : mainData[DATAS][dataType]; }
javascript
function getLinkedData(dataType) { var mainData = this[MAIN_DATA]; return (dataType == null || mainData == null) ? mainData : mainData[DATAS][dataType]; }
[ "function", "getLinkedData", "(", "dataType", ")", "{", "var", "mainData", "=", "this", "[", "MAIN_DATA", "]", ";", "return", "(", "dataType", "==", "null", "||", "mainData", "==", "null", ")", "?", "mainData", ":", "mainData", "[", "DATAS", "]", "[", "dataType", "]", ";", "}" ]
Supplement method to List. @public @param {string} [dataType] If not specified, return mainData. @return {module:echarts/data/List}
[ "Supplement", "method", "to", "List", "." ]
4d0ea095dc3929cb6de40c45748826e7999c7aa8
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/data/helper/linkList.js#L119-L124
303
apache/incubator-echarts
src/component/dataZoom/dataZoomProcessor.js
function (ecModel, api) { ecModel.eachComponent('dataZoom', function (dataZoomModel) { // We calculate window and reset axis here but not in model // init stage and not after action dispatch handler, because // reset should be called after seriesData.restoreData. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel) { dataZoomModel.getAxisProxy(dimNames.name, axisIndex).reset(dataZoomModel, api); }); // Caution: data zoom filtering is order sensitive when using // percent range and no min/max/scale set on axis. // For example, we have dataZoom definition: // [ // {xAxisIndex: 0, start: 30, end: 70}, // {yAxisIndex: 0, start: 20, end: 80} // ] // In this case, [20, 80] of y-dataZoom should be based on data // that have filtered by x-dataZoom using range of [30, 70], // but should not be based on full raw data. Thus sliding // x-dataZoom will change both ranges of xAxis and yAxis, // while sliding y-dataZoom will only change the range of yAxis. // So we should filter x-axis after reset x-axis immediately, // and then reset y-axis and filter y-axis. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel) { dataZoomModel.getAxisProxy(dimNames.name, axisIndex).filterData(dataZoomModel, api); }); }); ecModel.eachComponent('dataZoom', function (dataZoomModel) { // Fullfill all of the range props so that user // is able to get them from chart.getOption(). var axisProxy = dataZoomModel.findRepresentativeAxisProxy(); var percentRange = axisProxy.getDataPercentWindow(); var valueRange = axisProxy.getDataValueWindow(); dataZoomModel.setRawRange({ start: percentRange[0], end: percentRange[1], startValue: valueRange[0], endValue: valueRange[1] }, true); }); }
javascript
function (ecModel, api) { ecModel.eachComponent('dataZoom', function (dataZoomModel) { // We calculate window and reset axis here but not in model // init stage and not after action dispatch handler, because // reset should be called after seriesData.restoreData. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel) { dataZoomModel.getAxisProxy(dimNames.name, axisIndex).reset(dataZoomModel, api); }); // Caution: data zoom filtering is order sensitive when using // percent range and no min/max/scale set on axis. // For example, we have dataZoom definition: // [ // {xAxisIndex: 0, start: 30, end: 70}, // {yAxisIndex: 0, start: 20, end: 80} // ] // In this case, [20, 80] of y-dataZoom should be based on data // that have filtered by x-dataZoom using range of [30, 70], // but should not be based on full raw data. Thus sliding // x-dataZoom will change both ranges of xAxis and yAxis, // while sliding y-dataZoom will only change the range of yAxis. // So we should filter x-axis after reset x-axis immediately, // and then reset y-axis and filter y-axis. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel) { dataZoomModel.getAxisProxy(dimNames.name, axisIndex).filterData(dataZoomModel, api); }); }); ecModel.eachComponent('dataZoom', function (dataZoomModel) { // Fullfill all of the range props so that user // is able to get them from chart.getOption(). var axisProxy = dataZoomModel.findRepresentativeAxisProxy(); var percentRange = axisProxy.getDataPercentWindow(); var valueRange = axisProxy.getDataValueWindow(); dataZoomModel.setRawRange({ start: percentRange[0], end: percentRange[1], startValue: valueRange[0], endValue: valueRange[1] }, true); }); }
[ "function", "(", "ecModel", ",", "api", ")", "{", "ecModel", ".", "eachComponent", "(", "'dataZoom'", ",", "function", "(", "dataZoomModel", ")", "{", "// We calculate window and reset axis here but not in model", "// init stage and not after action dispatch handler, because", "// reset should be called after seriesData.restoreData.", "dataZoomModel", ".", "eachTargetAxis", "(", "function", "(", "dimNames", ",", "axisIndex", ",", "dataZoomModel", ")", "{", "dataZoomModel", ".", "getAxisProxy", "(", "dimNames", ".", "name", ",", "axisIndex", ")", ".", "reset", "(", "dataZoomModel", ",", "api", ")", ";", "}", ")", ";", "// Caution: data zoom filtering is order sensitive when using", "// percent range and no min/max/scale set on axis.", "// For example, we have dataZoom definition:", "// [", "// {xAxisIndex: 0, start: 30, end: 70},", "// {yAxisIndex: 0, start: 20, end: 80}", "// ]", "// In this case, [20, 80] of y-dataZoom should be based on data", "// that have filtered by x-dataZoom using range of [30, 70],", "// but should not be based on full raw data. Thus sliding", "// x-dataZoom will change both ranges of xAxis and yAxis,", "// while sliding y-dataZoom will only change the range of yAxis.", "// So we should filter x-axis after reset x-axis immediately,", "// and then reset y-axis and filter y-axis.", "dataZoomModel", ".", "eachTargetAxis", "(", "function", "(", "dimNames", ",", "axisIndex", ",", "dataZoomModel", ")", "{", "dataZoomModel", ".", "getAxisProxy", "(", "dimNames", ".", "name", ",", "axisIndex", ")", ".", "filterData", "(", "dataZoomModel", ",", "api", ")", ";", "}", ")", ";", "}", ")", ";", "ecModel", ".", "eachComponent", "(", "'dataZoom'", ",", "function", "(", "dataZoomModel", ")", "{", "// Fullfill all of the range props so that user", "// is able to get them from chart.getOption().", "var", "axisProxy", "=", "dataZoomModel", ".", "findRepresentativeAxisProxy", "(", ")", ";", "var", "percentRange", "=", "axisProxy", ".", "getDataPercentWindow", "(", ")", ";", "var", "valueRange", "=", "axisProxy", ".", "getDataValueWindow", "(", ")", ";", "dataZoomModel", ".", "setRawRange", "(", "{", "start", ":", "percentRange", "[", "0", "]", ",", "end", ":", "percentRange", "[", "1", "]", ",", "startValue", ":", "valueRange", "[", "0", "]", ",", "endValue", ":", "valueRange", "[", "1", "]", "}", ",", "true", ")", ";", "}", ")", ";", "}" ]
Consider appendData, where filter should be performed. Because data process is in block mode currently, it is not need to worry about that the overallProgress execute every frame.
[ "Consider", "appendData", "where", "filter", "should", "be", "performed", ".", "Because", "data", "process", "is", "in", "block", "mode", "currently", "it", "is", "not", "need", "to", "worry", "about", "that", "the", "overallProgress", "execute", "every", "frame", "." ]
4d0ea095dc3929cb6de40c45748826e7999c7aa8
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/dataZoom/dataZoomProcessor.js#L48-L91
304
apache/incubator-echarts
src/coord/polar/Polar.js
function (point) { var coord = this.pointToCoord(point); return this._radiusAxis.contain(coord[0]) && this._angleAxis.contain(coord[1]); }
javascript
function (point) { var coord = this.pointToCoord(point); return this._radiusAxis.contain(coord[0]) && this._angleAxis.contain(coord[1]); }
[ "function", "(", "point", ")", "{", "var", "coord", "=", "this", ".", "pointToCoord", "(", "point", ")", ";", "return", "this", ".", "_radiusAxis", ".", "contain", "(", "coord", "[", "0", "]", ")", "&&", "this", ".", "_angleAxis", ".", "contain", "(", "coord", "[", "1", "]", ")", ";", "}" ]
If contain coord @param {Array.<number>} point @return {boolean}
[ "If", "contain", "coord" ]
4d0ea095dc3929cb6de40c45748826e7999c7aa8
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/polar/Polar.js#L90-L94
305
apache/incubator-echarts
src/coord/polar/Polar.js
function (scaleType) { var axes = []; var angleAxis = this._angleAxis; var radiusAxis = this._radiusAxis; angleAxis.scale.type === scaleType && axes.push(angleAxis); radiusAxis.scale.type === scaleType && axes.push(radiusAxis); return axes; }
javascript
function (scaleType) { var axes = []; var angleAxis = this._angleAxis; var radiusAxis = this._radiusAxis; angleAxis.scale.type === scaleType && axes.push(angleAxis); radiusAxis.scale.type === scaleType && axes.push(radiusAxis); return axes; }
[ "function", "(", "scaleType", ")", "{", "var", "axes", "=", "[", "]", ";", "var", "angleAxis", "=", "this", ".", "_angleAxis", ";", "var", "radiusAxis", "=", "this", ".", "_radiusAxis", ";", "angleAxis", ".", "scale", ".", "type", "===", "scaleType", "&&", "axes", ".", "push", "(", "angleAxis", ")", ";", "radiusAxis", ".", "scale", ".", "type", "===", "scaleType", "&&", "axes", ".", "push", "(", "radiusAxis", ")", ";", "return", "axes", ";", "}" ]
Get axes by type of scale @param {string} scaleType @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
[ "Get", "axes", "by", "type", "of", "scale" ]
4d0ea095dc3929cb6de40c45748826e7999c7aa8
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/polar/Polar.js#L126-L134
306
apache/incubator-echarts
src/chart/line/poly.js
drawNonMono
function drawNonMono( ctx, points, start, segLen, allLen, dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls ) { var prevIdx = 0; var idx = start; for (var k = 0; k < segLen; k++) { var p = points[idx]; if (idx >= allLen || idx < 0) { break; } if (isPointNull(p)) { if (connectNulls) { idx += dir; continue; } break; } if (idx === start) { ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]); v2Copy(cp0, p); } else { if (smooth > 0) { var nextIdx = idx + dir; var nextP = points[nextIdx]; if (connectNulls) { // Find next point not null while (nextP && isPointNull(points[nextIdx])) { nextIdx += dir; nextP = points[nextIdx]; } } var ratioNextSeg = 0.5; var prevP = points[prevIdx]; var nextP = points[nextIdx]; // Last point if (!nextP || isPointNull(nextP)) { v2Copy(cp1, p); } else { // If next data is null in not connect case if (isPointNull(nextP) && !connectNulls) { nextP = p; } vec2.sub(v, nextP, prevP); var lenPrevSeg; var lenNextSeg; if (smoothMonotone === 'x' || smoothMonotone === 'y') { var dim = smoothMonotone === 'x' ? 0 : 1; lenPrevSeg = Math.abs(p[dim] - prevP[dim]); lenNextSeg = Math.abs(p[dim] - nextP[dim]); } else { lenPrevSeg = vec2.dist(p, prevP); lenNextSeg = vec2.dist(p, nextP); } // Use ratio of seg length ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg); scaleAndAdd(cp1, p, v, -smooth * (1 - ratioNextSeg)); } // Smooth constraint vec2Min(cp0, cp0, smoothMax); vec2Max(cp0, cp0, smoothMin); vec2Min(cp1, cp1, smoothMax); vec2Max(cp1, cp1, smoothMin); ctx.bezierCurveTo( cp0[0], cp0[1], cp1[0], cp1[1], p[0], p[1] ); // cp0 of next segment scaleAndAdd(cp0, p, v, smooth * ratioNextSeg); } else { ctx.lineTo(p[0], p[1]); } } prevIdx = idx; idx += dir; } return k; }
javascript
function drawNonMono( ctx, points, start, segLen, allLen, dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls ) { var prevIdx = 0; var idx = start; for (var k = 0; k < segLen; k++) { var p = points[idx]; if (idx >= allLen || idx < 0) { break; } if (isPointNull(p)) { if (connectNulls) { idx += dir; continue; } break; } if (idx === start) { ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]); v2Copy(cp0, p); } else { if (smooth > 0) { var nextIdx = idx + dir; var nextP = points[nextIdx]; if (connectNulls) { // Find next point not null while (nextP && isPointNull(points[nextIdx])) { nextIdx += dir; nextP = points[nextIdx]; } } var ratioNextSeg = 0.5; var prevP = points[prevIdx]; var nextP = points[nextIdx]; // Last point if (!nextP || isPointNull(nextP)) { v2Copy(cp1, p); } else { // If next data is null in not connect case if (isPointNull(nextP) && !connectNulls) { nextP = p; } vec2.sub(v, nextP, prevP); var lenPrevSeg; var lenNextSeg; if (smoothMonotone === 'x' || smoothMonotone === 'y') { var dim = smoothMonotone === 'x' ? 0 : 1; lenPrevSeg = Math.abs(p[dim] - prevP[dim]); lenNextSeg = Math.abs(p[dim] - nextP[dim]); } else { lenPrevSeg = vec2.dist(p, prevP); lenNextSeg = vec2.dist(p, nextP); } // Use ratio of seg length ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg); scaleAndAdd(cp1, p, v, -smooth * (1 - ratioNextSeg)); } // Smooth constraint vec2Min(cp0, cp0, smoothMax); vec2Max(cp0, cp0, smoothMin); vec2Min(cp1, cp1, smoothMax); vec2Max(cp1, cp1, smoothMin); ctx.bezierCurveTo( cp0[0], cp0[1], cp1[0], cp1[1], p[0], p[1] ); // cp0 of next segment scaleAndAdd(cp0, p, v, smooth * ratioNextSeg); } else { ctx.lineTo(p[0], p[1]); } } prevIdx = idx; idx += dir; } return k; }
[ "function", "drawNonMono", "(", "ctx", ",", "points", ",", "start", ",", "segLen", ",", "allLen", ",", "dir", ",", "smoothMin", ",", "smoothMax", ",", "smooth", ",", "smoothMonotone", ",", "connectNulls", ")", "{", "var", "prevIdx", "=", "0", ";", "var", "idx", "=", "start", ";", "for", "(", "var", "k", "=", "0", ";", "k", "<", "segLen", ";", "k", "++", ")", "{", "var", "p", "=", "points", "[", "idx", "]", ";", "if", "(", "idx", ">=", "allLen", "||", "idx", "<", "0", ")", "{", "break", ";", "}", "if", "(", "isPointNull", "(", "p", ")", ")", "{", "if", "(", "connectNulls", ")", "{", "idx", "+=", "dir", ";", "continue", ";", "}", "break", ";", "}", "if", "(", "idx", "===", "start", ")", "{", "ctx", "[", "dir", ">", "0", "?", "'moveTo'", ":", "'lineTo'", "]", "(", "p", "[", "0", "]", ",", "p", "[", "1", "]", ")", ";", "v2Copy", "(", "cp0", ",", "p", ")", ";", "}", "else", "{", "if", "(", "smooth", ">", "0", ")", "{", "var", "nextIdx", "=", "idx", "+", "dir", ";", "var", "nextP", "=", "points", "[", "nextIdx", "]", ";", "if", "(", "connectNulls", ")", "{", "// Find next point not null", "while", "(", "nextP", "&&", "isPointNull", "(", "points", "[", "nextIdx", "]", ")", ")", "{", "nextIdx", "+=", "dir", ";", "nextP", "=", "points", "[", "nextIdx", "]", ";", "}", "}", "var", "ratioNextSeg", "=", "0.5", ";", "var", "prevP", "=", "points", "[", "prevIdx", "]", ";", "var", "nextP", "=", "points", "[", "nextIdx", "]", ";", "// Last point", "if", "(", "!", "nextP", "||", "isPointNull", "(", "nextP", ")", ")", "{", "v2Copy", "(", "cp1", ",", "p", ")", ";", "}", "else", "{", "// If next data is null in not connect case", "if", "(", "isPointNull", "(", "nextP", ")", "&&", "!", "connectNulls", ")", "{", "nextP", "=", "p", ";", "}", "vec2", ".", "sub", "(", "v", ",", "nextP", ",", "prevP", ")", ";", "var", "lenPrevSeg", ";", "var", "lenNextSeg", ";", "if", "(", "smoothMonotone", "===", "'x'", "||", "smoothMonotone", "===", "'y'", ")", "{", "var", "dim", "=", "smoothMonotone", "===", "'x'", "?", "0", ":", "1", ";", "lenPrevSeg", "=", "Math", ".", "abs", "(", "p", "[", "dim", "]", "-", "prevP", "[", "dim", "]", ")", ";", "lenNextSeg", "=", "Math", ".", "abs", "(", "p", "[", "dim", "]", "-", "nextP", "[", "dim", "]", ")", ";", "}", "else", "{", "lenPrevSeg", "=", "vec2", ".", "dist", "(", "p", ",", "prevP", ")", ";", "lenNextSeg", "=", "vec2", ".", "dist", "(", "p", ",", "nextP", ")", ";", "}", "// Use ratio of seg length", "ratioNextSeg", "=", "lenNextSeg", "/", "(", "lenNextSeg", "+", "lenPrevSeg", ")", ";", "scaleAndAdd", "(", "cp1", ",", "p", ",", "v", ",", "-", "smooth", "*", "(", "1", "-", "ratioNextSeg", ")", ")", ";", "}", "// Smooth constraint", "vec2Min", "(", "cp0", ",", "cp0", ",", "smoothMax", ")", ";", "vec2Max", "(", "cp0", ",", "cp0", ",", "smoothMin", ")", ";", "vec2Min", "(", "cp1", ",", "cp1", ",", "smoothMax", ")", ";", "vec2Max", "(", "cp1", ",", "cp1", ",", "smoothMin", ")", ";", "ctx", ".", "bezierCurveTo", "(", "cp0", "[", "0", "]", ",", "cp0", "[", "1", "]", ",", "cp1", "[", "0", "]", ",", "cp1", "[", "1", "]", ",", "p", "[", "0", "]", ",", "p", "[", "1", "]", ")", ";", "// cp0 of next segment", "scaleAndAdd", "(", "cp0", ",", "p", ",", "v", ",", "smooth", "*", "ratioNextSeg", ")", ";", "}", "else", "{", "ctx", ".", "lineTo", "(", "p", "[", "0", "]", ",", "p", "[", "1", "]", ")", ";", "}", "}", "prevIdx", "=", "idx", ";", "idx", "+=", "dir", ";", "}", "return", "k", ";", "}" ]
Draw smoothed line in non-monotone, in may cause undesired curve in extreme situations. This should be used when points are non-monotone neither in x or y dimension.
[ "Draw", "smoothed", "line", "in", "non", "-", "monotone", "in", "may", "cause", "undesired", "curve", "in", "extreme", "situations", ".", "This", "should", "be", "used", "when", "points", "are", "non", "-", "monotone", "neither", "in", "x", "or", "y", "dimension", "." ]
4d0ea095dc3929cb6de40c45748826e7999c7aa8
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/line/poly.js#L171-L262
307
apache/incubator-echarts
src/component/visualMap/visualEncoding.js
getColorVisual
function getColorVisual(seriesModel, visualMapModel, value, valueState) { var mappings = visualMapModel.targetVisuals[valueState]; var visualTypes = VisualMapping.prepareVisualTypes(mappings); var resultVisual = { color: seriesModel.getData().getVisual('color') // default color. }; for (var i = 0, len = visualTypes.length; i < len; i++) { var type = visualTypes[i]; var mapping = mappings[ type === 'opacity' ? '__alphaForOpacity' : type ]; mapping && mapping.applyVisual(value, getVisual, setVisual); } return resultVisual.color; function getVisual(key) { return resultVisual[key]; } function setVisual(key, value) { resultVisual[key] = value; } }
javascript
function getColorVisual(seriesModel, visualMapModel, value, valueState) { var mappings = visualMapModel.targetVisuals[valueState]; var visualTypes = VisualMapping.prepareVisualTypes(mappings); var resultVisual = { color: seriesModel.getData().getVisual('color') // default color. }; for (var i = 0, len = visualTypes.length; i < len; i++) { var type = visualTypes[i]; var mapping = mappings[ type === 'opacity' ? '__alphaForOpacity' : type ]; mapping && mapping.applyVisual(value, getVisual, setVisual); } return resultVisual.color; function getVisual(key) { return resultVisual[key]; } function setVisual(key, value) { resultVisual[key] = value; } }
[ "function", "getColorVisual", "(", "seriesModel", ",", "visualMapModel", ",", "value", ",", "valueState", ")", "{", "var", "mappings", "=", "visualMapModel", ".", "targetVisuals", "[", "valueState", "]", ";", "var", "visualTypes", "=", "VisualMapping", ".", "prepareVisualTypes", "(", "mappings", ")", ";", "var", "resultVisual", "=", "{", "color", ":", "seriesModel", ".", "getData", "(", ")", ".", "getVisual", "(", "'color'", ")", "// default color.", "}", ";", "for", "(", "var", "i", "=", "0", ",", "len", "=", "visualTypes", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "var", "type", "=", "visualTypes", "[", "i", "]", ";", "var", "mapping", "=", "mappings", "[", "type", "===", "'opacity'", "?", "'__alphaForOpacity'", ":", "type", "]", ";", "mapping", "&&", "mapping", ".", "applyVisual", "(", "value", ",", "getVisual", ",", "setVisual", ")", ";", "}", "return", "resultVisual", ".", "color", ";", "function", "getVisual", "(", "key", ")", "{", "return", "resultVisual", "[", "key", "]", ";", "}", "function", "setVisual", "(", "key", ",", "value", ")", "{", "resultVisual", "[", "key", "]", "=", "value", ";", "}", "}" ]
FIXME performance and export for heatmap? value can be Infinity or -Infinity
[ "FIXME", "performance", "and", "export", "for", "heatmap?", "value", "can", "be", "Infinity", "or", "-", "Infinity" ]
4d0ea095dc3929cb6de40c45748826e7999c7aa8
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/visualMap/visualEncoding.js#L82-L106
308
vuejs/vuex
dist/vuex.esm.js
vuexInit
function vuexInit () { var options = this.$options; // store injection if (options.store) { this.$store = typeof options.store === 'function' ? options.store() : options.store; } else if (options.parent && options.parent.$store) { this.$store = options.parent.$store; } }
javascript
function vuexInit () { var options = this.$options; // store injection if (options.store) { this.$store = typeof options.store === 'function' ? options.store() : options.store; } else if (options.parent && options.parent.$store) { this.$store = options.parent.$store; } }
[ "function", "vuexInit", "(", ")", "{", "var", "options", "=", "this", ".", "$options", ";", "// store injection", "if", "(", "options", ".", "store", ")", "{", "this", ".", "$store", "=", "typeof", "options", ".", "store", "===", "'function'", "?", "options", ".", "store", "(", ")", ":", "options", ".", "store", ";", "}", "else", "if", "(", "options", ".", "parent", "&&", "options", ".", "parent", ".", "$store", ")", "{", "this", ".", "$store", "=", "options", ".", "parent", ".", "$store", ";", "}", "}" ]
Vuex init hook, injected into each instances init hooks list.
[ "Vuex", "init", "hook", "injected", "into", "each", "instances", "init", "hooks", "list", "." ]
d7c7f9844831f98c5c9aaca213746c4ccc5d6929
https://github.com/vuejs/vuex/blob/d7c7f9844831f98c5c9aaca213746c4ccc5d6929/dist/vuex.esm.js#L29-L39
309
vuejs/vuex
dist/vuex.esm.js
forEachValue
function forEachValue (obj, fn) { Object.keys(obj).forEach(function (key) { return fn(obj[key], key); }); }
javascript
function forEachValue (obj, fn) { Object.keys(obj).forEach(function (key) { return fn(obj[key], key); }); }
[ "function", "forEachValue", "(", "obj", ",", "fn", ")", "{", "Object", ".", "keys", "(", "obj", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "return", "fn", "(", "obj", "[", "key", "]", ",", "key", ")", ";", "}", ")", ";", "}" ]
Get the first item that pass the test by second argument function @param {Array} list @param {Function} f @return {*} forEach for object
[ "Get", "the", "first", "item", "that", "pass", "the", "test", "by", "second", "argument", "function" ]
d7c7f9844831f98c5c9aaca213746c4ccc5d6929
https://github.com/vuejs/vuex/blob/d7c7f9844831f98c5c9aaca213746c4ccc5d6929/dist/vuex.esm.js#L74-L76
310
vuejs/vuex
dist/vuex.esm.js
Module
function Module (rawModule, runtime) { this.runtime = runtime; // Store some children item this._children = Object.create(null); // Store the origin module object which passed by programmer this._rawModule = rawModule; var rawState = rawModule.state; // Store the origin module's state this.state = (typeof rawState === 'function' ? rawState() : rawState) || {}; }
javascript
function Module (rawModule, runtime) { this.runtime = runtime; // Store some children item this._children = Object.create(null); // Store the origin module object which passed by programmer this._rawModule = rawModule; var rawState = rawModule.state; // Store the origin module's state this.state = (typeof rawState === 'function' ? rawState() : rawState) || {}; }
[ "function", "Module", "(", "rawModule", ",", "runtime", ")", "{", "this", ".", "runtime", "=", "runtime", ";", "// Store some children item", "this", ".", "_children", "=", "Object", ".", "create", "(", "null", ")", ";", "// Store the origin module object which passed by programmer", "this", ".", "_rawModule", "=", "rawModule", ";", "var", "rawState", "=", "rawModule", ".", "state", ";", "// Store the origin module's state", "this", ".", "state", "=", "(", "typeof", "rawState", "===", "'function'", "?", "rawState", "(", ")", ":", "rawState", ")", "||", "{", "}", ";", "}" ]
Base data struct for store's module, package with some attribute and method
[ "Base", "data", "struct", "for", "store", "s", "module", "package", "with", "some", "attribute", "and", "method" ]
d7c7f9844831f98c5c9aaca213746c4ccc5d6929
https://github.com/vuejs/vuex/blob/d7c7f9844831f98c5c9aaca213746c4ccc5d6929/dist/vuex.esm.js#L91-L101
311
vuejs/vuex
dist/vuex.esm.js
normalizeNamespace
function normalizeNamespace (fn) { return function (namespace, map) { if (typeof namespace !== 'string') { map = namespace; namespace = ''; } else if (namespace.charAt(namespace.length - 1) !== '/') { namespace += '/'; } return fn(namespace, map) } }
javascript
function normalizeNamespace (fn) { return function (namespace, map) { if (typeof namespace !== 'string') { map = namespace; namespace = ''; } else if (namespace.charAt(namespace.length - 1) !== '/') { namespace += '/'; } return fn(namespace, map) } }
[ "function", "normalizeNamespace", "(", "fn", ")", "{", "return", "function", "(", "namespace", ",", "map", ")", "{", "if", "(", "typeof", "namespace", "!==", "'string'", ")", "{", "map", "=", "namespace", ";", "namespace", "=", "''", ";", "}", "else", "if", "(", "namespace", ".", "charAt", "(", "namespace", ".", "length", "-", "1", ")", "!==", "'/'", ")", "{", "namespace", "+=", "'/'", ";", "}", "return", "fn", "(", "namespace", ",", "map", ")", "}", "}" ]
Return a function expect two param contains namespace and map. it will normalize the namespace and then the param's function will handle the new namespace and the map. @param {Function} fn @return {Function}
[ "Return", "a", "function", "expect", "two", "param", "contains", "namespace", "and", "map", ".", "it", "will", "normalize", "the", "namespace", "and", "then", "the", "param", "s", "function", "will", "handle", "the", "new", "namespace", "and", "the", "map", "." ]
d7c7f9844831f98c5c9aaca213746c4ccc5d6929
https://github.com/vuejs/vuex/blob/d7c7f9844831f98c5c9aaca213746c4ccc5d6929/dist/vuex.esm.js#L960-L970
312
vuejs/vuex
src/helpers.js
getModuleByNamespace
function getModuleByNamespace (store, helper, namespace) { const module = store._modulesNamespaceMap[namespace] if (process.env.NODE_ENV !== 'production' && !module) { console.error(`[vuex] module namespace not found in ${helper}(): ${namespace}`) } return module }
javascript
function getModuleByNamespace (store, helper, namespace) { const module = store._modulesNamespaceMap[namespace] if (process.env.NODE_ENV !== 'production' && !module) { console.error(`[vuex] module namespace not found in ${helper}(): ${namespace}`) } return module }
[ "function", "getModuleByNamespace", "(", "store", ",", "helper", ",", "namespace", ")", "{", "const", "module", "=", "store", ".", "_modulesNamespaceMap", "[", "namespace", "]", "if", "(", "process", ".", "env", ".", "NODE_ENV", "!==", "'production'", "&&", "!", "module", ")", "{", "console", ".", "error", "(", "`", "${", "helper", "}", "${", "namespace", "}", "`", ")", "}", "return", "module", "}" ]
Search a special module from store by namespace. if module not exist, print error message. @param {Object} store @param {String} helper @param {String} namespace @return {Object}
[ "Search", "a", "special", "module", "from", "store", "by", "namespace", ".", "if", "module", "not", "exist", "print", "error", "message", "." ]
d7c7f9844831f98c5c9aaca213746c4ccc5d6929
https://github.com/vuejs/vuex/blob/d7c7f9844831f98c5c9aaca213746c4ccc5d6929/src/helpers.js#L161-L167
313
vuejs/vuex
src/store.js
makeLocalContext
function makeLocalContext (store, namespace, path) { const noNamespace = namespace === '' const local = { dispatch: noNamespace ? store.dispatch : (_type, _payload, _options) => { const args = unifyObjectStyle(_type, _payload, _options) const { payload, options } = args let { type } = args if (!options || !options.root) { type = namespace + type if (process.env.NODE_ENV !== 'production' && !store._actions[type]) { console.error(`[vuex] unknown local action type: ${args.type}, global type: ${type}`) return } } return store.dispatch(type, payload) }, commit: noNamespace ? store.commit : (_type, _payload, _options) => { const args = unifyObjectStyle(_type, _payload, _options) const { payload, options } = args let { type } = args if (!options || !options.root) { type = namespace + type if (process.env.NODE_ENV !== 'production' && !store._mutations[type]) { console.error(`[vuex] unknown local mutation type: ${args.type}, global type: ${type}`) return } } store.commit(type, payload, options) } } // getters and state object must be gotten lazily // because they will be changed by vm update Object.defineProperties(local, { getters: { get: noNamespace ? () => store.getters : () => makeLocalGetters(store, namespace) }, state: { get: () => getNestedState(store.state, path) } }) return local }
javascript
function makeLocalContext (store, namespace, path) { const noNamespace = namespace === '' const local = { dispatch: noNamespace ? store.dispatch : (_type, _payload, _options) => { const args = unifyObjectStyle(_type, _payload, _options) const { payload, options } = args let { type } = args if (!options || !options.root) { type = namespace + type if (process.env.NODE_ENV !== 'production' && !store._actions[type]) { console.error(`[vuex] unknown local action type: ${args.type}, global type: ${type}`) return } } return store.dispatch(type, payload) }, commit: noNamespace ? store.commit : (_type, _payload, _options) => { const args = unifyObjectStyle(_type, _payload, _options) const { payload, options } = args let { type } = args if (!options || !options.root) { type = namespace + type if (process.env.NODE_ENV !== 'production' && !store._mutations[type]) { console.error(`[vuex] unknown local mutation type: ${args.type}, global type: ${type}`) return } } store.commit(type, payload, options) } } // getters and state object must be gotten lazily // because they will be changed by vm update Object.defineProperties(local, { getters: { get: noNamespace ? () => store.getters : () => makeLocalGetters(store, namespace) }, state: { get: () => getNestedState(store.state, path) } }) return local }
[ "function", "makeLocalContext", "(", "store", ",", "namespace", ",", "path", ")", "{", "const", "noNamespace", "=", "namespace", "===", "''", "const", "local", "=", "{", "dispatch", ":", "noNamespace", "?", "store", ".", "dispatch", ":", "(", "_type", ",", "_payload", ",", "_options", ")", "=>", "{", "const", "args", "=", "unifyObjectStyle", "(", "_type", ",", "_payload", ",", "_options", ")", "const", "{", "payload", ",", "options", "}", "=", "args", "let", "{", "type", "}", "=", "args", "if", "(", "!", "options", "||", "!", "options", ".", "root", ")", "{", "type", "=", "namespace", "+", "type", "if", "(", "process", ".", "env", ".", "NODE_ENV", "!==", "'production'", "&&", "!", "store", ".", "_actions", "[", "type", "]", ")", "{", "console", ".", "error", "(", "`", "${", "args", ".", "type", "}", "${", "type", "}", "`", ")", "return", "}", "}", "return", "store", ".", "dispatch", "(", "type", ",", "payload", ")", "}", ",", "commit", ":", "noNamespace", "?", "store", ".", "commit", ":", "(", "_type", ",", "_payload", ",", "_options", ")", "=>", "{", "const", "args", "=", "unifyObjectStyle", "(", "_type", ",", "_payload", ",", "_options", ")", "const", "{", "payload", ",", "options", "}", "=", "args", "let", "{", "type", "}", "=", "args", "if", "(", "!", "options", "||", "!", "options", ".", "root", ")", "{", "type", "=", "namespace", "+", "type", "if", "(", "process", ".", "env", ".", "NODE_ENV", "!==", "'production'", "&&", "!", "store", ".", "_mutations", "[", "type", "]", ")", "{", "console", ".", "error", "(", "`", "${", "args", ".", "type", "}", "${", "type", "}", "`", ")", "return", "}", "}", "store", ".", "commit", "(", "type", ",", "payload", ",", "options", ")", "}", "}", "// getters and state object must be gotten lazily", "// because they will be changed by vm update", "Object", ".", "defineProperties", "(", "local", ",", "{", "getters", ":", "{", "get", ":", "noNamespace", "?", "(", ")", "=>", "store", ".", "getters", ":", "(", ")", "=>", "makeLocalGetters", "(", "store", ",", "namespace", ")", "}", ",", "state", ":", "{", "get", ":", "(", ")", "=>", "getNestedState", "(", "store", ".", "state", ",", "path", ")", "}", "}", ")", "return", "local", "}" ]
make localized dispatch, commit, getters and state if there is no namespace, just use root ones
[ "make", "localized", "dispatch", "commit", "getters", "and", "state", "if", "there", "is", "no", "namespace", "just", "use", "root", "ones" ]
d7c7f9844831f98c5c9aaca213746c4ccc5d6929
https://github.com/vuejs/vuex/blob/d7c7f9844831f98c5c9aaca213746c4ccc5d6929/src/store.js#L343-L394
314
transloadit/uppy
packages/@uppy/golden-retriever/src/IndexedDBStore.js
migrateExpiration
function migrateExpiration (store) { const request = store.openCursor() request.onsuccess = (event) => { const cursor = event.target.result if (!cursor) { return } const entry = cursor.value entry.expires = Date.now() + DEFAULT_EXPIRY cursor.update(entry) } }
javascript
function migrateExpiration (store) { const request = store.openCursor() request.onsuccess = (event) => { const cursor = event.target.result if (!cursor) { return } const entry = cursor.value entry.expires = Date.now() + DEFAULT_EXPIRY cursor.update(entry) } }
[ "function", "migrateExpiration", "(", "store", ")", "{", "const", "request", "=", "store", ".", "openCursor", "(", ")", "request", ".", "onsuccess", "=", "(", "event", ")", "=>", "{", "const", "cursor", "=", "event", ".", "target", ".", "result", "if", "(", "!", "cursor", ")", "{", "return", "}", "const", "entry", "=", "cursor", ".", "value", "entry", ".", "expires", "=", "Date", ".", "now", "(", ")", "+", "DEFAULT_EXPIRY", "cursor", ".", "update", "(", "entry", ")", "}", "}" ]
Set default `expires` dates on existing stored blobs.
[ "Set", "default", "expires", "dates", "on", "existing", "stored", "blobs", "." ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/golden-retriever/src/IndexedDBStore.js#L13-L24
315
transloadit/uppy
packages/@uppy/core/src/Plugin.js
debounce
function debounce (fn) { let calling = null let latestArgs = null return (...args) => { latestArgs = args if (!calling) { calling = Promise.resolve().then(() => { calling = null // At this point `args` may be different from the most // recent state, if multiple calls happened since this task // was queued. So we use the `latestArgs`, which definitely // is the most recent call. return fn(...latestArgs) }) } return calling } }
javascript
function debounce (fn) { let calling = null let latestArgs = null return (...args) => { latestArgs = args if (!calling) { calling = Promise.resolve().then(() => { calling = null // At this point `args` may be different from the most // recent state, if multiple calls happened since this task // was queued. So we use the `latestArgs`, which definitely // is the most recent call. return fn(...latestArgs) }) } return calling } }
[ "function", "debounce", "(", "fn", ")", "{", "let", "calling", "=", "null", "let", "latestArgs", "=", "null", "return", "(", "...", "args", ")", "=>", "{", "latestArgs", "=", "args", "if", "(", "!", "calling", ")", "{", "calling", "=", "Promise", ".", "resolve", "(", ")", ".", "then", "(", "(", ")", "=>", "{", "calling", "=", "null", "// At this point `args` may be different from the most", "// recent state, if multiple calls happened since this task", "// was queued. So we use the `latestArgs`, which definitely", "// is the most recent call.", "return", "fn", "(", "...", "latestArgs", ")", "}", ")", "}", "return", "calling", "}", "}" ]
Defer a frequent call to the microtask queue.
[ "Defer", "a", "frequent", "call", "to", "the", "microtask", "queue", "." ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/core/src/Plugin.js#L7-L24
316
transloadit/uppy
packages/@uppy/transloadit/src/AssemblyOptions.js
validateParams
function validateParams (params) { if (!params) { throw new Error('Transloadit: The `params` option is required.') } if (typeof params === 'string') { try { params = JSON.parse(params) } catch (err) { // Tell the user that this is not an Uppy bug! err.message = 'Transloadit: The `params` option is a malformed JSON string: ' + err.message throw err } } if (!params.auth || !params.auth.key) { throw new Error('Transloadit: The `params.auth.key` option is required. ' + 'You can find your Transloadit API key at https://transloadit.com/account/api-settings.') } }
javascript
function validateParams (params) { if (!params) { throw new Error('Transloadit: The `params` option is required.') } if (typeof params === 'string') { try { params = JSON.parse(params) } catch (err) { // Tell the user that this is not an Uppy bug! err.message = 'Transloadit: The `params` option is a malformed JSON string: ' + err.message throw err } } if (!params.auth || !params.auth.key) { throw new Error('Transloadit: The `params.auth.key` option is required. ' + 'You can find your Transloadit API key at https://transloadit.com/account/api-settings.') } }
[ "function", "validateParams", "(", "params", ")", "{", "if", "(", "!", "params", ")", "{", "throw", "new", "Error", "(", "'Transloadit: The `params` option is required.'", ")", "}", "if", "(", "typeof", "params", "===", "'string'", ")", "{", "try", "{", "params", "=", "JSON", ".", "parse", "(", "params", ")", "}", "catch", "(", "err", ")", "{", "// Tell the user that this is not an Uppy bug!", "err", ".", "message", "=", "'Transloadit: The `params` option is a malformed JSON string: '", "+", "err", ".", "message", "throw", "err", "}", "}", "if", "(", "!", "params", ".", "auth", "||", "!", "params", ".", "auth", ".", "key", ")", "{", "throw", "new", "Error", "(", "'Transloadit: The `params.auth.key` option is required. '", "+", "'You can find your Transloadit API key at https://transloadit.com/account/api-settings.'", ")", "}", "}" ]
Check that Assembly parameters are present and include all required fields.
[ "Check", "that", "Assembly", "parameters", "are", "present", "and", "include", "all", "required", "fields", "." ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/transloadit/src/AssemblyOptions.js#L4-L24
317
transloadit/uppy
examples/react-native-expo/FileList.js
FileIcon
function FileIcon () { return <View style={styles.itemIconContainer}> <Image style={styles.itemIcon} source={require('./assets/file-icon.png')} /> </View> }
javascript
function FileIcon () { return <View style={styles.itemIconContainer}> <Image style={styles.itemIcon} source={require('./assets/file-icon.png')} /> </View> }
[ "function", "FileIcon", "(", ")", "{", "return", "<", "View", "style", "=", "{", "styles", ".", "itemIconContainer", "}", ">", "\n ", "<", "Image", "style", "=", "{", "styles", ".", "itemIcon", "}", "source", "=", "{", "require", "(", "'./assets/file-icon.png'", ")", "}", "/", ">", "\n ", "<", "/", "View", ">", "}" ]
return str }
[ "return", "str", "}" ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/examples/react-native-expo/FileList.js#L18-L25
318
transloadit/uppy
packages/@uppy/companion/src/server/controllers/authorized.js
authorized
function authorized (req, res) { const { params, uppy } = req const providerName = params.providerName if (!uppy.providerTokens || !uppy.providerTokens[providerName]) { return res.json({ authenticated: false }) } const token = uppy.providerTokens[providerName] uppy.provider.list({ token, uppy }, (err, response, body) => { const notAuthenticated = Boolean(err) if (notAuthenticated) { logger.debug(`${providerName} failed authorizarion test err:${err}`, 'provider.auth.check') } return res.json({ authenticated: !notAuthenticated }) }) }
javascript
function authorized (req, res) { const { params, uppy } = req const providerName = params.providerName if (!uppy.providerTokens || !uppy.providerTokens[providerName]) { return res.json({ authenticated: false }) } const token = uppy.providerTokens[providerName] uppy.provider.list({ token, uppy }, (err, response, body) => { const notAuthenticated = Boolean(err) if (notAuthenticated) { logger.debug(`${providerName} failed authorizarion test err:${err}`, 'provider.auth.check') } return res.json({ authenticated: !notAuthenticated }) }) }
[ "function", "authorized", "(", "req", ",", "res", ")", "{", "const", "{", "params", ",", "uppy", "}", "=", "req", "const", "providerName", "=", "params", ".", "providerName", "if", "(", "!", "uppy", ".", "providerTokens", "||", "!", "uppy", ".", "providerTokens", "[", "providerName", "]", ")", "{", "return", "res", ".", "json", "(", "{", "authenticated", ":", "false", "}", ")", "}", "const", "token", "=", "uppy", ".", "providerTokens", "[", "providerName", "]", "uppy", ".", "provider", ".", "list", "(", "{", "token", ",", "uppy", "}", ",", "(", "err", ",", "response", ",", "body", ")", "=>", "{", "const", "notAuthenticated", "=", "Boolean", "(", "err", ")", "if", "(", "notAuthenticated", ")", "{", "logger", ".", "debug", "(", "`", "${", "providerName", "}", "${", "err", "}", "`", ",", "'provider.auth.check'", ")", "}", "return", "res", ".", "json", "(", "{", "authenticated", ":", "!", "notAuthenticated", "}", ")", "}", ")", "}" ]
checks if companion is authorized to access a user's provider account. @param {object} req @param {object} res
[ "checks", "if", "companion", "is", "authorized", "to", "access", "a", "user", "s", "provider", "account", "." ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/companion/src/server/controllers/authorized.js#L12-L28
319
transloadit/uppy
website/inject.js
injectGhStars
async function injectGhStars () { const opts = {} if ('GITHUB_TOKEN' in process.env) { opts.auth = process.env.GITHUB_TOKEN } const Octokit = require('@octokit/rest') const octokit = new Octokit(opts) let { headers, data } = await octokit.repos.get({ owner: 'transloadit', repo: 'uppy' }) console.log(`${headers['x-ratelimit-remaining']} requests remaining until we hit GitHub ratelimiter`) let dstpath = path.join(webRoot, 'themes', 'uppy', 'layout', 'partials', 'generated_stargazers.ejs') fs.writeFileSync(dstpath, data.stargazers_count, 'utf-8') console.log(`${data.stargazers_count} stargazers written to '${dstpath}'`) }
javascript
async function injectGhStars () { const opts = {} if ('GITHUB_TOKEN' in process.env) { opts.auth = process.env.GITHUB_TOKEN } const Octokit = require('@octokit/rest') const octokit = new Octokit(opts) let { headers, data } = await octokit.repos.get({ owner: 'transloadit', repo: 'uppy' }) console.log(`${headers['x-ratelimit-remaining']} requests remaining until we hit GitHub ratelimiter`) let dstpath = path.join(webRoot, 'themes', 'uppy', 'layout', 'partials', 'generated_stargazers.ejs') fs.writeFileSync(dstpath, data.stargazers_count, 'utf-8') console.log(`${data.stargazers_count} stargazers written to '${dstpath}'`) }
[ "async", "function", "injectGhStars", "(", ")", "{", "const", "opts", "=", "{", "}", "if", "(", "'GITHUB_TOKEN'", "in", "process", ".", "env", ")", "{", "opts", ".", "auth", "=", "process", ".", "env", ".", "GITHUB_TOKEN", "}", "const", "Octokit", "=", "require", "(", "'@octokit/rest'", ")", "const", "octokit", "=", "new", "Octokit", "(", "opts", ")", "let", "{", "headers", ",", "data", "}", "=", "await", "octokit", ".", "repos", ".", "get", "(", "{", "owner", ":", "'transloadit'", ",", "repo", ":", "'uppy'", "}", ")", "console", ".", "log", "(", "`", "${", "headers", "[", "'x-ratelimit-remaining'", "]", "}", "`", ")", "let", "dstpath", "=", "path", ".", "join", "(", "webRoot", ",", "'themes'", ",", "'uppy'", ",", "'layout'", ",", "'partials'", ",", "'generated_stargazers.ejs'", ")", "fs", ".", "writeFileSync", "(", "dstpath", ",", "data", ".", "stargazers_count", ",", "'utf-8'", ")", "console", ".", "log", "(", "`", "${", "data", ".", "stargazers_count", "}", "${", "dstpath", "}", "`", ")", "}" ]
re-enable after rate limiter issue is fixed
[ "re", "-", "enable", "after", "rate", "limiter", "issue", "is", "fixed" ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/website/inject.js#L131-L151
320
transloadit/uppy
packages/@uppy/aws-s3-multipart/src/index.js
createEventTracker
function createEventTracker (emitter) { const events = [] return { on (event, fn) { events.push([ event, fn ]) return emitter.on(event, fn) }, remove () { events.forEach(([ event, fn ]) => { emitter.off(event, fn) }) } } }
javascript
function createEventTracker (emitter) { const events = [] return { on (event, fn) { events.push([ event, fn ]) return emitter.on(event, fn) }, remove () { events.forEach(([ event, fn ]) => { emitter.off(event, fn) }) } } }
[ "function", "createEventTracker", "(", "emitter", ")", "{", "const", "events", "=", "[", "]", "return", "{", "on", "(", "event", ",", "fn", ")", "{", "events", ".", "push", "(", "[", "event", ",", "fn", "]", ")", "return", "emitter", ".", "on", "(", "event", ",", "fn", ")", "}", ",", "remove", "(", ")", "{", "events", ".", "forEach", "(", "(", "[", "event", ",", "fn", "]", ")", "=>", "{", "emitter", ".", "off", "(", "event", ",", "fn", ")", "}", ")", "}", "}", "}" ]
Create a wrapper around an event emitter with a `remove` method to remove all events that were added using the wrapped emitter.
[ "Create", "a", "wrapper", "around", "an", "event", "emitter", "with", "a", "remove", "method", "to", "remove", "all", "events", "that", "were", "added", "using", "the", "wrapped", "emitter", "." ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/aws-s3-multipart/src/index.js#L12-L25
321
transloadit/uppy
packages/@uppy/provider-views/src/index.js
findIndex
function findIndex (array, predicate) { for (let i = 0; i < array.length; i++) { if (predicate(array[i])) return i } return -1 }
javascript
function findIndex (array, predicate) { for (let i = 0; i < array.length; i++) { if (predicate(array[i])) return i } return -1 }
[ "function", "findIndex", "(", "array", ",", "predicate", ")", "{", "for", "(", "let", "i", "=", "0", ";", "i", "<", "array", ".", "length", ";", "i", "++", ")", "{", "if", "(", "predicate", "(", "array", "[", "i", "]", ")", ")", "return", "i", "}", "return", "-", "1", "}" ]
Array.prototype.findIndex ponyfill for old browsers.
[ "Array", ".", "prototype", ".", "findIndex", "ponyfill", "for", "old", "browsers", "." ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/provider-views/src/index.js#L12-L17
322
transloadit/uppy
packages/@uppy/golden-retriever/src/MetaDataStore.js
findUppyInstances
function findUppyInstances () { const instances = [] for (let i = 0; i < localStorage.length; i++) { const key = localStorage.key(i) if (/^uppyState:/.test(key)) { instances.push(key.slice('uppyState:'.length)) } } return instances }
javascript
function findUppyInstances () { const instances = [] for (let i = 0; i < localStorage.length; i++) { const key = localStorage.key(i) if (/^uppyState:/.test(key)) { instances.push(key.slice('uppyState:'.length)) } } return instances }
[ "function", "findUppyInstances", "(", ")", "{", "const", "instances", "=", "[", "]", "for", "(", "let", "i", "=", "0", ";", "i", "<", "localStorage", ".", "length", ";", "i", "++", ")", "{", "const", "key", "=", "localStorage", ".", "key", "(", "i", ")", "if", "(", "/", "^uppyState:", "/", ".", "test", "(", "key", ")", ")", "{", "instances", ".", "push", "(", "key", ".", "slice", "(", "'uppyState:'", ".", "length", ")", ")", "}", "}", "return", "instances", "}" ]
Get uppy instance IDs for which state is stored.
[ "Get", "uppy", "instance", "IDs", "for", "which", "state", "is", "stored", "." ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/golden-retriever/src/MetaDataStore.js#L4-L13
323
transloadit/uppy
examples/transloadit/main.js
openModal
function openModal () { robodog.pick({ restrictions: { allowedFileTypes: ['.png'] }, waitForEncoding: true, params: { auth: { key: TRANSLOADIT_KEY }, template_id: TEMPLATE_ID }, providers: [ 'webcam' ] // if providers need custom config // webcam: { // option: 'whatever' // } }).then(console.log, console.error) }
javascript
function openModal () { robodog.pick({ restrictions: { allowedFileTypes: ['.png'] }, waitForEncoding: true, params: { auth: { key: TRANSLOADIT_KEY }, template_id: TEMPLATE_ID }, providers: [ 'webcam' ] // if providers need custom config // webcam: { // option: 'whatever' // } }).then(console.log, console.error) }
[ "function", "openModal", "(", ")", "{", "robodog", ".", "pick", "(", "{", "restrictions", ":", "{", "allowedFileTypes", ":", "[", "'.png'", "]", "}", ",", "waitForEncoding", ":", "true", ",", "params", ":", "{", "auth", ":", "{", "key", ":", "TRANSLOADIT_KEY", "}", ",", "template_id", ":", "TEMPLATE_ID", "}", ",", "providers", ":", "[", "'webcam'", "]", "// if providers need custom config", "// webcam: {", "// option: 'whatever'", "// }", "}", ")", ".", "then", "(", "console", ".", "log", ",", "console", ".", "error", ")", "}" ]
robodog.modal
[ "robodog", ".", "modal" ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/examples/transloadit/main.js#L81-L99
324
transloadit/uppy
packages/@uppy/companion/src/server/controllers/s3.js
getUploadParameters
function getUploadParameters (req, res, next) { // @ts-ignore The `uppy` property is added by middleware before reaching here. const client = req.uppy.s3Client const key = config.getKey(req, req.query.filename) if (typeof key !== 'string') { return res.status(500).json({ error: 's3: filename returned from `getKey` must be a string' }) } const fields = { acl: config.acl, key: key, success_action_status: '201', 'content-type': req.query.type } client.createPresignedPost({ Bucket: config.bucket, Expires: ms('5 minutes') / 1000, Fields: fields, Conditions: config.conditions }, (err, data) => { if (err) { next(err) return } res.json({ method: 'post', url: data.url, fields: data.fields }) }) }
javascript
function getUploadParameters (req, res, next) { // @ts-ignore The `uppy` property is added by middleware before reaching here. const client = req.uppy.s3Client const key = config.getKey(req, req.query.filename) if (typeof key !== 'string') { return res.status(500).json({ error: 's3: filename returned from `getKey` must be a string' }) } const fields = { acl: config.acl, key: key, success_action_status: '201', 'content-type': req.query.type } client.createPresignedPost({ Bucket: config.bucket, Expires: ms('5 minutes') / 1000, Fields: fields, Conditions: config.conditions }, (err, data) => { if (err) { next(err) return } res.json({ method: 'post', url: data.url, fields: data.fields }) }) }
[ "function", "getUploadParameters", "(", "req", ",", "res", ",", "next", ")", "{", "// @ts-ignore The `uppy` property is added by middleware before reaching here.", "const", "client", "=", "req", ".", "uppy", ".", "s3Client", "const", "key", "=", "config", ".", "getKey", "(", "req", ",", "req", ".", "query", ".", "filename", ")", "if", "(", "typeof", "key", "!==", "'string'", ")", "{", "return", "res", ".", "status", "(", "500", ")", ".", "json", "(", "{", "error", ":", "'s3: filename returned from `getKey` must be a string'", "}", ")", "}", "const", "fields", "=", "{", "acl", ":", "config", ".", "acl", ",", "key", ":", "key", ",", "success_action_status", ":", "'201'", ",", "'content-type'", ":", "req", ".", "query", ".", "type", "}", "client", ".", "createPresignedPost", "(", "{", "Bucket", ":", "config", ".", "bucket", ",", "Expires", ":", "ms", "(", "'5 minutes'", ")", "/", "1000", ",", "Fields", ":", "fields", ",", "Conditions", ":", "config", ".", "conditions", "}", ",", "(", "err", ",", "data", ")", "=>", "{", "if", "(", "err", ")", "{", "next", "(", "err", ")", "return", "}", "res", ".", "json", "(", "{", "method", ":", "'post'", ",", "url", ":", "data", ".", "url", ",", "fields", ":", "data", ".", "fields", "}", ")", "}", ")", "}" ]
Get upload paramaters for a simple direct upload. Expected query parameters: - filename - The name of the file, given to the `config.getKey` option to determine the object key name in the S3 bucket. - type - The MIME type of the file. Response JSON: - method - The HTTP method to use to upload. - url - The URL to upload to. - fields - Form fields to send along.
[ "Get", "upload", "paramaters", "for", "a", "simple", "direct", "upload", "." ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/companion/src/server/controllers/s3.js#L25-L56
325
transloadit/uppy
packages/@uppy/companion/src/server/controllers/s3.js
createMultipartUpload
function createMultipartUpload (req, res, next) { // @ts-ignore The `uppy` property is added by middleware before reaching here. const client = req.uppy.s3Client const key = config.getKey(req, req.body.filename) const { type } = req.body if (typeof key !== 'string') { return res.status(500).json({ error: 's3: filename returned from `getKey` must be a string' }) } if (typeof type !== 'string') { return res.status(400).json({ error: 's3: content type must be a string' }) } client.createMultipartUpload({ Bucket: config.bucket, Key: key, ACL: config.acl, ContentType: type, Expires: ms('5 minutes') / 1000 }, (err, data) => { if (err) { next(err) return } res.json({ key: data.Key, uploadId: data.UploadId }) }) }
javascript
function createMultipartUpload (req, res, next) { // @ts-ignore The `uppy` property is added by middleware before reaching here. const client = req.uppy.s3Client const key = config.getKey(req, req.body.filename) const { type } = req.body if (typeof key !== 'string') { return res.status(500).json({ error: 's3: filename returned from `getKey` must be a string' }) } if (typeof type !== 'string') { return res.status(400).json({ error: 's3: content type must be a string' }) } client.createMultipartUpload({ Bucket: config.bucket, Key: key, ACL: config.acl, ContentType: type, Expires: ms('5 minutes') / 1000 }, (err, data) => { if (err) { next(err) return } res.json({ key: data.Key, uploadId: data.UploadId }) }) }
[ "function", "createMultipartUpload", "(", "req", ",", "res", ",", "next", ")", "{", "// @ts-ignore The `uppy` property is added by middleware before reaching here.", "const", "client", "=", "req", ".", "uppy", ".", "s3Client", "const", "key", "=", "config", ".", "getKey", "(", "req", ",", "req", ".", "body", ".", "filename", ")", "const", "{", "type", "}", "=", "req", ".", "body", "if", "(", "typeof", "key", "!==", "'string'", ")", "{", "return", "res", ".", "status", "(", "500", ")", ".", "json", "(", "{", "error", ":", "'s3: filename returned from `getKey` must be a string'", "}", ")", "}", "if", "(", "typeof", "type", "!==", "'string'", ")", "{", "return", "res", ".", "status", "(", "400", ")", ".", "json", "(", "{", "error", ":", "'s3: content type must be a string'", "}", ")", "}", "client", ".", "createMultipartUpload", "(", "{", "Bucket", ":", "config", ".", "bucket", ",", "Key", ":", "key", ",", "ACL", ":", "config", ".", "acl", ",", "ContentType", ":", "type", ",", "Expires", ":", "ms", "(", "'5 minutes'", ")", "/", "1000", "}", ",", "(", "err", ",", "data", ")", "=>", "{", "if", "(", "err", ")", "{", "next", "(", "err", ")", "return", "}", "res", ".", "json", "(", "{", "key", ":", "data", ".", "Key", ",", "uploadId", ":", "data", ".", "UploadId", "}", ")", "}", ")", "}" ]
Create an S3 multipart upload. With this, files can be uploaded in chunks of 5MB+ each. Expected JSON body: - filename - The name of the file, given to the `config.getKey` option to determine the object key name in the S3 bucket. - type - The MIME type of the file. Response JSON: - key - The object key in the S3 bucket. - uploadId - The ID of this multipart upload, to be used in later requests.
[ "Create", "an", "S3", "multipart", "upload", ".", "With", "this", "files", "can", "be", "uploaded", "in", "chunks", "of", "5MB", "+", "each", "." ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/companion/src/server/controllers/s3.js#L70-L98
326
transloadit/uppy
packages/@uppy/companion/src/server/controllers/s3.js
getUploadedParts
function getUploadedParts (req, res, next) { // @ts-ignore The `uppy` property is added by middleware before reaching here. const client = req.uppy.s3Client const { uploadId } = req.params const { key } = req.query if (typeof key !== 'string') { return res.status(400).json({ error: 's3: the object key must be passed as a query parameter. For example: "?key=abc.jpg"' }) } let parts = [] listPartsPage(0) function listPartsPage (startAt) { client.listParts({ Bucket: config.bucket, Key: key, UploadId: uploadId, PartNumberMarker: startAt }, (err, data) => { if (err) { next(err) return } parts = parts.concat(data.Parts) if (data.IsTruncated) { // Get the next page. listPartsPage(data.NextPartNumberMarker) } else { done() } }) } function done () { res.json(parts) } }
javascript
function getUploadedParts (req, res, next) { // @ts-ignore The `uppy` property is added by middleware before reaching here. const client = req.uppy.s3Client const { uploadId } = req.params const { key } = req.query if (typeof key !== 'string') { return res.status(400).json({ error: 's3: the object key must be passed as a query parameter. For example: "?key=abc.jpg"' }) } let parts = [] listPartsPage(0) function listPartsPage (startAt) { client.listParts({ Bucket: config.bucket, Key: key, UploadId: uploadId, PartNumberMarker: startAt }, (err, data) => { if (err) { next(err) return } parts = parts.concat(data.Parts) if (data.IsTruncated) { // Get the next page. listPartsPage(data.NextPartNumberMarker) } else { done() } }) } function done () { res.json(parts) } }
[ "function", "getUploadedParts", "(", "req", ",", "res", ",", "next", ")", "{", "// @ts-ignore The `uppy` property is added by middleware before reaching here.", "const", "client", "=", "req", ".", "uppy", ".", "s3Client", "const", "{", "uploadId", "}", "=", "req", ".", "params", "const", "{", "key", "}", "=", "req", ".", "query", "if", "(", "typeof", "key", "!==", "'string'", ")", "{", "return", "res", ".", "status", "(", "400", ")", ".", "json", "(", "{", "error", ":", "'s3: the object key must be passed as a query parameter. For example: \"?key=abc.jpg\"'", "}", ")", "}", "let", "parts", "=", "[", "]", "listPartsPage", "(", "0", ")", "function", "listPartsPage", "(", "startAt", ")", "{", "client", ".", "listParts", "(", "{", "Bucket", ":", "config", ".", "bucket", ",", "Key", ":", "key", ",", "UploadId", ":", "uploadId", ",", "PartNumberMarker", ":", "startAt", "}", ",", "(", "err", ",", "data", ")", "=>", "{", "if", "(", "err", ")", "{", "next", "(", "err", ")", "return", "}", "parts", "=", "parts", ".", "concat", "(", "data", ".", "Parts", ")", "if", "(", "data", ".", "IsTruncated", ")", "{", "// Get the next page.", "listPartsPage", "(", "data", ".", "NextPartNumberMarker", ")", "}", "else", "{", "done", "(", ")", "}", "}", ")", "}", "function", "done", "(", ")", "{", "res", ".", "json", "(", "parts", ")", "}", "}" ]
List parts that have been fully uploaded so far. Expected URL parameters: - uploadId - The uploadId returned from `createMultipartUpload`. Expected query parameters: - key - The object key in the S3 bucket. Response JSON: - An array of objects representing parts: - PartNumber - the index of this part. - ETag - a hash of this part's contents, used to refer to it. - Size - size of this part.
[ "List", "parts", "that", "have", "been", "fully", "uploaded", "so", "far", "." ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/companion/src/server/controllers/s3.js#L113-L152
327
transloadit/uppy
packages/@uppy/companion/src/server/controllers/s3.js
signPartUpload
function signPartUpload (req, res, next) { // @ts-ignore The `uppy` property is added by middleware before reaching here. const client = req.uppy.s3Client const { uploadId, partNumber } = req.params const { key } = req.query if (typeof key !== 'string') { return res.status(400).json({ error: 's3: the object key must be passed as a query parameter. For example: "?key=abc.jpg"' }) } if (!parseInt(partNumber, 10)) { return res.status(400).json({ error: 's3: the part number must be a number between 1 and 10000.' }) } client.getSignedUrl('uploadPart', { Bucket: config.bucket, Key: key, UploadId: uploadId, PartNumber: partNumber, Body: '', Expires: ms('5 minutes') / 1000 }, (err, url) => { if (err) { next(err) return } res.json({ url }) }) }
javascript
function signPartUpload (req, res, next) { // @ts-ignore The `uppy` property is added by middleware before reaching here. const client = req.uppy.s3Client const { uploadId, partNumber } = req.params const { key } = req.query if (typeof key !== 'string') { return res.status(400).json({ error: 's3: the object key must be passed as a query parameter. For example: "?key=abc.jpg"' }) } if (!parseInt(partNumber, 10)) { return res.status(400).json({ error: 's3: the part number must be a number between 1 and 10000.' }) } client.getSignedUrl('uploadPart', { Bucket: config.bucket, Key: key, UploadId: uploadId, PartNumber: partNumber, Body: '', Expires: ms('5 minutes') / 1000 }, (err, url) => { if (err) { next(err) return } res.json({ url }) }) }
[ "function", "signPartUpload", "(", "req", ",", "res", ",", "next", ")", "{", "// @ts-ignore The `uppy` property is added by middleware before reaching here.", "const", "client", "=", "req", ".", "uppy", ".", "s3Client", "const", "{", "uploadId", ",", "partNumber", "}", "=", "req", ".", "params", "const", "{", "key", "}", "=", "req", ".", "query", "if", "(", "typeof", "key", "!==", "'string'", ")", "{", "return", "res", ".", "status", "(", "400", ")", ".", "json", "(", "{", "error", ":", "'s3: the object key must be passed as a query parameter. For example: \"?key=abc.jpg\"'", "}", ")", "}", "if", "(", "!", "parseInt", "(", "partNumber", ",", "10", ")", ")", "{", "return", "res", ".", "status", "(", "400", ")", ".", "json", "(", "{", "error", ":", "'s3: the part number must be a number between 1 and 10000.'", "}", ")", "}", "client", ".", "getSignedUrl", "(", "'uploadPart'", ",", "{", "Bucket", ":", "config", ".", "bucket", ",", "Key", ":", "key", ",", "UploadId", ":", "uploadId", ",", "PartNumber", ":", "partNumber", ",", "Body", ":", "''", ",", "Expires", ":", "ms", "(", "'5 minutes'", ")", "/", "1000", "}", ",", "(", "err", ",", "url", ")", "=>", "{", "if", "(", "err", ")", "{", "next", "(", "err", ")", "return", "}", "res", ".", "json", "(", "{", "url", "}", ")", "}", ")", "}" ]
Get parameters for uploading one part. Expected URL parameters: - uploadId - The uploadId returned from `createMultipartUpload`. - partNumber - This part's index in the file (1-10000). Expected query parameters: - key - The object key in the S3 bucket. Response JSON: - url - The URL to upload to, including signed query parameters.
[ "Get", "parameters", "for", "uploading", "one", "part", "." ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/companion/src/server/controllers/s3.js#L165-L192
328
transloadit/uppy
packages/@uppy/companion/src/server/controllers/s3.js
abortMultipartUpload
function abortMultipartUpload (req, res, next) { // @ts-ignore The `uppy` property is added by middleware before reaching here. const client = req.uppy.s3Client const { uploadId } = req.params const { key } = req.query if (typeof key !== 'string') { return res.status(400).json({ error: 's3: the object key must be passed as a query parameter. For example: "?key=abc.jpg"' }) } client.abortMultipartUpload({ Bucket: config.bucket, Key: key, UploadId: uploadId }, (err, data) => { if (err) { next(err) return } res.json({}) }) }
javascript
function abortMultipartUpload (req, res, next) { // @ts-ignore The `uppy` property is added by middleware before reaching here. const client = req.uppy.s3Client const { uploadId } = req.params const { key } = req.query if (typeof key !== 'string') { return res.status(400).json({ error: 's3: the object key must be passed as a query parameter. For example: "?key=abc.jpg"' }) } client.abortMultipartUpload({ Bucket: config.bucket, Key: key, UploadId: uploadId }, (err, data) => { if (err) { next(err) return } res.json({}) }) }
[ "function", "abortMultipartUpload", "(", "req", ",", "res", ",", "next", ")", "{", "// @ts-ignore The `uppy` property is added by middleware before reaching here.", "const", "client", "=", "req", ".", "uppy", ".", "s3Client", "const", "{", "uploadId", "}", "=", "req", ".", "params", "const", "{", "key", "}", "=", "req", ".", "query", "if", "(", "typeof", "key", "!==", "'string'", ")", "{", "return", "res", ".", "status", "(", "400", ")", ".", "json", "(", "{", "error", ":", "'s3: the object key must be passed as a query parameter. For example: \"?key=abc.jpg\"'", "}", ")", "}", "client", ".", "abortMultipartUpload", "(", "{", "Bucket", ":", "config", ".", "bucket", ",", "Key", ":", "key", ",", "UploadId", ":", "uploadId", "}", ",", "(", "err", ",", "data", ")", "=>", "{", "if", "(", "err", ")", "{", "next", "(", "err", ")", "return", "}", "res", ".", "json", "(", "{", "}", ")", "}", ")", "}" ]
Abort a multipart upload, deleting already uploaded parts. Expected URL parameters: - uploadId - The uploadId returned from `createMultipartUpload`. Expected query parameters: - key - The object key in the S3 bucket. Response JSON: Empty.
[ "Abort", "a", "multipart", "upload", "deleting", "already", "uploaded", "parts", "." ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/companion/src/server/controllers/s3.js#L204-L225
329
transloadit/uppy
packages/@uppy/companion/src/server/controllers/s3.js
completeMultipartUpload
function completeMultipartUpload (req, res, next) { // @ts-ignore The `uppy` property is added by middleware before reaching here. const client = req.uppy.s3Client const { uploadId } = req.params const { key } = req.query const { parts } = req.body if (typeof key !== 'string') { return res.status(400).json({ error: 's3: the object key must be passed as a query parameter. For example: "?key=abc.jpg"' }) } if (!Array.isArray(parts) || !parts.every(isValidPart)) { return res.status(400).json({ error: 's3: `parts` must be an array of {ETag, PartNumber} objects.' }) } client.completeMultipartUpload({ Bucket: config.bucket, Key: key, UploadId: uploadId, MultipartUpload: { Parts: parts } }, (err, data) => { if (err) { next(err) return } res.json({ location: data.Location }) }) }
javascript
function completeMultipartUpload (req, res, next) { // @ts-ignore The `uppy` property is added by middleware before reaching here. const client = req.uppy.s3Client const { uploadId } = req.params const { key } = req.query const { parts } = req.body if (typeof key !== 'string') { return res.status(400).json({ error: 's3: the object key must be passed as a query parameter. For example: "?key=abc.jpg"' }) } if (!Array.isArray(parts) || !parts.every(isValidPart)) { return res.status(400).json({ error: 's3: `parts` must be an array of {ETag, PartNumber} objects.' }) } client.completeMultipartUpload({ Bucket: config.bucket, Key: key, UploadId: uploadId, MultipartUpload: { Parts: parts } }, (err, data) => { if (err) { next(err) return } res.json({ location: data.Location }) }) }
[ "function", "completeMultipartUpload", "(", "req", ",", "res", ",", "next", ")", "{", "// @ts-ignore The `uppy` property is added by middleware before reaching here.", "const", "client", "=", "req", ".", "uppy", ".", "s3Client", "const", "{", "uploadId", "}", "=", "req", ".", "params", "const", "{", "key", "}", "=", "req", ".", "query", "const", "{", "parts", "}", "=", "req", ".", "body", "if", "(", "typeof", "key", "!==", "'string'", ")", "{", "return", "res", ".", "status", "(", "400", ")", ".", "json", "(", "{", "error", ":", "'s3: the object key must be passed as a query parameter. For example: \"?key=abc.jpg\"'", "}", ")", "}", "if", "(", "!", "Array", ".", "isArray", "(", "parts", ")", "||", "!", "parts", ".", "every", "(", "isValidPart", ")", ")", "{", "return", "res", ".", "status", "(", "400", ")", ".", "json", "(", "{", "error", ":", "'s3: `parts` must be an array of {ETag, PartNumber} objects.'", "}", ")", "}", "client", ".", "completeMultipartUpload", "(", "{", "Bucket", ":", "config", ".", "bucket", ",", "Key", ":", "key", ",", "UploadId", ":", "uploadId", ",", "MultipartUpload", ":", "{", "Parts", ":", "parts", "}", "}", ",", "(", "err", ",", "data", ")", "=>", "{", "if", "(", "err", ")", "{", "next", "(", "err", ")", "return", "}", "res", ".", "json", "(", "{", "location", ":", "data", ".", "Location", "}", ")", "}", ")", "}" ]
Complete a multipart upload, combining all the parts into a single object in the S3 bucket. Expected URL parameters: - uploadId - The uploadId returned from `createMultipartUpload`. Expected query parameters: - key - The object key in the S3 bucket. Expected JSON body: - parts - An array of parts, see the `getUploadedParts` response JSON. Response JSON: - location - The full URL to the object in the S3 bucket.
[ "Complete", "a", "multipart", "upload", "combining", "all", "the", "parts", "into", "a", "single", "object", "in", "the", "S3", "bucket", "." ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/companion/src/server/controllers/s3.js#L239-L269
330
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/utils.js
assertLoadedUrlEqual
function assertLoadedUrlEqual(controller, targetUrl) { var locationBar = new elementslib.ID(controller.window.document, "urlbar"); var currentURL = locationBar.getNode().value; // Load the target URL controller.open(targetUrl); controller.waitForPageLoad(); // Check the same web page has been opened controller.waitForEval("subject.targetURL.value == subject.currentURL", gTimeout, 100, {targetURL: locationBar.getNode(), currentURL: currentURL}); }
javascript
function assertLoadedUrlEqual(controller, targetUrl) { var locationBar = new elementslib.ID(controller.window.document, "urlbar"); var currentURL = locationBar.getNode().value; // Load the target URL controller.open(targetUrl); controller.waitForPageLoad(); // Check the same web page has been opened controller.waitForEval("subject.targetURL.value == subject.currentURL", gTimeout, 100, {targetURL: locationBar.getNode(), currentURL: currentURL}); }
[ "function", "assertLoadedUrlEqual", "(", "controller", ",", "targetUrl", ")", "{", "var", "locationBar", "=", "new", "elementslib", ".", "ID", "(", "controller", ".", "window", ".", "document", ",", "\"urlbar\"", ")", ";", "var", "currentURL", "=", "locationBar", ".", "getNode", "(", ")", ".", "value", ";", "// Load the target URL", "controller", ".", "open", "(", "targetUrl", ")", ";", "controller", ".", "waitForPageLoad", "(", ")", ";", "// Check the same web page has been opened", "controller", ".", "waitForEval", "(", "\"subject.targetURL.value == subject.currentURL\"", ",", "gTimeout", ",", "100", ",", "{", "targetURL", ":", "locationBar", ".", "getNode", "(", ")", ",", "currentURL", ":", "currentURL", "}", ")", ";", "}" ]
Assert if the current URL is identical to the target URL. With this function also redirects can be tested. @param {MozmillController} controller MozMillController of the window to operate on @param {string} targetURL URL to check
[ "Assert", "if", "the", "current", "URL", "is", "identical", "to", "the", "target", "URL", ".", "With", "this", "function", "also", "redirects", "can", "be", "tested", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/utils.js#L194-L205
331
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/utils.js
closeContentAreaContextMenu
function closeContentAreaContextMenu(controller) { var contextMenu = new elementslib.ID(controller.window.document, "contentAreaContextMenu"); controller.keypress(contextMenu, "VK_ESCAPE", {}); }
javascript
function closeContentAreaContextMenu(controller) { var contextMenu = new elementslib.ID(controller.window.document, "contentAreaContextMenu"); controller.keypress(contextMenu, "VK_ESCAPE", {}); }
[ "function", "closeContentAreaContextMenu", "(", "controller", ")", "{", "var", "contextMenu", "=", "new", "elementslib", ".", "ID", "(", "controller", ".", "window", ".", "document", ",", "\"contentAreaContextMenu\"", ")", ";", "controller", ".", "keypress", "(", "contextMenu", ",", "\"VK_ESCAPE\"", ",", "{", "}", ")", ";", "}" ]
Close the context menu inside the content area of the currently open tab @param {MozmillController} controller MozMillController of the window to operate on
[ "Close", "the", "context", "menu", "inside", "the", "content", "area", "of", "the", "currently", "open", "tab" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/utils.js#L213-L216
332
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/utils.js
checkSearchField
function checkSearchField(controller, searchField, searchTerm, submitButton, timeout) { controller.waitThenClick(searchField, timeout); controller.type(searchField, searchTerm); if (submitButton != undefined) { controller.waitThenClick(submitButton, timeout); } }
javascript
function checkSearchField(controller, searchField, searchTerm, submitButton, timeout) { controller.waitThenClick(searchField, timeout); controller.type(searchField, searchTerm); if (submitButton != undefined) { controller.waitThenClick(submitButton, timeout); } }
[ "function", "checkSearchField", "(", "controller", ",", "searchField", ",", "searchTerm", ",", "submitButton", ",", "timeout", ")", "{", "controller", ".", "waitThenClick", "(", "searchField", ",", "timeout", ")", ";", "controller", ".", "type", "(", "searchField", ",", "searchTerm", ")", ";", "if", "(", "submitButton", "!=", "undefined", ")", "{", "controller", ".", "waitThenClick", "(", "submitButton", ",", "timeout", ")", ";", "}", "}" ]
Run tests against a given search form @param {MozMillController} controller MozMillController of the window to operate on @param {ElemBase} searchField The HTML input form element to test @param {string} searchTerm The search term for the test @param {ElemBase} submitButton (Optional) The forms submit button @param {number} timeout The timeout value for the single tests
[ "Run", "tests", "against", "a", "given", "search", "form" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/utils.js#L232-L241
333
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/utils.js
createURI
function createURI(spec, originCharset, baseURI) { let iosvc = Cc["@mozilla.org/network/io-service;1"]. getService(Ci.nsIIOService); return iosvc.newURI(spec, originCharset, baseURI); }
javascript
function createURI(spec, originCharset, baseURI) { let iosvc = Cc["@mozilla.org/network/io-service;1"]. getService(Ci.nsIIOService); return iosvc.newURI(spec, originCharset, baseURI); }
[ "function", "createURI", "(", "spec", ",", "originCharset", ",", "baseURI", ")", "{", "let", "iosvc", "=", "Cc", "[", "\"@mozilla.org/network/io-service;1\"", "]", ".", "getService", "(", "Ci", ".", "nsIIOService", ")", ";", "return", "iosvc", ".", "newURI", "(", "spec", ",", "originCharset", ",", "baseURI", ")", ";", "}" ]
Create a new URI @param {string} spec The URI string in UTF-8 encoding. @param {string} originCharset The charset of the document from which this URI string originated. @param {string} baseURI If null, spec must specify an absolute URI. Otherwise, spec may be resolved relative to baseURI, depending on the protocol. @return A URI object @type nsIURI
[ "Create", "a", "new", "URI" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/utils.js#L256-L262
334
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/utils.js
formatUrlPref
function formatUrlPref(prefName) { var formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"] .getService(Ci.nsIURLFormatter); return formatter.formatURLPref(prefName); }
javascript
function formatUrlPref(prefName) { var formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"] .getService(Ci.nsIURLFormatter); return formatter.formatURLPref(prefName); }
[ "function", "formatUrlPref", "(", "prefName", ")", "{", "var", "formatter", "=", "Cc", "[", "\"@mozilla.org/toolkit/URLFormatterService;1\"", "]", ".", "getService", "(", "Ci", ".", "nsIURLFormatter", ")", ";", "return", "formatter", ".", "formatURLPref", "(", "prefName", ")", ";", "}" ]
Format a URL by replacing all placeholders @param {string} prefName The preference name which contains the URL @return The formatted URL @type string
[ "Format", "a", "URL", "by", "replacing", "all", "placeholders" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/utils.js#L281-L286
335
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/utils.js
getDefaultHomepage
function getDefaultHomepage() { var preferences = prefs.preferences; var prefValue = preferences.getPref("browser.startup.homepage", "", true, Ci.nsIPrefLocalizedString); return prefValue.data; }
javascript
function getDefaultHomepage() { var preferences = prefs.preferences; var prefValue = preferences.getPref("browser.startup.homepage", "", true, Ci.nsIPrefLocalizedString); return prefValue.data; }
[ "function", "getDefaultHomepage", "(", ")", "{", "var", "preferences", "=", "prefs", ".", "preferences", ";", "var", "prefValue", "=", "preferences", ".", "getPref", "(", "\"browser.startup.homepage\"", ",", "\"\"", ",", "true", ",", "Ci", ".", "nsIPrefLocalizedString", ")", ";", "return", "prefValue", ".", "data", ";", "}" ]
Returns the default home page @return The URL of the default homepage @type string
[ "Returns", "the", "default", "home", "page" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/utils.js#L294-L300
336
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/utils.js
getEntity
function getEntity(urls, entityId) { // Add xhtml11.dtd to prevent missing entity errors with XHTML files urls.push("resource:///res/dtd/xhtml11.dtd"); // Build a string of external entities var extEntities = ""; for (i = 0; i < urls.length; i++) { extEntities += '<!ENTITY % dtd' + i + ' SYSTEM "' + urls[i] + '">%dtd' + i + ';'; } var parser = Cc["@mozilla.org/xmlextras/domparser;1"] .createInstance(Ci.nsIDOMParser); var header = '<?xml version="1.0"?><!DOCTYPE elem [' + extEntities + ']>'; var elem = '<elem id="elementID">&' + entityId + ';</elem>'; var doc = parser.parseFromString(header + elem, 'text/xml'); var elemNode = doc.querySelector('elem[id="elementID"]'); if (elemNode == null) throw new Error(arguments.callee.name + ": Unknown entity - " + entityId); return elemNode.textContent; }
javascript
function getEntity(urls, entityId) { // Add xhtml11.dtd to prevent missing entity errors with XHTML files urls.push("resource:///res/dtd/xhtml11.dtd"); // Build a string of external entities var extEntities = ""; for (i = 0; i < urls.length; i++) { extEntities += '<!ENTITY % dtd' + i + ' SYSTEM "' + urls[i] + '">%dtd' + i + ';'; } var parser = Cc["@mozilla.org/xmlextras/domparser;1"] .createInstance(Ci.nsIDOMParser); var header = '<?xml version="1.0"?><!DOCTYPE elem [' + extEntities + ']>'; var elem = '<elem id="elementID">&' + entityId + ';</elem>'; var doc = parser.parseFromString(header + elem, 'text/xml'); var elemNode = doc.querySelector('elem[id="elementID"]'); if (elemNode == null) throw new Error(arguments.callee.name + ": Unknown entity - " + entityId); return elemNode.textContent; }
[ "function", "getEntity", "(", "urls", ",", "entityId", ")", "{", "// Add xhtml11.dtd to prevent missing entity errors with XHTML files", "urls", ".", "push", "(", "\"resource:///res/dtd/xhtml11.dtd\"", ")", ";", "// Build a string of external entities", "var", "extEntities", "=", "\"\"", ";", "for", "(", "i", "=", "0", ";", "i", "<", "urls", ".", "length", ";", "i", "++", ")", "{", "extEntities", "+=", "'<!ENTITY % dtd'", "+", "i", "+", "' SYSTEM \"'", "+", "urls", "[", "i", "]", "+", "'\">%dtd'", "+", "i", "+", "';'", ";", "}", "var", "parser", "=", "Cc", "[", "\"@mozilla.org/xmlextras/domparser;1\"", "]", ".", "createInstance", "(", "Ci", ".", "nsIDOMParser", ")", ";", "var", "header", "=", "'<?xml version=\"1.0\"?><!DOCTYPE elem ['", "+", "extEntities", "+", "']>'", ";", "var", "elem", "=", "'<elem id=\"elementID\">&'", "+", "entityId", "+", "';</elem>'", ";", "var", "doc", "=", "parser", ".", "parseFromString", "(", "header", "+", "elem", ",", "'text/xml'", ")", ";", "var", "elemNode", "=", "doc", ".", "querySelector", "(", "'elem[id=\"elementID\"]'", ")", ";", "if", "(", "elemNode", "==", "null", ")", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Unknown entity - \"", "+", "entityId", ")", ";", "return", "elemNode", ".", "textContent", ";", "}" ]
Returns the value of an individual entity in a DTD file. @param [string] urls Array of DTD urls. @param {string} entityId The ID of the entity to get the value of. @return The value of the requested entity @type string
[ "Returns", "the", "value", "of", "an", "individual", "entity", "in", "a", "DTD", "file", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/utils.js#L313-L335
337
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/utils.js
getProperty
function getProperty(url, prefName) { var sbs = Cc["@mozilla.org/intl/stringbundle;1"] .getService(Ci.nsIStringBundleService); var bundle = sbs.createBundle(url); try { return bundle.GetStringFromName(prefName); } catch (ex) { throw new Error(arguments.callee.name + ": Unknown property - " + prefName); } }
javascript
function getProperty(url, prefName) { var sbs = Cc["@mozilla.org/intl/stringbundle;1"] .getService(Ci.nsIStringBundleService); var bundle = sbs.createBundle(url); try { return bundle.GetStringFromName(prefName); } catch (ex) { throw new Error(arguments.callee.name + ": Unknown property - " + prefName); } }
[ "function", "getProperty", "(", "url", ",", "prefName", ")", "{", "var", "sbs", "=", "Cc", "[", "\"@mozilla.org/intl/stringbundle;1\"", "]", ".", "getService", "(", "Ci", ".", "nsIStringBundleService", ")", ";", "var", "bundle", "=", "sbs", ".", "createBundle", "(", "url", ")", ";", "try", "{", "return", "bundle", ".", "GetStringFromName", "(", "prefName", ")", ";", "}", "catch", "(", "ex", ")", "{", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Unknown property - \"", "+", "prefName", ")", ";", "}", "}" ]
Returns the value of an individual property. @param {string} url URL of the string bundle. @param {string} prefName The property to get the value of. @return The value of the requested property @type string
[ "Returns", "the", "value", "of", "an", "individual", "property", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/utils.js#L348-L358
338
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/utils.js
handleWindow
function handleWindow(type, text, callback, dontClose) { // Set the window opener function to use depending on the type var func_ptr = null; switch (type) { case "type": func_ptr = mozmill.utils.getWindowByType; break; case "title": func_ptr = mozmill.utils.getWindowByTitle; break; default: throw new Error(arguments.callee.name + ": Unknown opener type - " + type); } var window = null; var controller = null; try { // Wait until the window has been opened mozmill.utils.waitFor(function () { window = func_ptr(text); return window != null; }, "Window has been found."); // XXX: We still have to find a reliable way to wait until the new window // content has been finished loading. Let's wait for now. controller = new mozmill.controller.MozMillController(window); controller.sleep(200); if (callback) { callback(controller); } // Check if we have to close the window dontClose = dontClose || false; if (dontClose == false & window != null) { controller.window.close(); mozmill.utils.waitFor(function () { return func_ptr(text) != window; }, "Window has been closed."); window = null; controller = null; } return controller; } catch (ex) { if (window) window.close(); throw ex; } }
javascript
function handleWindow(type, text, callback, dontClose) { // Set the window opener function to use depending on the type var func_ptr = null; switch (type) { case "type": func_ptr = mozmill.utils.getWindowByType; break; case "title": func_ptr = mozmill.utils.getWindowByTitle; break; default: throw new Error(arguments.callee.name + ": Unknown opener type - " + type); } var window = null; var controller = null; try { // Wait until the window has been opened mozmill.utils.waitFor(function () { window = func_ptr(text); return window != null; }, "Window has been found."); // XXX: We still have to find a reliable way to wait until the new window // content has been finished loading. Let's wait for now. controller = new mozmill.controller.MozMillController(window); controller.sleep(200); if (callback) { callback(controller); } // Check if we have to close the window dontClose = dontClose || false; if (dontClose == false & window != null) { controller.window.close(); mozmill.utils.waitFor(function () { return func_ptr(text) != window; }, "Window has been closed."); window = null; controller = null; } return controller; } catch (ex) { if (window) window.close(); throw ex; } }
[ "function", "handleWindow", "(", "type", ",", "text", ",", "callback", ",", "dontClose", ")", "{", "// Set the window opener function to use depending on the type", "var", "func_ptr", "=", "null", ";", "switch", "(", "type", ")", "{", "case", "\"type\"", ":", "func_ptr", "=", "mozmill", ".", "utils", ".", "getWindowByType", ";", "break", ";", "case", "\"title\"", ":", "func_ptr", "=", "mozmill", ".", "utils", ".", "getWindowByTitle", ";", "break", ";", "default", ":", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Unknown opener type - \"", "+", "type", ")", ";", "}", "var", "window", "=", "null", ";", "var", "controller", "=", "null", ";", "try", "{", "// Wait until the window has been opened", "mozmill", ".", "utils", ".", "waitFor", "(", "function", "(", ")", "{", "window", "=", "func_ptr", "(", "text", ")", ";", "return", "window", "!=", "null", ";", "}", ",", "\"Window has been found.\"", ")", ";", "// XXX: We still have to find a reliable way to wait until the new window", "// content has been finished loading. Let's wait for now.", "controller", "=", "new", "mozmill", ".", "controller", ".", "MozMillController", "(", "window", ")", ";", "controller", ".", "sleep", "(", "200", ")", ";", "if", "(", "callback", ")", "{", "callback", "(", "controller", ")", ";", "}", "// Check if we have to close the window", "dontClose", "=", "dontClose", "||", "false", ";", "if", "(", "dontClose", "==", "false", "&", "window", "!=", "null", ")", "{", "controller", ".", "window", ".", "close", "(", ")", ";", "mozmill", ".", "utils", ".", "waitFor", "(", "function", "(", ")", "{", "return", "func_ptr", "(", "text", ")", "!=", "window", ";", "}", ",", "\"Window has been closed.\"", ")", ";", "window", "=", "null", ";", "controller", "=", "null", ";", "}", "return", "controller", ";", "}", "catch", "(", "ex", ")", "{", "if", "(", "window", ")", "window", ".", "close", "(", ")", ";", "throw", "ex", ";", "}", "}" ]
Function to handle non-modal windows @param {string} type Specifies how to check for the new window (possible values: type or title) @param {string} text The window type of title string to search for @param {function} callback (optional) Callback function to call for window specific tests @param {boolean} dontClose (optional) Doens't close the window after the return from the callback handler @returns The MozMillController of the window (if the window hasn't been closed)
[ "Function", "to", "handle", "non", "-", "modal", "windows" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/utils.js#L373-L425
339
SeleniumHQ/selenium
javascript/node/selenium-webdriver/firefox.js
createExecutor
function createExecutor(serverUrl) { let client = serverUrl.then(url => new http.HttpClient(url)); let executor = new http.Executor(client); configureExecutor(executor); return executor; }
javascript
function createExecutor(serverUrl) { let client = serverUrl.then(url => new http.HttpClient(url)); let executor = new http.Executor(client); configureExecutor(executor); return executor; }
[ "function", "createExecutor", "(", "serverUrl", ")", "{", "let", "client", "=", "serverUrl", ".", "then", "(", "url", "=>", "new", "http", ".", "HttpClient", "(", "url", ")", ")", ";", "let", "executor", "=", "new", "http", ".", "Executor", "(", "client", ")", ";", "configureExecutor", "(", "executor", ")", ";", "return", "executor", ";", "}" ]
Creates a command executor with support for Marionette's custom commands. @param {!Promise<string>} serverUrl The server's URL. @return {!command.Executor} The new command executor.
[ "Creates", "a", "command", "executor", "with", "support", "for", "Marionette", "s", "custom", "commands", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/node/selenium-webdriver/firefox.js#L470-L475
340
SeleniumHQ/selenium
javascript/node/selenium-webdriver/firefox.js
configureExecutor
function configureExecutor(executor) { executor.defineCommand( ExtensionCommand.GET_CONTEXT, 'GET', '/session/:sessionId/moz/context'); executor.defineCommand( ExtensionCommand.SET_CONTEXT, 'POST', '/session/:sessionId/moz/context'); executor.defineCommand( ExtensionCommand.INSTALL_ADDON, 'POST', '/session/:sessionId/moz/addon/install'); executor.defineCommand( ExtensionCommand.UNINSTALL_ADDON, 'POST', '/session/:sessionId/moz/addon/uninstall'); }
javascript
function configureExecutor(executor) { executor.defineCommand( ExtensionCommand.GET_CONTEXT, 'GET', '/session/:sessionId/moz/context'); executor.defineCommand( ExtensionCommand.SET_CONTEXT, 'POST', '/session/:sessionId/moz/context'); executor.defineCommand( ExtensionCommand.INSTALL_ADDON, 'POST', '/session/:sessionId/moz/addon/install'); executor.defineCommand( ExtensionCommand.UNINSTALL_ADDON, 'POST', '/session/:sessionId/moz/addon/uninstall'); }
[ "function", "configureExecutor", "(", "executor", ")", "{", "executor", ".", "defineCommand", "(", "ExtensionCommand", ".", "GET_CONTEXT", ",", "'GET'", ",", "'/session/:sessionId/moz/context'", ")", ";", "executor", ".", "defineCommand", "(", "ExtensionCommand", ".", "SET_CONTEXT", ",", "'POST'", ",", "'/session/:sessionId/moz/context'", ")", ";", "executor", ".", "defineCommand", "(", "ExtensionCommand", ".", "INSTALL_ADDON", ",", "'POST'", ",", "'/session/:sessionId/moz/addon/install'", ")", ";", "executor", ".", "defineCommand", "(", "ExtensionCommand", ".", "UNINSTALL_ADDON", ",", "'POST'", ",", "'/session/:sessionId/moz/addon/uninstall'", ")", ";", "}" ]
Configures the given executor with Firefox-specific commands. @param {!http.Executor} executor the executor to configure.
[ "Configures", "the", "given", "executor", "with", "Firefox", "-", "specific", "commands", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/node/selenium-webdriver/firefox.js#L482-L502
341
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/tabview.js
tabView_open
function tabView_open() { var menuitem = new elementslib.Elem(this._controller.menus['view-menu'].menu_tabview); this._controller.click(menuitem); this.waitForOpened(); this._tabView = this.getElement({type: "tabView"}); this._tabViewDoc = this._tabView.getNode().webNavigation.document; }
javascript
function tabView_open() { var menuitem = new elementslib.Elem(this._controller.menus['view-menu'].menu_tabview); this._controller.click(menuitem); this.waitForOpened(); this._tabView = this.getElement({type: "tabView"}); this._tabViewDoc = this._tabView.getNode().webNavigation.document; }
[ "function", "tabView_open", "(", ")", "{", "var", "menuitem", "=", "new", "elementslib", ".", "Elem", "(", "this", ".", "_controller", ".", "menus", "[", "'view-menu'", "]", ".", "menu_tabview", ")", ";", "this", ".", "_controller", ".", "click", "(", "menuitem", ")", ";", "this", ".", "waitForOpened", "(", ")", ";", "this", ".", "_tabView", "=", "this", ".", "getElement", "(", "{", "type", ":", "\"tabView\"", "}", ")", ";", "this", ".", "_tabViewDoc", "=", "this", ".", "_tabView", ".", "getNode", "(", ")", ".", "webNavigation", ".", "document", ";", "}" ]
Open the Tab View
[ "Open", "the", "Tab", "View" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/tabview.js#L86-L93
342
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/tabview.js
tabView_waitForOpened
function tabView_waitForOpened() { // Add event listener to wait until the tabview has been opened var self = { opened: false }; function checkOpened() { self.opened = true; } this._controller.window.addEventListener("tabviewshown", checkOpened, false); try { mozmill.utils.waitFor(function() { return self.opened == true; }, TIMEOUT, 100, "TabView is not open."); this._tabViewObject = this._controller.window.TabView; this._groupItemsObject = this._tabViewObject._window.GroupItems; this._tabItemsObject = this._tabViewObject._window.TabItems; } finally { this._controller.window.removeEventListener("tabviewshown", checkOpened, false); } }
javascript
function tabView_waitForOpened() { // Add event listener to wait until the tabview has been opened var self = { opened: false }; function checkOpened() { self.opened = true; } this._controller.window.addEventListener("tabviewshown", checkOpened, false); try { mozmill.utils.waitFor(function() { return self.opened == true; }, TIMEOUT, 100, "TabView is not open."); this._tabViewObject = this._controller.window.TabView; this._groupItemsObject = this._tabViewObject._window.GroupItems; this._tabItemsObject = this._tabViewObject._window.TabItems; } finally { this._controller.window.removeEventListener("tabviewshown", checkOpened, false); } }
[ "function", "tabView_waitForOpened", "(", ")", "{", "// Add event listener to wait until the tabview has been opened", "var", "self", "=", "{", "opened", ":", "false", "}", ";", "function", "checkOpened", "(", ")", "{", "self", ".", "opened", "=", "true", ";", "}", "this", ".", "_controller", ".", "window", ".", "addEventListener", "(", "\"tabviewshown\"", ",", "checkOpened", ",", "false", ")", ";", "try", "{", "mozmill", ".", "utils", ".", "waitFor", "(", "function", "(", ")", "{", "return", "self", ".", "opened", "==", "true", ";", "}", ",", "TIMEOUT", ",", "100", ",", "\"TabView is not open.\"", ")", ";", "this", ".", "_tabViewObject", "=", "this", ".", "_controller", ".", "window", ".", "TabView", ";", "this", ".", "_groupItemsObject", "=", "this", ".", "_tabViewObject", ".", "_window", ".", "GroupItems", ";", "this", ".", "_tabItemsObject", "=", "this", ".", "_tabViewObject", ".", "_window", ".", "TabItems", ";", "}", "finally", "{", "this", ".", "_controller", ".", "window", ".", "removeEventListener", "(", "\"tabviewshown\"", ",", "checkOpened", ",", "false", ")", ";", "}", "}" ]
Wait until the Tab View has been opened
[ "Wait", "until", "the", "Tab", "View", "has", "been", "opened" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/tabview.js#L98-L115
343
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/tabview.js
tabView_close
function tabView_close() { var menuitem = new elementslib.Elem(this._controller.menus['view-menu'].menu_tabview); this._controller.click(menuitem); this.waitForClosed(); this._tabView = null; this._tabViewDoc = this._controller.window.document; }
javascript
function tabView_close() { var menuitem = new elementslib.Elem(this._controller.menus['view-menu'].menu_tabview); this._controller.click(menuitem); this.waitForClosed(); this._tabView = null; this._tabViewDoc = this._controller.window.document; }
[ "function", "tabView_close", "(", ")", "{", "var", "menuitem", "=", "new", "elementslib", ".", "Elem", "(", "this", ".", "_controller", ".", "menus", "[", "'view-menu'", "]", ".", "menu_tabview", ")", ";", "this", ".", "_controller", ".", "click", "(", "menuitem", ")", ";", "this", ".", "waitForClosed", "(", ")", ";", "this", ".", "_tabView", "=", "null", ";", "this", ".", "_tabViewDoc", "=", "this", ".", "_controller", ".", "window", ".", "document", ";", "}" ]
Close the Tab View
[ "Close", "the", "Tab", "View" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/tabview.js#L120-L127
344
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/tabview.js
tabView_waitForClosed
function tabView_waitForClosed() { // Add event listener to wait until the tabview has been closed var self = { closed: false }; function checkClosed() { self.closed = true; } this._controller.window.addEventListener("tabviewhidden", checkClosed, false); try { mozmill.utils.waitFor(function() { return self.closed == true; }, TIMEOUT, 100, "TabView is still open."); } finally { this._controller.window.removeEventListener("tabviewhidden", checkClosed, false); } this._tabViewObject = null; this._groupItemsObject = null; this._tabItemsObject = null; }
javascript
function tabView_waitForClosed() { // Add event listener to wait until the tabview has been closed var self = { closed: false }; function checkClosed() { self.closed = true; } this._controller.window.addEventListener("tabviewhidden", checkClosed, false); try { mozmill.utils.waitFor(function() { return self.closed == true; }, TIMEOUT, 100, "TabView is still open."); } finally { this._controller.window.removeEventListener("tabviewhidden", checkClosed, false); } this._tabViewObject = null; this._groupItemsObject = null; this._tabItemsObject = null; }
[ "function", "tabView_waitForClosed", "(", ")", "{", "// Add event listener to wait until the tabview has been closed", "var", "self", "=", "{", "closed", ":", "false", "}", ";", "function", "checkClosed", "(", ")", "{", "self", ".", "closed", "=", "true", ";", "}", "this", ".", "_controller", ".", "window", ".", "addEventListener", "(", "\"tabviewhidden\"", ",", "checkClosed", ",", "false", ")", ";", "try", "{", "mozmill", ".", "utils", ".", "waitFor", "(", "function", "(", ")", "{", "return", "self", ".", "closed", "==", "true", ";", "}", ",", "TIMEOUT", ",", "100", ",", "\"TabView is still open.\"", ")", ";", "}", "finally", "{", "this", ".", "_controller", ".", "window", ".", "removeEventListener", "(", "\"tabviewhidden\"", ",", "checkClosed", ",", "false", ")", ";", "}", "this", ".", "_tabViewObject", "=", "null", ";", "this", ".", "_groupItemsObject", "=", "null", ";", "this", ".", "_tabItemsObject", "=", "null", ";", "}" ]
Wait until the Tab View has been closed
[ "Wait", "until", "the", "Tab", "View", "has", "been", "closed" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/tabview.js#L132-L149
345
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/tabview.js
tabView_getGroupTitleBox
function tabView_getGroupTitleBox(aSpec) { var spec = aSpec || {}; var group = spec.group; if (!group) { throw new Error(arguments.callee.name + ": Group not specified."); } return this.getElement({ type: "group_titleBox", parent: spec.group }); }
javascript
function tabView_getGroupTitleBox(aSpec) { var spec = aSpec || {}; var group = spec.group; if (!group) { throw new Error(arguments.callee.name + ": Group not specified."); } return this.getElement({ type: "group_titleBox", parent: spec.group }); }
[ "function", "tabView_getGroupTitleBox", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "group", "=", "spec", ".", "group", ";", "if", "(", "!", "group", ")", "{", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Group not specified.\"", ")", ";", "}", "return", "this", ".", "getElement", "(", "{", "type", ":", "\"group_titleBox\"", ",", "parent", ":", "spec", ".", "group", "}", ")", ";", "}" ]
Retrieve the group's title box @param {object} aSpec Information on which group to operate on Elements: group - Group element @returns Group title box @type {ElemBase}
[ "Retrieve", "the", "group", "s", "title", "box" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/tabview.js#L190-L202
346
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/tabview.js
tabView_closeGroup
function tabView_closeGroup(aSpec) { var spec = aSpec || {}; var group = spec.group; if (!group) { throw new Error(arguments.callee.name + ": Group not specified."); } var button = this.getElement({ type: "group_closeButton", value: group }); this._controller.click(button); this.waitForGroupClosed({group: group}); }
javascript
function tabView_closeGroup(aSpec) { var spec = aSpec || {}; var group = spec.group; if (!group) { throw new Error(arguments.callee.name + ": Group not specified."); } var button = this.getElement({ type: "group_closeButton", value: group }); this._controller.click(button); this.waitForGroupClosed({group: group}); }
[ "function", "tabView_closeGroup", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "group", "=", "spec", ".", "group", ";", "if", "(", "!", "group", ")", "{", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Group not specified.\"", ")", ";", "}", "var", "button", "=", "this", ".", "getElement", "(", "{", "type", ":", "\"group_closeButton\"", ",", "value", ":", "group", "}", ")", ";", "this", ".", "_controller", ".", "click", "(", "button", ")", ";", "this", ".", "waitForGroupClosed", "(", "{", "group", ":", "group", "}", ")", ";", "}" ]
Close the specified tab group @param {object} aSpec Information on which group to operate on Elements: group - Group
[ "Close", "the", "specified", "tab", "group" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/tabview.js#L211-L226
347
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/tabview.js
tabView_undoCloseGroup
function tabView_undoCloseGroup(aSpec) { var spec = aSpec || {}; var group = spec.group; if (!group) { throw new Error(arguments.callee.name + ": Group not specified."); } var undo = this.getElement({ type: "group_undoButton", value: group }); this._controller.click(undo); this.waitForGroupUndo({group: group}); }
javascript
function tabView_undoCloseGroup(aSpec) { var spec = aSpec || {}; var group = spec.group; if (!group) { throw new Error(arguments.callee.name + ": Group not specified."); } var undo = this.getElement({ type: "group_undoButton", value: group }); this._controller.click(undo); this.waitForGroupUndo({group: group}); }
[ "function", "tabView_undoCloseGroup", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "group", "=", "spec", ".", "group", ";", "if", "(", "!", "group", ")", "{", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Group not specified.\"", ")", ";", "}", "var", "undo", "=", "this", ".", "getElement", "(", "{", "type", ":", "\"group_undoButton\"", ",", "value", ":", "group", "}", ")", ";", "this", ".", "_controller", ".", "click", "(", "undo", ")", ";", "this", ".", "waitForGroupUndo", "(", "{", "group", ":", "group", "}", ")", ";", "}" ]
Undo the closing of the specified tab group @param {object} aSpec Information on which group to operate on Elements: group - Group
[ "Undo", "the", "closing", "of", "the", "specified", "tab", "group" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/tabview.js#L265-L280
348
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/tabview.js
tabView_waitForGroupUndo
function tabView_waitForGroupUndo(aSpec) { var spec = aSpec || {}; var group = spec.group; if (!group) { throw new Error(arguments.callee.name + ": Group not specified."); } var element = null; this._groupItemsObject.groupItems.forEach(function(node) { if (node.container == group.getNode()) { element = node; } }); mozmill.utils.waitFor(function() { return element && element.hidden == false; }, TIMEOUT, 100, "Tab Group has not been reopened."); // XXX: Ugly but otherwise the events on the button aren't get processed this._controller.sleep(0); }
javascript
function tabView_waitForGroupUndo(aSpec) { var spec = aSpec || {}; var group = spec.group; if (!group) { throw new Error(arguments.callee.name + ": Group not specified."); } var element = null; this._groupItemsObject.groupItems.forEach(function(node) { if (node.container == group.getNode()) { element = node; } }); mozmill.utils.waitFor(function() { return element && element.hidden == false; }, TIMEOUT, 100, "Tab Group has not been reopened."); // XXX: Ugly but otherwise the events on the button aren't get processed this._controller.sleep(0); }
[ "function", "tabView_waitForGroupUndo", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "group", "=", "spec", ".", "group", ";", "if", "(", "!", "group", ")", "{", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Group not specified.\"", ")", ";", "}", "var", "element", "=", "null", ";", "this", ".", "_groupItemsObject", ".", "groupItems", ".", "forEach", "(", "function", "(", "node", ")", "{", "if", "(", "node", ".", "container", "==", "group", ".", "getNode", "(", ")", ")", "{", "element", "=", "node", ";", "}", "}", ")", ";", "mozmill", ".", "utils", ".", "waitFor", "(", "function", "(", ")", "{", "return", "element", "&&", "element", ".", "hidden", "==", "false", ";", "}", ",", "TIMEOUT", ",", "100", ",", "\"Tab Group has not been reopened.\"", ")", ";", "// XXX: Ugly but otherwise the events on the button aren't get processed", "this", ".", "_controller", ".", "sleep", "(", "0", ")", ";", "}" ]
Wait until the specified tab group has been reopened @param {object} aSpec Information on which group to operate on Elements: group - Group
[ "Wait", "until", "the", "specified", "tab", "group", "has", "been", "reopened" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/tabview.js#L289-L310
349
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/tabview.js
tabView_closeTab
function tabView_closeTab(aSpec) { var spec = aSpec || {}; var tab = spec.tab; if (!tab) { throw new Error(arguments.callee.name + ": Tab not specified."); } var button = this.getElement({ type: "tab_closeButton", value: tab} ); this._controller.click(button); }
javascript
function tabView_closeTab(aSpec) { var spec = aSpec || {}; var tab = spec.tab; if (!tab) { throw new Error(arguments.callee.name + ": Tab not specified."); } var button = this.getElement({ type: "tab_closeButton", value: tab} ); this._controller.click(button); }
[ "function", "tabView_closeTab", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "tab", "=", "spec", ".", "tab", ";", "if", "(", "!", "tab", ")", "{", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Tab not specified.\"", ")", ";", "}", "var", "button", "=", "this", ".", "getElement", "(", "{", "type", ":", "\"tab_closeButton\"", ",", "value", ":", "tab", "}", ")", ";", "this", ".", "_controller", ".", "click", "(", "button", ")", ";", "}" ]
Close a tab @param {object} aSpec Information about the element to operate on Elements: tab - Tab to close
[ "Close", "a", "tab" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/tabview.js#L348-L361
350
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/tabview.js
tabView_getTabTitleBox
function tabView_getTabTitleBox(aSpec) { var spec = aSpec || {}; var tab = spec.tab; if (!tab) { throw new Error(arguments.callee.name + ": Tab not specified."); } return this.getElement({ type: "tab_titleBox", parent: spec.tab }); }
javascript
function tabView_getTabTitleBox(aSpec) { var spec = aSpec || {}; var tab = spec.tab; if (!tab) { throw new Error(arguments.callee.name + ": Tab not specified."); } return this.getElement({ type: "tab_titleBox", parent: spec.tab }); }
[ "function", "tabView_getTabTitleBox", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "tab", "=", "spec", ".", "tab", ";", "if", "(", "!", "tab", ")", "{", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Tab not specified.\"", ")", ";", "}", "return", "this", ".", "getElement", "(", "{", "type", ":", "\"tab_titleBox\"", ",", "parent", ":", "spec", ".", "tab", "}", ")", ";", "}" ]
Retrieve the tab's title box @param {object} aSpec Information on which tab to operate on Elements: tab - Tab @returns Tab title box @type {ElemBase}
[ "Retrieve", "the", "tab", "s", "title", "box" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/tabview.js#L373-L385
351
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/tabview.js
tabView_openTab
function tabView_openTab(aSpec) { var spec = aSpec || {}; var group = spec.group; if (!group) { throw new Error(arguments.callee.name + ": Group not specified."); } var button = this.getElement({ type: "group_newTabButton", value: group }); this._controller.click(button); this.waitForClosed(); }
javascript
function tabView_openTab(aSpec) { var spec = aSpec || {}; var group = spec.group; if (!group) { throw new Error(arguments.callee.name + ": Group not specified."); } var button = this.getElement({ type: "group_newTabButton", value: group }); this._controller.click(button); this.waitForClosed(); }
[ "function", "tabView_openTab", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "group", "=", "spec", ".", "group", ";", "if", "(", "!", "group", ")", "{", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Group not specified.\"", ")", ";", "}", "var", "button", "=", "this", ".", "getElement", "(", "{", "type", ":", "\"group_newTabButton\"", ",", "value", ":", "group", "}", ")", ";", "this", ".", "_controller", ".", "click", "(", "button", ")", ";", "this", ".", "waitForClosed", "(", ")", ";", "}" ]
Open a new tab in the specified group @param {object} aSpec Information about the element to operate on Elements: group - Group to create a new tab in
[ "Open", "a", "new", "tab", "in", "the", "specified", "group" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/tabview.js#L394-L409
352
SeleniumHQ/selenium
javascript/atoms/events.js
createNativeTouchList
function createNativeTouchList(touchListArgs) { var touches = goog.array.map(touchListArgs, function(touchArg) { return doc.createTouch(view, target, touchArg.identifier, touchArg.pageX, touchArg.pageY, touchArg.screenX, touchArg.screenY); }); return doc.createTouchList.apply(doc, touches); }
javascript
function createNativeTouchList(touchListArgs) { var touches = goog.array.map(touchListArgs, function(touchArg) { return doc.createTouch(view, target, touchArg.identifier, touchArg.pageX, touchArg.pageY, touchArg.screenX, touchArg.screenY); }); return doc.createTouchList.apply(doc, touches); }
[ "function", "createNativeTouchList", "(", "touchListArgs", ")", "{", "var", "touches", "=", "goog", ".", "array", ".", "map", "(", "touchListArgs", ",", "function", "(", "touchArg", ")", "{", "return", "doc", ".", "createTouch", "(", "view", ",", "target", ",", "touchArg", ".", "identifier", ",", "touchArg", ".", "pageX", ",", "touchArg", ".", "pageY", ",", "touchArg", ".", "screenX", ",", "touchArg", ".", "screenY", ")", ";", "}", ")", ";", "return", "doc", ".", "createTouchList", ".", "apply", "(", "doc", ",", "touches", ")", ";", "}" ]
Creates a TouchList, using native touch Api, for touch events.
[ "Creates", "a", "TouchList", "using", "native", "touch", "Api", "for", "touch", "events", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/atoms/events.js#L493-L500
353
SeleniumHQ/selenium
javascript/atoms/events.js
createGenericTouchList
function createGenericTouchList(touchListArgs) { var touches = goog.array.map(touchListArgs, function(touchArg) { // The target field is not part of the W3C spec, but both android and iOS // add the target field to each touch. return { identifier: touchArg.identifier, screenX: touchArg.screenX, screenY: touchArg.screenY, clientX: touchArg.clientX, clientY: touchArg.clientY, pageX: touchArg.pageX, pageY: touchArg.pageY, target: target }; }); touches.item = function(i) { return touches[i]; }; return touches; }
javascript
function createGenericTouchList(touchListArgs) { var touches = goog.array.map(touchListArgs, function(touchArg) { // The target field is not part of the W3C spec, but both android and iOS // add the target field to each touch. return { identifier: touchArg.identifier, screenX: touchArg.screenX, screenY: touchArg.screenY, clientX: touchArg.clientX, clientY: touchArg.clientY, pageX: touchArg.pageX, pageY: touchArg.pageY, target: target }; }); touches.item = function(i) { return touches[i]; }; return touches; }
[ "function", "createGenericTouchList", "(", "touchListArgs", ")", "{", "var", "touches", "=", "goog", ".", "array", ".", "map", "(", "touchListArgs", ",", "function", "(", "touchArg", ")", "{", "// The target field is not part of the W3C spec, but both android and iOS", "// add the target field to each touch.", "return", "{", "identifier", ":", "touchArg", ".", "identifier", ",", "screenX", ":", "touchArg", ".", "screenX", ",", "screenY", ":", "touchArg", ".", "screenY", ",", "clientX", ":", "touchArg", ".", "clientX", ",", "clientY", ":", "touchArg", ".", "clientY", ",", "pageX", ":", "touchArg", ".", "pageX", ",", "pageY", ":", "touchArg", ".", "pageY", ",", "target", ":", "target", "}", ";", "}", ")", ";", "touches", ".", "item", "=", "function", "(", "i", ")", "{", "return", "touches", "[", "i", "]", ";", "}", ";", "return", "touches", ";", "}" ]
Creates a TouchList, using simulated touch Api, for touch events.
[ "Creates", "a", "TouchList", "using", "simulated", "touch", "Api", "for", "touch", "events", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/atoms/events.js#L503-L522
354
SeleniumHQ/selenium
third_party/closure/goog/net/streams/pbjsonstreamparser.js
function() { /** * Protobuf raw bytes stream parser * @private {?JsonStreamParser} */ this.jsonStreamParser_ = null; /** * The current error message, if any. * @private {?string} */ this.errorMessage_ = null; /** * The current position in the streamed data. * @private {number} */ this.streamPos_ = 0; /** * The current parser state. * @private {!State} */ this.state_ = State.INIT; /** * The currently buffered result (parsed JSON objects). * @private {!Array<!Object>} */ this.result_ = []; /** * Whether the status has been parsed. * @private {boolean} */ this.statusParsed_ = false; }
javascript
function() { /** * Protobuf raw bytes stream parser * @private {?JsonStreamParser} */ this.jsonStreamParser_ = null; /** * The current error message, if any. * @private {?string} */ this.errorMessage_ = null; /** * The current position in the streamed data. * @private {number} */ this.streamPos_ = 0; /** * The current parser state. * @private {!State} */ this.state_ = State.INIT; /** * The currently buffered result (parsed JSON objects). * @private {!Array<!Object>} */ this.result_ = []; /** * Whether the status has been parsed. * @private {boolean} */ this.statusParsed_ = false; }
[ "function", "(", ")", "{", "/**\n * Protobuf raw bytes stream parser\n * @private {?JsonStreamParser}\n */", "this", ".", "jsonStreamParser_", "=", "null", ";", "/**\n * The current error message, if any.\n * @private {?string}\n */", "this", ".", "errorMessage_", "=", "null", ";", "/**\n * The current position in the streamed data.\n * @private {number}\n */", "this", ".", "streamPos_", "=", "0", ";", "/**\n * The current parser state.\n * @private {!State}\n */", "this", ".", "state_", "=", "State", ".", "INIT", ";", "/**\n * The currently buffered result (parsed JSON objects).\n * @private {!Array<!Object>}\n */", "this", ".", "result_", "=", "[", "]", ";", "/**\n * Whether the status has been parsed.\n * @private {boolean}\n */", "this", ".", "statusParsed_", "=", "false", ";", "}" ]
A stream parser of StreamBody message in Protobuf-JSON format. @constructor @struct @implements {StreamParser} @final
[ "A", "stream", "parser", "of", "StreamBody", "message", "in", "Protobuf", "-", "JSON", "format", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/closure/goog/net/streams/pbjsonstreamparser.js#L52-L88
355
SeleniumHQ/selenium
third_party/closure/goog/net/streams/pbjsonstreamparser.js
readMore
function readMore() { while (pos < input.length) { if (!utils.isJsonWhitespace(input[pos])) { return true; } pos++; parser.streamPos_++; } return false; }
javascript
function readMore() { while (pos < input.length) { if (!utils.isJsonWhitespace(input[pos])) { return true; } pos++; parser.streamPos_++; } return false; }
[ "function", "readMore", "(", ")", "{", "while", "(", "pos", "<", "input", ".", "length", ")", "{", "if", "(", "!", "utils", ".", "isJsonWhitespace", "(", "input", "[", "pos", "]", ")", ")", "{", "return", "true", ";", "}", "pos", "++", ";", "parser", ".", "streamPos_", "++", ";", "}", "return", "false", ";", "}" ]
Advances to the first non-whitespace input character. @return {boolean} return false if no more non-whitespace input character
[ "Advances", "to", "the", "first", "non", "-", "whitespace", "input", "character", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/closure/goog/net/streams/pbjsonstreamparser.js#L240-L249
356
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/modal-dialog.js
mdObserver
function mdObserver(aOpener, aCallback) { this._opener = aOpener; this._callback = aCallback; this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); this.exception = null; this.finished = false; }
javascript
function mdObserver(aOpener, aCallback) { this._opener = aOpener; this._callback = aCallback; this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); this.exception = null; this.finished = false; }
[ "function", "mdObserver", "(", "aOpener", ",", "aCallback", ")", "{", "this", ".", "_opener", "=", "aOpener", ";", "this", ".", "_callback", "=", "aCallback", ";", "this", ".", "_timer", "=", "Cc", "[", "\"@mozilla.org/timer;1\"", "]", ".", "createInstance", "(", "Ci", ".", "nsITimer", ")", ";", "this", ".", "exception", "=", "null", ";", "this", ".", "finished", "=", "false", ";", "}" ]
Observer object to find the modal dialog spawned by a controller @constructor @class Observer used to find a modal dialog @param {object} aOpener Window which is the opener of the modal dialog @param {function} aCallback The callback handler to use to interact with the modal dialog
[ "Observer", "object", "to", "find", "the", "modal", "dialog", "spawned", "by", "a", "controller" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/modal-dialog.js#L55-L62
357
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/modal-dialog.js
mdObserver_findWindow
function mdObserver_findWindow() { // If a window has been opened from content, it has to be unwrapped. var window = domUtils.unwrapNode(mozmill.wm.getMostRecentWindow('')); // Get the WebBrowserChrome and check if it's a modal window var chrome = window.QueryInterface(Ci.nsIInterfaceRequestor). getInterface(Ci.nsIWebNavigation). QueryInterface(Ci.nsIDocShellTreeItem). treeOwner. QueryInterface(Ci.nsIInterfaceRequestor). getInterface(Ci.nsIWebBrowserChrome); if (!chrome.isWindowModal()) { return null; } // Opening a modal dialog from a modal dialog would fail, if we wouldn't // check for the opener of the modal dialog var found = false; if (window.opener) { // XXX Bug 614757 - an already unwrapped node returns a wrapped node var opener = domUtils.unwrapNode(window.opener); found = (mozmill.utils.getChromeWindow(opener) == this._opener); } else { // Also note that it could happen that dialogs don't have an opener // (i.e. clear recent history). In such a case make sure that the most // recent window is not the passed in reference opener found = (window != this._opener); } return (found ? window : null); }
javascript
function mdObserver_findWindow() { // If a window has been opened from content, it has to be unwrapped. var window = domUtils.unwrapNode(mozmill.wm.getMostRecentWindow('')); // Get the WebBrowserChrome and check if it's a modal window var chrome = window.QueryInterface(Ci.nsIInterfaceRequestor). getInterface(Ci.nsIWebNavigation). QueryInterface(Ci.nsIDocShellTreeItem). treeOwner. QueryInterface(Ci.nsIInterfaceRequestor). getInterface(Ci.nsIWebBrowserChrome); if (!chrome.isWindowModal()) { return null; } // Opening a modal dialog from a modal dialog would fail, if we wouldn't // check for the opener of the modal dialog var found = false; if (window.opener) { // XXX Bug 614757 - an already unwrapped node returns a wrapped node var opener = domUtils.unwrapNode(window.opener); found = (mozmill.utils.getChromeWindow(opener) == this._opener); } else { // Also note that it could happen that dialogs don't have an opener // (i.e. clear recent history). In such a case make sure that the most // recent window is not the passed in reference opener found = (window != this._opener); } return (found ? window : null); }
[ "function", "mdObserver_findWindow", "(", ")", "{", "// If a window has been opened from content, it has to be unwrapped.", "var", "window", "=", "domUtils", ".", "unwrapNode", "(", "mozmill", ".", "wm", ".", "getMostRecentWindow", "(", "''", ")", ")", ";", "// Get the WebBrowserChrome and check if it's a modal window", "var", "chrome", "=", "window", ".", "QueryInterface", "(", "Ci", ".", "nsIInterfaceRequestor", ")", ".", "getInterface", "(", "Ci", ".", "nsIWebNavigation", ")", ".", "QueryInterface", "(", "Ci", ".", "nsIDocShellTreeItem", ")", ".", "treeOwner", ".", "QueryInterface", "(", "Ci", ".", "nsIInterfaceRequestor", ")", ".", "getInterface", "(", "Ci", ".", "nsIWebBrowserChrome", ")", ";", "if", "(", "!", "chrome", ".", "isWindowModal", "(", ")", ")", "{", "return", "null", ";", "}", "// Opening a modal dialog from a modal dialog would fail, if we wouldn't", "// check for the opener of the modal dialog", "var", "found", "=", "false", ";", "if", "(", "window", ".", "opener", ")", "{", "// XXX Bug 614757 - an already unwrapped node returns a wrapped node", "var", "opener", "=", "domUtils", ".", "unwrapNode", "(", "window", ".", "opener", ")", ";", "found", "=", "(", "mozmill", ".", "utils", ".", "getChromeWindow", "(", "opener", ")", "==", "this", ".", "_opener", ")", ";", "}", "else", "{", "// Also note that it could happen that dialogs don't have an opener", "// (i.e. clear recent history). In such a case make sure that the most", "// recent window is not the passed in reference opener", "found", "=", "(", "window", "!=", "this", ".", "_opener", ")", ";", "}", "return", "(", "found", "?", "window", ":", "null", ")", ";", "}" ]
Check if the modal dialog has been opened @returns {object} The modal dialog window found, or null.
[ "Check", "if", "the", "modal", "dialog", "has", "been", "opened" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/modal-dialog.js#L71-L102
358
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/modal-dialog.js
mdObserver_observe
function mdObserver_observe(aSubject, aTopic, aData) { // Once the window has been found and loaded we can execute the callback var window = this.findWindow(); if (window && ("documentLoaded" in window)) { try { this._callback(new mozmill.controller.MozMillController(window)); } catch (ex) { // Store the exception, so it can be forwarded if a modal dialog has // been opened by another modal dialog this.exception = ex; } if (window) { window.close(); } this.finished = true; this.stop(); } else { // otherwise try again in a bit this._timer.init(this, DELAY_CHECK, Ci.nsITimer.TYPE_ONE_SHOT); } }
javascript
function mdObserver_observe(aSubject, aTopic, aData) { // Once the window has been found and loaded we can execute the callback var window = this.findWindow(); if (window && ("documentLoaded" in window)) { try { this._callback(new mozmill.controller.MozMillController(window)); } catch (ex) { // Store the exception, so it can be forwarded if a modal dialog has // been opened by another modal dialog this.exception = ex; } if (window) { window.close(); } this.finished = true; this.stop(); } else { // otherwise try again in a bit this._timer.init(this, DELAY_CHECK, Ci.nsITimer.TYPE_ONE_SHOT); } }
[ "function", "mdObserver_observe", "(", "aSubject", ",", "aTopic", ",", "aData", ")", "{", "// Once the window has been found and loaded we can execute the callback", "var", "window", "=", "this", ".", "findWindow", "(", ")", ";", "if", "(", "window", "&&", "(", "\"documentLoaded\"", "in", "window", ")", ")", "{", "try", "{", "this", ".", "_callback", "(", "new", "mozmill", ".", "controller", ".", "MozMillController", "(", "window", ")", ")", ";", "}", "catch", "(", "ex", ")", "{", "// Store the exception, so it can be forwarded if a modal dialog has", "// been opened by another modal dialog", "this", ".", "exception", "=", "ex", ";", "}", "if", "(", "window", ")", "{", "window", ".", "close", "(", ")", ";", "}", "this", ".", "finished", "=", "true", ";", "this", ".", "stop", "(", ")", ";", "}", "else", "{", "// otherwise try again in a bit", "this", ".", "_timer", ".", "init", "(", "this", ",", "DELAY_CHECK", ",", "Ci", ".", "nsITimer", ".", "TYPE_ONE_SHOT", ")", ";", "}", "}" ]
Called by the timer in the given interval to check if the modal dialog has been opened. Once it has been found the callback gets executed @param {object} aSubject Not used. @param {string} aTopic Not used. @param {string} aData Not used.
[ "Called", "by", "the", "timer", "in", "the", "given", "interval", "to", "check", "if", "the", "modal", "dialog", "has", "been", "opened", ".", "Once", "it", "has", "been", "found", "the", "callback", "gets", "executed" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/modal-dialog.js#L112-L136
359
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/modal-dialog.js
modalDialog_start
function modalDialog_start(aCallback) { if (!aCallback) throw new Error(arguments.callee.name + ": Callback not specified."); this._observer = new mdObserver(this._window, aCallback); this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); this._timer.init(this._observer, DELAY_CHECK, Ci.nsITimer.TYPE_ONE_SHOT); }
javascript
function modalDialog_start(aCallback) { if (!aCallback) throw new Error(arguments.callee.name + ": Callback not specified."); this._observer = new mdObserver(this._window, aCallback); this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); this._timer.init(this._observer, DELAY_CHECK, Ci.nsITimer.TYPE_ONE_SHOT); }
[ "function", "modalDialog_start", "(", "aCallback", ")", "{", "if", "(", "!", "aCallback", ")", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Callback not specified.\"", ")", ";", "this", ".", "_observer", "=", "new", "mdObserver", "(", "this", ".", "_window", ",", "aCallback", ")", ";", "this", ".", "_timer", "=", "Cc", "[", "\"@mozilla.org/timer;1\"", "]", ".", "createInstance", "(", "Ci", ".", "nsITimer", ")", ";", "this", ".", "_timer", ".", "init", "(", "this", ".", "_observer", ",", "DELAY_CHECK", ",", "Ci", ".", "nsITimer", ".", "TYPE_ONE_SHOT", ")", ";", "}" ]
Start timer to wait for the modal dialog. @param {function} aCallback The callback handler to use to interact with the modal dialog
[ "Start", "timer", "to", "wait", "for", "the", "modal", "dialog", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/modal-dialog.js#L177-L185
360
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/modal-dialog.js
modalDialog_waitForDialog
function modalDialog_waitForDialog(aTimeout) { var timeout = aTimeout || TIMEOUT_MODAL_DIALOG; if (!this._observer) { return; } try { mozmill.utils.waitFor(function () { return this.finished; }, "Modal dialog has been found and processed", timeout, undefined, this); // Forward the raised exception so we can detect failures in modal dialogs if (this._observer.exception) { throw this._observer.exception; } } finally { this.stop(); } }
javascript
function modalDialog_waitForDialog(aTimeout) { var timeout = aTimeout || TIMEOUT_MODAL_DIALOG; if (!this._observer) { return; } try { mozmill.utils.waitFor(function () { return this.finished; }, "Modal dialog has been found and processed", timeout, undefined, this); // Forward the raised exception so we can detect failures in modal dialogs if (this._observer.exception) { throw this._observer.exception; } } finally { this.stop(); } }
[ "function", "modalDialog_waitForDialog", "(", "aTimeout", ")", "{", "var", "timeout", "=", "aTimeout", "||", "TIMEOUT_MODAL_DIALOG", ";", "if", "(", "!", "this", ".", "_observer", ")", "{", "return", ";", "}", "try", "{", "mozmill", ".", "utils", ".", "waitFor", "(", "function", "(", ")", "{", "return", "this", ".", "finished", ";", "}", ",", "\"Modal dialog has been found and processed\"", ",", "timeout", ",", "undefined", ",", "this", ")", ";", "// Forward the raised exception so we can detect failures in modal dialogs", "if", "(", "this", ".", "_observer", ".", "exception", ")", "{", "throw", "this", ".", "_observer", ".", "exception", ";", "}", "}", "finally", "{", "this", ".", "stop", "(", ")", ";", "}", "}" ]
Wait until the modal dialog has been processed. @param {Number} aTimeout (optional - default 5s) Duration to wait
[ "Wait", "until", "the", "modal", "dialog", "has", "been", "processed", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/modal-dialog.js#L205-L225
361
SeleniumHQ/selenium
javascript/selenium-core/lib/prototype.js
function(event, tagName) { var element = Event.element(event); while (element.parentNode && (!element.tagName || (element.tagName.toUpperCase() != tagName.toUpperCase()))) element = element.parentNode; return element; }
javascript
function(event, tagName) { var element = Event.element(event); while (element.parentNode && (!element.tagName || (element.tagName.toUpperCase() != tagName.toUpperCase()))) element = element.parentNode; return element; }
[ "function", "(", "event", ",", "tagName", ")", "{", "var", "element", "=", "Event", ".", "element", "(", "event", ")", ";", "while", "(", "element", ".", "parentNode", "&&", "(", "!", "element", ".", "tagName", "||", "(", "element", ".", "tagName", ".", "toUpperCase", "(", ")", "!=", "tagName", ".", "toUpperCase", "(", ")", ")", ")", ")", "element", "=", "element", ".", "parentNode", ";", "return", "element", ";", "}" ]
find the first node with the given tagName, starting from the node the event was triggered on; traverses the DOM upwards
[ "find", "the", "first", "node", "with", "the", "given", "tagName", "starting", "from", "the", "node", "the", "event", "was", "triggered", "on", ";", "traverses", "the", "DOM", "upwards" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/lib/prototype.js#L1714-L1720
362
SeleniumHQ/selenium
javascript/selenium-core/lib/prototype.js
function() { this.deltaX = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0; this.deltaY = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0; }
javascript
function() { this.deltaX = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0; this.deltaY = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0; }
[ "function", "(", ")", "{", "this", ".", "deltaX", "=", "window", ".", "pageXOffset", "||", "document", ".", "documentElement", ".", "scrollLeft", "||", "document", ".", "body", ".", "scrollLeft", "||", "0", ";", "this", ".", "deltaY", "=", "window", ".", "pageYOffset", "||", "document", ".", "documentElement", ".", "scrollTop", "||", "document", ".", "body", ".", "scrollTop", "||", "0", ";", "}" ]
must be called before calling withinIncludingScrolloffset, every time the page is scrolled
[ "must", "be", "called", "before", "calling", "withinIncludingScrolloffset", "every", "time", "the", "page", "is", "scrolled" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/lib/prototype.js#L1784-L1793
363
SeleniumHQ/selenium
javascript/selenium-core/lib/prototype.js
function(mode, element) { if (!mode) return 0; if (mode == 'vertical') return ((this.offset[1] + element.offsetHeight) - this.ycomp) / element.offsetHeight; if (mode == 'horizontal') return ((this.offset[0] + element.offsetWidth) - this.xcomp) / element.offsetWidth; }
javascript
function(mode, element) { if (!mode) return 0; if (mode == 'vertical') return ((this.offset[1] + element.offsetHeight) - this.ycomp) / element.offsetHeight; if (mode == 'horizontal') return ((this.offset[0] + element.offsetWidth) - this.xcomp) / element.offsetWidth; }
[ "function", "(", "mode", ",", "element", ")", "{", "if", "(", "!", "mode", ")", "return", "0", ";", "if", "(", "mode", "==", "'vertical'", ")", "return", "(", "(", "this", ".", "offset", "[", "1", "]", "+", "element", ".", "offsetHeight", ")", "-", "this", ".", "ycomp", ")", "/", "element", ".", "offsetHeight", ";", "if", "(", "mode", "==", "'horizontal'", ")", "return", "(", "(", "this", ".", "offset", "[", "0", "]", "+", "element", ".", "offsetWidth", ")", "-", "this", ".", "xcomp", ")", "/", "element", ".", "offsetWidth", ";", "}" ]
within must be called directly before
[ "within", "must", "be", "called", "directly", "before" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/lib/prototype.js#L1868-L1876
364
SeleniumHQ/selenium
javascript/selenium-core/scripts/ui-element.js
UIArgument
function UIArgument(uiArgumentShorthand, localVars) { /** * @param uiArgumentShorthand * * @throws UIArgumentException */ this.validate = function(uiArgumentShorthand) { var msg = "UIArgument validation error:\n" + print_r(uiArgumentShorthand); // try really hard to throw an exception! if (!uiArgumentShorthand.name) { throw new UIArgumentException(msg + 'no name specified!'); } if (!uiArgumentShorthand.description) { throw new UIArgumentException(msg + 'no description specified!'); } if (!uiArgumentShorthand.defaultValues && !uiArgumentShorthand.getDefaultValues) { throw new UIArgumentException(msg + 'no default values specified!'); } }; /** * @param uiArgumentShorthand * @param localVars a list of local variables */ this.init = function(uiArgumentShorthand, localVars) { this.validate(uiArgumentShorthand); this.name = uiArgumentShorthand.name; this.description = uiArgumentShorthand.description; this.required = uiArgumentShorthand.required || false; if (uiArgumentShorthand.defaultValues) { var defaultValues = uiArgumentShorthand.defaultValues; this.getDefaultValues = function() { return defaultValues; } } else { this.getDefaultValues = uiArgumentShorthand.getDefaultValues; } for (var name in localVars) { this[name] = localVars[name]; } } this.init(uiArgumentShorthand, localVars); }
javascript
function UIArgument(uiArgumentShorthand, localVars) { /** * @param uiArgumentShorthand * * @throws UIArgumentException */ this.validate = function(uiArgumentShorthand) { var msg = "UIArgument validation error:\n" + print_r(uiArgumentShorthand); // try really hard to throw an exception! if (!uiArgumentShorthand.name) { throw new UIArgumentException(msg + 'no name specified!'); } if (!uiArgumentShorthand.description) { throw new UIArgumentException(msg + 'no description specified!'); } if (!uiArgumentShorthand.defaultValues && !uiArgumentShorthand.getDefaultValues) { throw new UIArgumentException(msg + 'no default values specified!'); } }; /** * @param uiArgumentShorthand * @param localVars a list of local variables */ this.init = function(uiArgumentShorthand, localVars) { this.validate(uiArgumentShorthand); this.name = uiArgumentShorthand.name; this.description = uiArgumentShorthand.description; this.required = uiArgumentShorthand.required || false; if (uiArgumentShorthand.defaultValues) { var defaultValues = uiArgumentShorthand.defaultValues; this.getDefaultValues = function() { return defaultValues; } } else { this.getDefaultValues = uiArgumentShorthand.getDefaultValues; } for (var name in localVars) { this[name] = localVars[name]; } } this.init(uiArgumentShorthand, localVars); }
[ "function", "UIArgument", "(", "uiArgumentShorthand", ",", "localVars", ")", "{", "/**\n * @param uiArgumentShorthand\n *\n * @throws UIArgumentException\n */", "this", ".", "validate", "=", "function", "(", "uiArgumentShorthand", ")", "{", "var", "msg", "=", "\"UIArgument validation error:\\n\"", "+", "print_r", "(", "uiArgumentShorthand", ")", ";", "// try really hard to throw an exception!", "if", "(", "!", "uiArgumentShorthand", ".", "name", ")", "{", "throw", "new", "UIArgumentException", "(", "msg", "+", "'no name specified!'", ")", ";", "}", "if", "(", "!", "uiArgumentShorthand", ".", "description", ")", "{", "throw", "new", "UIArgumentException", "(", "msg", "+", "'no description specified!'", ")", ";", "}", "if", "(", "!", "uiArgumentShorthand", ".", "defaultValues", "&&", "!", "uiArgumentShorthand", ".", "getDefaultValues", ")", "{", "throw", "new", "UIArgumentException", "(", "msg", "+", "'no default values specified!'", ")", ";", "}", "}", ";", "/**\n * @param uiArgumentShorthand\n * @param localVars a list of local variables\n */", "this", ".", "init", "=", "function", "(", "uiArgumentShorthand", ",", "localVars", ")", "{", "this", ".", "validate", "(", "uiArgumentShorthand", ")", ";", "this", ".", "name", "=", "uiArgumentShorthand", ".", "name", ";", "this", ".", "description", "=", "uiArgumentShorthand", ".", "description", ";", "this", ".", "required", "=", "uiArgumentShorthand", ".", "required", "||", "false", ";", "if", "(", "uiArgumentShorthand", ".", "defaultValues", ")", "{", "var", "defaultValues", "=", "uiArgumentShorthand", ".", "defaultValues", ";", "this", ".", "getDefaultValues", "=", "function", "(", ")", "{", "return", "defaultValues", ";", "}", "}", "else", "{", "this", ".", "getDefaultValues", "=", "uiArgumentShorthand", ".", "getDefaultValues", ";", "}", "for", "(", "var", "name", "in", "localVars", ")", "{", "this", "[", "name", "]", "=", "localVars", "[", "name", "]", ";", "}", "}", "this", ".", "init", "(", "uiArgumentShorthand", ",", "localVars", ")", ";", "}" ]
Constructs a UIArgument. This is mostly for checking that the values are valid. @param uiArgumentShorthand @param localVars @throws UIArgumentException
[ "Constructs", "a", "UIArgument", ".", "This", "is", "mostly", "for", "checking", "that", "the", "values", "are", "valid", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/ui-element.js#L530-L586
365
SeleniumHQ/selenium
javascript/selenium-core/scripts/ui-element.js
UISpecifier
function UISpecifier(uiSpecifierStringOrPagesetName, elementName, args) { /** * Initializes this object from a UI specifier string of the form: * * pagesetName::elementName(arg1=value1, arg2=value2, ...) * * into its component parts, and returns them as an object. * * @return an object containing the components of the UI specifier * @throws UISpecifierException */ this._initFromUISpecifierString = function(uiSpecifierString) { var matches = /^(.*)::([^\(]+)\((.*)\)$/.exec(uiSpecifierString); if (matches == null) { throw new UISpecifierException('Error in ' + 'UISpecifier._initFromUISpecifierString(): "' + this.string + '" is not a valid UI specifier string'); } this.pagesetName = matches[1]; this.elementName = matches[2]; this.args = (matches[3]) ? parse_kwargs(matches[3]) : {}; }; /** * Override the toString() method to return the UI specifier string when * evaluated in a string context. Combines the UI specifier components into * a canonical UI specifier string and returns it. * * @return a UI specifier string */ this.toString = function() { // empty string is acceptable for the path, but it must be defined if (this.pagesetName == undefined) { throw new UISpecifierException('Error in UISpecifier.toString(): "' + this.pagesetName + '" is not a valid UI specifier pageset ' + 'name'); } if (!this.elementName) { throw new UISpecifierException('Error in UISpecifier.unparse(): "' + this.elementName + '" is not a valid UI specifier element ' + 'name'); } if (!this.args) { throw new UISpecifierException('Error in UISpecifier.unparse(): "' + this.args + '" are not valid UI specifier args'); } uiElement = UIMap.getInstance() .getUIElement(this.pagesetName, this.elementName); if (uiElement != null) { var kwargs = to_kwargs(this.args, uiElement.argsOrder); } else { // probably under unit test var kwargs = to_kwargs(this.args); } return this.pagesetName + '::' + this.elementName + '(' + kwargs + ')'; }; // construct the object if (arguments.length < 2) { this._initFromUISpecifierString(uiSpecifierStringOrPagesetName); } else { this.pagesetName = uiSpecifierStringOrPagesetName; this.elementName = elementName; this.args = (args) ? clone(args) : {}; } }
javascript
function UISpecifier(uiSpecifierStringOrPagesetName, elementName, args) { /** * Initializes this object from a UI specifier string of the form: * * pagesetName::elementName(arg1=value1, arg2=value2, ...) * * into its component parts, and returns them as an object. * * @return an object containing the components of the UI specifier * @throws UISpecifierException */ this._initFromUISpecifierString = function(uiSpecifierString) { var matches = /^(.*)::([^\(]+)\((.*)\)$/.exec(uiSpecifierString); if (matches == null) { throw new UISpecifierException('Error in ' + 'UISpecifier._initFromUISpecifierString(): "' + this.string + '" is not a valid UI specifier string'); } this.pagesetName = matches[1]; this.elementName = matches[2]; this.args = (matches[3]) ? parse_kwargs(matches[3]) : {}; }; /** * Override the toString() method to return the UI specifier string when * evaluated in a string context. Combines the UI specifier components into * a canonical UI specifier string and returns it. * * @return a UI specifier string */ this.toString = function() { // empty string is acceptable for the path, but it must be defined if (this.pagesetName == undefined) { throw new UISpecifierException('Error in UISpecifier.toString(): "' + this.pagesetName + '" is not a valid UI specifier pageset ' + 'name'); } if (!this.elementName) { throw new UISpecifierException('Error in UISpecifier.unparse(): "' + this.elementName + '" is not a valid UI specifier element ' + 'name'); } if (!this.args) { throw new UISpecifierException('Error in UISpecifier.unparse(): "' + this.args + '" are not valid UI specifier args'); } uiElement = UIMap.getInstance() .getUIElement(this.pagesetName, this.elementName); if (uiElement != null) { var kwargs = to_kwargs(this.args, uiElement.argsOrder); } else { // probably under unit test var kwargs = to_kwargs(this.args); } return this.pagesetName + '::' + this.elementName + '(' + kwargs + ')'; }; // construct the object if (arguments.length < 2) { this._initFromUISpecifierString(uiSpecifierStringOrPagesetName); } else { this.pagesetName = uiSpecifierStringOrPagesetName; this.elementName = elementName; this.args = (args) ? clone(args) : {}; } }
[ "function", "UISpecifier", "(", "uiSpecifierStringOrPagesetName", ",", "elementName", ",", "args", ")", "{", "/**\n * Initializes this object from a UI specifier string of the form:\n *\n * pagesetName::elementName(arg1=value1, arg2=value2, ...)\n *\n * into its component parts, and returns them as an object.\n *\n * @return an object containing the components of the UI specifier\n * @throws UISpecifierException\n */", "this", ".", "_initFromUISpecifierString", "=", "function", "(", "uiSpecifierString", ")", "{", "var", "matches", "=", "/", "^(.*)::([^\\(]+)\\((.*)\\)$", "/", ".", "exec", "(", "uiSpecifierString", ")", ";", "if", "(", "matches", "==", "null", ")", "{", "throw", "new", "UISpecifierException", "(", "'Error in '", "+", "'UISpecifier._initFromUISpecifierString(): \"'", "+", "this", ".", "string", "+", "'\" is not a valid UI specifier string'", ")", ";", "}", "this", ".", "pagesetName", "=", "matches", "[", "1", "]", ";", "this", ".", "elementName", "=", "matches", "[", "2", "]", ";", "this", ".", "args", "=", "(", "matches", "[", "3", "]", ")", "?", "parse_kwargs", "(", "matches", "[", "3", "]", ")", ":", "{", "}", ";", "}", ";", "/**\n * Override the toString() method to return the UI specifier string when\n * evaluated in a string context. Combines the UI specifier components into\n * a canonical UI specifier string and returns it.\n *\n * @return a UI specifier string\n */", "this", ".", "toString", "=", "function", "(", ")", "{", "// empty string is acceptable for the path, but it must be defined", "if", "(", "this", ".", "pagesetName", "==", "undefined", ")", "{", "throw", "new", "UISpecifierException", "(", "'Error in UISpecifier.toString(): \"'", "+", "this", ".", "pagesetName", "+", "'\" is not a valid UI specifier pageset '", "+", "'name'", ")", ";", "}", "if", "(", "!", "this", ".", "elementName", ")", "{", "throw", "new", "UISpecifierException", "(", "'Error in UISpecifier.unparse(): \"'", "+", "this", ".", "elementName", "+", "'\" is not a valid UI specifier element '", "+", "'name'", ")", ";", "}", "if", "(", "!", "this", ".", "args", ")", "{", "throw", "new", "UISpecifierException", "(", "'Error in UISpecifier.unparse(): \"'", "+", "this", ".", "args", "+", "'\" are not valid UI specifier args'", ")", ";", "}", "uiElement", "=", "UIMap", ".", "getInstance", "(", ")", ".", "getUIElement", "(", "this", ".", "pagesetName", ",", "this", ".", "elementName", ")", ";", "if", "(", "uiElement", "!=", "null", ")", "{", "var", "kwargs", "=", "to_kwargs", "(", "this", ".", "args", ",", "uiElement", ".", "argsOrder", ")", ";", "}", "else", "{", "// probably under unit test", "var", "kwargs", "=", "to_kwargs", "(", "this", ".", "args", ")", ";", "}", "return", "this", ".", "pagesetName", "+", "'::'", "+", "this", ".", "elementName", "+", "'('", "+", "kwargs", "+", "')'", ";", "}", ";", "// construct the object", "if", "(", "arguments", ".", "length", "<", "2", ")", "{", "this", ".", "_initFromUISpecifierString", "(", "uiSpecifierStringOrPagesetName", ")", ";", "}", "else", "{", "this", ".", "pagesetName", "=", "uiSpecifierStringOrPagesetName", ";", "this", ".", "elementName", "=", "elementName", ";", "this", ".", "args", "=", "(", "args", ")", "?", "clone", "(", "args", ")", ":", "{", "}", ";", "}", "}" ]
The UISpecifier constructor is overloaded. If less than three arguments are provided, the first argument will be considered a UI specifier string, and will be split out accordingly. Otherwise, the first argument will be considered the path. @param uiSpecifierStringOrPagesetName a UI specifier string, or the pageset name of the UI specifier @param elementName the name of the element @param args an object associating keys to values @return new UISpecifier object
[ "The", "UISpecifier", "constructor", "is", "overloaded", ".", "If", "less", "than", "three", "arguments", "are", "provided", "the", "first", "argument", "will", "be", "considered", "a", "UI", "specifier", "string", "and", "will", "be", "split", "out", "accordingly", ".", "Otherwise", "the", "first", "argument", "will", "be", "considered", "the", "path", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/ui-element.js#L603-L675
366
SeleniumHQ/selenium
javascript/selenium-core/scripts/ui-element.js
UIMap
function UIMap() { // the singleton pattern, split into two parts so that "new" can still // be used, in addition to "getInstance()" UIMap.self = this; // need to attach variables directly to the Editor object in order for them // to be in scope for Editor methods if (is_IDE()) { Editor.uiMap = this; Editor.UI_PREFIX = UI_GLOBAL.UI_PREFIX; } this.pagesets = new Object(); /** * pageset[pagesetName] * regexp * elements[elementName] * UIElement */ this.addPageset = function(pagesetShorthand) { try { var pageset = new Pageset(pagesetShorthand); } catch (e) { safe_alert("Could not create pageset from shorthand:\n" + print_r(pagesetShorthand) + "\n" + e.message); return false; } if (this.pagesets[pageset.name]) { safe_alert('Could not add pageset "' + pageset.name + '": a pageset with that name already exists!'); return false; } this.pagesets[pageset.name] = pageset; return true; }; /** * @param pagesetName * @param uiElementShorthand a representation of a UIElement object in * shorthand JSON. */ this.addElement = function(pagesetName, uiElementShorthand) { try { var uiElement = new UIElement(uiElementShorthand); } catch (e) { safe_alert("Could not create UI element from shorthand:\n" + print_r(uiElementShorthand) + "\n" + e.message); return false; } // run the element's unit tests only for the IDE, and only when the // IDE is starting. Make a rough guess as to the latter condition. if (is_IDE() && !editor.selDebugger && !uiElement.test()) { safe_alert('Could not add UI element "' + uiElement.name + '": failed testcases!'); return false; } try { this.pagesets[pagesetName].uiElements[uiElement.name] = uiElement; } catch (e) { safe_alert("Could not add UI element '" + uiElement.name + "' to pageset '" + pagesetName + "':\n" + e.message); return false; } return true; }; /** * Returns the pageset for a given UI specifier string. * * @param uiSpecifierString * @return a pageset object */ this.getPageset = function(uiSpecifierString) { try { var uiSpecifier = new UISpecifier(uiSpecifierString); return this.pagesets[uiSpecifier.pagesetName]; } catch (e) { return null; } } /** * Returns the UIElement that a UISpecifierString or pageset and element * pair refer to. * * @param pagesetNameOrUISpecifierString * @return a UIElement, or null if none is found associated with * uiSpecifierString */ this.getUIElement = function(pagesetNameOrUISpecifierString, uiElementName) { var pagesetName = pagesetNameOrUISpecifierString; if (arguments.length == 1) { var uiSpecifierString = pagesetNameOrUISpecifierString; try { var uiSpecifier = new UISpecifier(uiSpecifierString); pagesetName = uiSpecifier.pagesetName; var uiElementName = uiSpecifier.elementName; } catch (e) { return null; } } try { return this.pagesets[pagesetName].uiElements[uiElementName]; } catch (e) { return null; } }; /** * Returns a list of pagesets that "contains" the provided page, * represented as a document object. Containership is defined by the * Pageset object's contain() method. * * @param inDocument the page to get pagesets for * @return a list of pagesets */ this.getPagesetsForPage = function(inDocument) { var pagesets = []; for (var pagesetName in this.pagesets) { var pageset = this.pagesets[pagesetName]; if (pageset.contains(inDocument)) { pagesets.push(pageset); } } return pagesets; }; /** * Returns a list of all pagesets. * * @return a list of pagesets */ this.getPagesets = function() { var pagesets = []; for (var pagesetName in this.pagesets) { pagesets.push(this.pagesets[pagesetName]); } return pagesets; }; /** * Returns a list of elements on a page that a given UI specifier string, * maps to. If no elements are mapped to, returns an empty list.. * * @param uiSpecifierString a String that specifies a UI element with * attendant argument values * @param inDocument the document object the specified UI element * appears in * @return a potentially-empty list of elements * specified by uiSpecifierString */ this.getPageElements = function(uiSpecifierString, inDocument) { var locator = this.getLocator(uiSpecifierString); var results = locator ? eval_locator(locator, inDocument) : []; return results; }; /** * Returns the locator string that a given UI specifier string maps to, or * null if it cannot be mapped. * * @param uiSpecifierString */ this.getLocator = function(uiSpecifierString) { try { var uiSpecifier = new UISpecifier(uiSpecifierString); } catch (e) { safe_alert('Could not create UISpecifier for string "' + uiSpecifierString + '": ' + e.message); return null; } var uiElement = this.getUIElement(uiSpecifier.pagesetName, uiSpecifier.elementName); try { return uiElement.getLocator(uiSpecifier.args); } catch (e) { return null; } } /** * Finds and returns a UI specifier string given an element and the page * that it appears on. * * @param pageElement the document element to map to a UI specifier * @param inDocument the document the element appears in * @return a UI specifier string, or false if one cannot be * constructed */ this.getUISpecifierString = function(pageElement, inDocument) { var is_fuzzy_match = BrowserBot.prototype.locateElementByUIElement.is_fuzzy_match; var pagesets = this.getPagesetsForPage(inDocument); for (var i = 0; i < pagesets.length; ++i) { var pageset = pagesets[i]; var uiElements = pageset.getUIElements(); for (var j = 0; j < uiElements.length; ++j) { var uiElement = uiElements[j]; // first test against the generic locator, if there is one. // This should net some performance benefit when recording on // more complicated pages. if (uiElement.getGenericLocator) { var passedTest = false; var results = eval_locator(uiElement.getGenericLocator(), inDocument); for (var i = 0; i < results.length; ++i) { if (results[i] == pageElement) { passedTest = true; break; } } if (!passedTest) { continue; } } var defaultLocators; if (uiElement.isDefaultLocatorConstructionDeferred) { defaultLocators = uiElement.getDefaultLocators(inDocument); } else { defaultLocators = uiElement.defaultLocators; } //safe_alert(print_r(uiElement.defaultLocators)); for (var locator in defaultLocators) { var locatedElements = eval_locator(locator, inDocument); if (locatedElements.length) { var locatedElement = locatedElements[0]; } else { continue; } // use a heuristic to determine whether the element // specified is the "same" as the element we're matching if (is_fuzzy_match) { if (is_fuzzy_match(locatedElement, pageElement)) { return UI_GLOBAL.UI_PREFIX + '=' + new UISpecifier(pageset.name, uiElement.name, defaultLocators[locator]); } } else { if (locatedElement == pageElement) { return UI_GLOBAL.UI_PREFIX + '=' + new UISpecifier(pageset.name, uiElement.name, defaultLocators[locator]); } } // ok, matching the element failed. See if an offset // locator can complete the match. if (uiElement.getOffsetLocator) { for (var k = 0; k < locatedElements.length; ++k) { var offsetLocator = uiElement .getOffsetLocator(locatedElements[k], pageElement); if (offsetLocator) { return UI_GLOBAL.UI_PREFIX + '=' + new UISpecifier(pageset.name, uiElement.name, defaultLocators[locator]) + '->' + offsetLocator; } } } } } } return false; }; /** * Returns a sorted list of UI specifier string stubs representing possible * UI elements for all pagesets, paired the their descriptions. Stubs * contain all required arguments, but leave argument values blank. * * @return a list of UI specifier string stubs */ this.getUISpecifierStringStubs = function() { var stubs = []; var pagesets = this.getPagesets(); for (var i = 0; i < pagesets.length; ++i) { stubs = stubs.concat(pagesets[i].getUISpecifierStringStubs()); } stubs.sort(function(a, b) { if (a[0] < b[0]) { return -1; } return a[0] == b[0] ? 0 : 1; }); return stubs; } }
javascript
function UIMap() { // the singleton pattern, split into two parts so that "new" can still // be used, in addition to "getInstance()" UIMap.self = this; // need to attach variables directly to the Editor object in order for them // to be in scope for Editor methods if (is_IDE()) { Editor.uiMap = this; Editor.UI_PREFIX = UI_GLOBAL.UI_PREFIX; } this.pagesets = new Object(); /** * pageset[pagesetName] * regexp * elements[elementName] * UIElement */ this.addPageset = function(pagesetShorthand) { try { var pageset = new Pageset(pagesetShorthand); } catch (e) { safe_alert("Could not create pageset from shorthand:\n" + print_r(pagesetShorthand) + "\n" + e.message); return false; } if (this.pagesets[pageset.name]) { safe_alert('Could not add pageset "' + pageset.name + '": a pageset with that name already exists!'); return false; } this.pagesets[pageset.name] = pageset; return true; }; /** * @param pagesetName * @param uiElementShorthand a representation of a UIElement object in * shorthand JSON. */ this.addElement = function(pagesetName, uiElementShorthand) { try { var uiElement = new UIElement(uiElementShorthand); } catch (e) { safe_alert("Could not create UI element from shorthand:\n" + print_r(uiElementShorthand) + "\n" + e.message); return false; } // run the element's unit tests only for the IDE, and only when the // IDE is starting. Make a rough guess as to the latter condition. if (is_IDE() && !editor.selDebugger && !uiElement.test()) { safe_alert('Could not add UI element "' + uiElement.name + '": failed testcases!'); return false; } try { this.pagesets[pagesetName].uiElements[uiElement.name] = uiElement; } catch (e) { safe_alert("Could not add UI element '" + uiElement.name + "' to pageset '" + pagesetName + "':\n" + e.message); return false; } return true; }; /** * Returns the pageset for a given UI specifier string. * * @param uiSpecifierString * @return a pageset object */ this.getPageset = function(uiSpecifierString) { try { var uiSpecifier = new UISpecifier(uiSpecifierString); return this.pagesets[uiSpecifier.pagesetName]; } catch (e) { return null; } } /** * Returns the UIElement that a UISpecifierString or pageset and element * pair refer to. * * @param pagesetNameOrUISpecifierString * @return a UIElement, or null if none is found associated with * uiSpecifierString */ this.getUIElement = function(pagesetNameOrUISpecifierString, uiElementName) { var pagesetName = pagesetNameOrUISpecifierString; if (arguments.length == 1) { var uiSpecifierString = pagesetNameOrUISpecifierString; try { var uiSpecifier = new UISpecifier(uiSpecifierString); pagesetName = uiSpecifier.pagesetName; var uiElementName = uiSpecifier.elementName; } catch (e) { return null; } } try { return this.pagesets[pagesetName].uiElements[uiElementName]; } catch (e) { return null; } }; /** * Returns a list of pagesets that "contains" the provided page, * represented as a document object. Containership is defined by the * Pageset object's contain() method. * * @param inDocument the page to get pagesets for * @return a list of pagesets */ this.getPagesetsForPage = function(inDocument) { var pagesets = []; for (var pagesetName in this.pagesets) { var pageset = this.pagesets[pagesetName]; if (pageset.contains(inDocument)) { pagesets.push(pageset); } } return pagesets; }; /** * Returns a list of all pagesets. * * @return a list of pagesets */ this.getPagesets = function() { var pagesets = []; for (var pagesetName in this.pagesets) { pagesets.push(this.pagesets[pagesetName]); } return pagesets; }; /** * Returns a list of elements on a page that a given UI specifier string, * maps to. If no elements are mapped to, returns an empty list.. * * @param uiSpecifierString a String that specifies a UI element with * attendant argument values * @param inDocument the document object the specified UI element * appears in * @return a potentially-empty list of elements * specified by uiSpecifierString */ this.getPageElements = function(uiSpecifierString, inDocument) { var locator = this.getLocator(uiSpecifierString); var results = locator ? eval_locator(locator, inDocument) : []; return results; }; /** * Returns the locator string that a given UI specifier string maps to, or * null if it cannot be mapped. * * @param uiSpecifierString */ this.getLocator = function(uiSpecifierString) { try { var uiSpecifier = new UISpecifier(uiSpecifierString); } catch (e) { safe_alert('Could not create UISpecifier for string "' + uiSpecifierString + '": ' + e.message); return null; } var uiElement = this.getUIElement(uiSpecifier.pagesetName, uiSpecifier.elementName); try { return uiElement.getLocator(uiSpecifier.args); } catch (e) { return null; } } /** * Finds and returns a UI specifier string given an element and the page * that it appears on. * * @param pageElement the document element to map to a UI specifier * @param inDocument the document the element appears in * @return a UI specifier string, or false if one cannot be * constructed */ this.getUISpecifierString = function(pageElement, inDocument) { var is_fuzzy_match = BrowserBot.prototype.locateElementByUIElement.is_fuzzy_match; var pagesets = this.getPagesetsForPage(inDocument); for (var i = 0; i < pagesets.length; ++i) { var pageset = pagesets[i]; var uiElements = pageset.getUIElements(); for (var j = 0; j < uiElements.length; ++j) { var uiElement = uiElements[j]; // first test against the generic locator, if there is one. // This should net some performance benefit when recording on // more complicated pages. if (uiElement.getGenericLocator) { var passedTest = false; var results = eval_locator(uiElement.getGenericLocator(), inDocument); for (var i = 0; i < results.length; ++i) { if (results[i] == pageElement) { passedTest = true; break; } } if (!passedTest) { continue; } } var defaultLocators; if (uiElement.isDefaultLocatorConstructionDeferred) { defaultLocators = uiElement.getDefaultLocators(inDocument); } else { defaultLocators = uiElement.defaultLocators; } //safe_alert(print_r(uiElement.defaultLocators)); for (var locator in defaultLocators) { var locatedElements = eval_locator(locator, inDocument); if (locatedElements.length) { var locatedElement = locatedElements[0]; } else { continue; } // use a heuristic to determine whether the element // specified is the "same" as the element we're matching if (is_fuzzy_match) { if (is_fuzzy_match(locatedElement, pageElement)) { return UI_GLOBAL.UI_PREFIX + '=' + new UISpecifier(pageset.name, uiElement.name, defaultLocators[locator]); } } else { if (locatedElement == pageElement) { return UI_GLOBAL.UI_PREFIX + '=' + new UISpecifier(pageset.name, uiElement.name, defaultLocators[locator]); } } // ok, matching the element failed. See if an offset // locator can complete the match. if (uiElement.getOffsetLocator) { for (var k = 0; k < locatedElements.length; ++k) { var offsetLocator = uiElement .getOffsetLocator(locatedElements[k], pageElement); if (offsetLocator) { return UI_GLOBAL.UI_PREFIX + '=' + new UISpecifier(pageset.name, uiElement.name, defaultLocators[locator]) + '->' + offsetLocator; } } } } } } return false; }; /** * Returns a sorted list of UI specifier string stubs representing possible * UI elements for all pagesets, paired the their descriptions. Stubs * contain all required arguments, but leave argument values blank. * * @return a list of UI specifier string stubs */ this.getUISpecifierStringStubs = function() { var stubs = []; var pagesets = this.getPagesets(); for (var i = 0; i < pagesets.length; ++i) { stubs = stubs.concat(pagesets[i].getUISpecifierStringStubs()); } stubs.sort(function(a, b) { if (a[0] < b[0]) { return -1; } return a[0] == b[0] ? 0 : 1; }); return stubs; } }
[ "function", "UIMap", "(", ")", "{", "// the singleton pattern, split into two parts so that \"new\" can still", "// be used, in addition to \"getInstance()\"", "UIMap", ".", "self", "=", "this", ";", "// need to attach variables directly to the Editor object in order for them", "// to be in scope for Editor methods", "if", "(", "is_IDE", "(", ")", ")", "{", "Editor", ".", "uiMap", "=", "this", ";", "Editor", ".", "UI_PREFIX", "=", "UI_GLOBAL", ".", "UI_PREFIX", ";", "}", "this", ".", "pagesets", "=", "new", "Object", "(", ")", ";", "/**\n * pageset[pagesetName]\n * regexp\n * elements[elementName]\n * UIElement\n */", "this", ".", "addPageset", "=", "function", "(", "pagesetShorthand", ")", "{", "try", "{", "var", "pageset", "=", "new", "Pageset", "(", "pagesetShorthand", ")", ";", "}", "catch", "(", "e", ")", "{", "safe_alert", "(", "\"Could not create pageset from shorthand:\\n\"", "+", "print_r", "(", "pagesetShorthand", ")", "+", "\"\\n\"", "+", "e", ".", "message", ")", ";", "return", "false", ";", "}", "if", "(", "this", ".", "pagesets", "[", "pageset", ".", "name", "]", ")", "{", "safe_alert", "(", "'Could not add pageset \"'", "+", "pageset", ".", "name", "+", "'\": a pageset with that name already exists!'", ")", ";", "return", "false", ";", "}", "this", ".", "pagesets", "[", "pageset", ".", "name", "]", "=", "pageset", ";", "return", "true", ";", "}", ";", "/**\n * @param pagesetName\n * @param uiElementShorthand a representation of a UIElement object in\n * shorthand JSON.\n */", "this", ".", "addElement", "=", "function", "(", "pagesetName", ",", "uiElementShorthand", ")", "{", "try", "{", "var", "uiElement", "=", "new", "UIElement", "(", "uiElementShorthand", ")", ";", "}", "catch", "(", "e", ")", "{", "safe_alert", "(", "\"Could not create UI element from shorthand:\\n\"", "+", "print_r", "(", "uiElementShorthand", ")", "+", "\"\\n\"", "+", "e", ".", "message", ")", ";", "return", "false", ";", "}", "// run the element's unit tests only for the IDE, and only when the", "// IDE is starting. Make a rough guess as to the latter condition.", "if", "(", "is_IDE", "(", ")", "&&", "!", "editor", ".", "selDebugger", "&&", "!", "uiElement", ".", "test", "(", ")", ")", "{", "safe_alert", "(", "'Could not add UI element \"'", "+", "uiElement", ".", "name", "+", "'\": failed testcases!'", ")", ";", "return", "false", ";", "}", "try", "{", "this", ".", "pagesets", "[", "pagesetName", "]", ".", "uiElements", "[", "uiElement", ".", "name", "]", "=", "uiElement", ";", "}", "catch", "(", "e", ")", "{", "safe_alert", "(", "\"Could not add UI element '\"", "+", "uiElement", ".", "name", "+", "\"' to pageset '\"", "+", "pagesetName", "+", "\"':\\n\"", "+", "e", ".", "message", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}", ";", "/**\n * Returns the pageset for a given UI specifier string.\n *\n * @param uiSpecifierString\n * @return a pageset object\n */", "this", ".", "getPageset", "=", "function", "(", "uiSpecifierString", ")", "{", "try", "{", "var", "uiSpecifier", "=", "new", "UISpecifier", "(", "uiSpecifierString", ")", ";", "return", "this", ".", "pagesets", "[", "uiSpecifier", ".", "pagesetName", "]", ";", "}", "catch", "(", "e", ")", "{", "return", "null", ";", "}", "}", "/**\n * Returns the UIElement that a UISpecifierString or pageset and element\n * pair refer to.\n *\n * @param pagesetNameOrUISpecifierString\n * @return a UIElement, or null if none is found associated with\n * uiSpecifierString\n */", "this", ".", "getUIElement", "=", "function", "(", "pagesetNameOrUISpecifierString", ",", "uiElementName", ")", "{", "var", "pagesetName", "=", "pagesetNameOrUISpecifierString", ";", "if", "(", "arguments", ".", "length", "==", "1", ")", "{", "var", "uiSpecifierString", "=", "pagesetNameOrUISpecifierString", ";", "try", "{", "var", "uiSpecifier", "=", "new", "UISpecifier", "(", "uiSpecifierString", ")", ";", "pagesetName", "=", "uiSpecifier", ".", "pagesetName", ";", "var", "uiElementName", "=", "uiSpecifier", ".", "elementName", ";", "}", "catch", "(", "e", ")", "{", "return", "null", ";", "}", "}", "try", "{", "return", "this", ".", "pagesets", "[", "pagesetName", "]", ".", "uiElements", "[", "uiElementName", "]", ";", "}", "catch", "(", "e", ")", "{", "return", "null", ";", "}", "}", ";", "/**\n * Returns a list of pagesets that \"contains\" the provided page,\n * represented as a document object. Containership is defined by the\n * Pageset object's contain() method.\n *\n * @param inDocument the page to get pagesets for\n * @return a list of pagesets\n */", "this", ".", "getPagesetsForPage", "=", "function", "(", "inDocument", ")", "{", "var", "pagesets", "=", "[", "]", ";", "for", "(", "var", "pagesetName", "in", "this", ".", "pagesets", ")", "{", "var", "pageset", "=", "this", ".", "pagesets", "[", "pagesetName", "]", ";", "if", "(", "pageset", ".", "contains", "(", "inDocument", ")", ")", "{", "pagesets", ".", "push", "(", "pageset", ")", ";", "}", "}", "return", "pagesets", ";", "}", ";", "/**\n * Returns a list of all pagesets.\n *\n * @return a list of pagesets\n */", "this", ".", "getPagesets", "=", "function", "(", ")", "{", "var", "pagesets", "=", "[", "]", ";", "for", "(", "var", "pagesetName", "in", "this", ".", "pagesets", ")", "{", "pagesets", ".", "push", "(", "this", ".", "pagesets", "[", "pagesetName", "]", ")", ";", "}", "return", "pagesets", ";", "}", ";", "/**\n * Returns a list of elements on a page that a given UI specifier string,\n * maps to. If no elements are mapped to, returns an empty list..\n *\n * @param uiSpecifierString a String that specifies a UI element with\n * attendant argument values\n * @param inDocument the document object the specified UI element\n * appears in\n * @return a potentially-empty list of elements\n * specified by uiSpecifierString\n */", "this", ".", "getPageElements", "=", "function", "(", "uiSpecifierString", ",", "inDocument", ")", "{", "var", "locator", "=", "this", ".", "getLocator", "(", "uiSpecifierString", ")", ";", "var", "results", "=", "locator", "?", "eval_locator", "(", "locator", ",", "inDocument", ")", ":", "[", "]", ";", "return", "results", ";", "}", ";", "/**\n * Returns the locator string that a given UI specifier string maps to, or\n * null if it cannot be mapped.\n *\n * @param uiSpecifierString\n */", "this", ".", "getLocator", "=", "function", "(", "uiSpecifierString", ")", "{", "try", "{", "var", "uiSpecifier", "=", "new", "UISpecifier", "(", "uiSpecifierString", ")", ";", "}", "catch", "(", "e", ")", "{", "safe_alert", "(", "'Could not create UISpecifier for string \"'", "+", "uiSpecifierString", "+", "'\": '", "+", "e", ".", "message", ")", ";", "return", "null", ";", "}", "var", "uiElement", "=", "this", ".", "getUIElement", "(", "uiSpecifier", ".", "pagesetName", ",", "uiSpecifier", ".", "elementName", ")", ";", "try", "{", "return", "uiElement", ".", "getLocator", "(", "uiSpecifier", ".", "args", ")", ";", "}", "catch", "(", "e", ")", "{", "return", "null", ";", "}", "}", "/**\n * Finds and returns a UI specifier string given an element and the page\n * that it appears on.\n *\n * @param pageElement the document element to map to a UI specifier\n * @param inDocument the document the element appears in\n * @return a UI specifier string, or false if one cannot be\n * constructed\n */", "this", ".", "getUISpecifierString", "=", "function", "(", "pageElement", ",", "inDocument", ")", "{", "var", "is_fuzzy_match", "=", "BrowserBot", ".", "prototype", ".", "locateElementByUIElement", ".", "is_fuzzy_match", ";", "var", "pagesets", "=", "this", ".", "getPagesetsForPage", "(", "inDocument", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "pagesets", ".", "length", ";", "++", "i", ")", "{", "var", "pageset", "=", "pagesets", "[", "i", "]", ";", "var", "uiElements", "=", "pageset", ".", "getUIElements", "(", ")", ";", "for", "(", "var", "j", "=", "0", ";", "j", "<", "uiElements", ".", "length", ";", "++", "j", ")", "{", "var", "uiElement", "=", "uiElements", "[", "j", "]", ";", "// first test against the generic locator, if there is one.", "// This should net some performance benefit when recording on", "// more complicated pages.", "if", "(", "uiElement", ".", "getGenericLocator", ")", "{", "var", "passedTest", "=", "false", ";", "var", "results", "=", "eval_locator", "(", "uiElement", ".", "getGenericLocator", "(", ")", ",", "inDocument", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "results", ".", "length", ";", "++", "i", ")", "{", "if", "(", "results", "[", "i", "]", "==", "pageElement", ")", "{", "passedTest", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "passedTest", ")", "{", "continue", ";", "}", "}", "var", "defaultLocators", ";", "if", "(", "uiElement", ".", "isDefaultLocatorConstructionDeferred", ")", "{", "defaultLocators", "=", "uiElement", ".", "getDefaultLocators", "(", "inDocument", ")", ";", "}", "else", "{", "defaultLocators", "=", "uiElement", ".", "defaultLocators", ";", "}", "//safe_alert(print_r(uiElement.defaultLocators));", "for", "(", "var", "locator", "in", "defaultLocators", ")", "{", "var", "locatedElements", "=", "eval_locator", "(", "locator", ",", "inDocument", ")", ";", "if", "(", "locatedElements", ".", "length", ")", "{", "var", "locatedElement", "=", "locatedElements", "[", "0", "]", ";", "}", "else", "{", "continue", ";", "}", "// use a heuristic to determine whether the element", "// specified is the \"same\" as the element we're matching", "if", "(", "is_fuzzy_match", ")", "{", "if", "(", "is_fuzzy_match", "(", "locatedElement", ",", "pageElement", ")", ")", "{", "return", "UI_GLOBAL", ".", "UI_PREFIX", "+", "'='", "+", "new", "UISpecifier", "(", "pageset", ".", "name", ",", "uiElement", ".", "name", ",", "defaultLocators", "[", "locator", "]", ")", ";", "}", "}", "else", "{", "if", "(", "locatedElement", "==", "pageElement", ")", "{", "return", "UI_GLOBAL", ".", "UI_PREFIX", "+", "'='", "+", "new", "UISpecifier", "(", "pageset", ".", "name", ",", "uiElement", ".", "name", ",", "defaultLocators", "[", "locator", "]", ")", ";", "}", "}", "// ok, matching the element failed. See if an offset", "// locator can complete the match.", "if", "(", "uiElement", ".", "getOffsetLocator", ")", "{", "for", "(", "var", "k", "=", "0", ";", "k", "<", "locatedElements", ".", "length", ";", "++", "k", ")", "{", "var", "offsetLocator", "=", "uiElement", ".", "getOffsetLocator", "(", "locatedElements", "[", "k", "]", ",", "pageElement", ")", ";", "if", "(", "offsetLocator", ")", "{", "return", "UI_GLOBAL", ".", "UI_PREFIX", "+", "'='", "+", "new", "UISpecifier", "(", "pageset", ".", "name", ",", "uiElement", ".", "name", ",", "defaultLocators", "[", "locator", "]", ")", "+", "'->'", "+", "offsetLocator", ";", "}", "}", "}", "}", "}", "}", "return", "false", ";", "}", ";", "/**\n * Returns a sorted list of UI specifier string stubs representing possible\n * UI elements for all pagesets, paired the their descriptions. Stubs\n * contain all required arguments, but leave argument values blank.\n *\n * @return a list of UI specifier string stubs\n */", "this", ".", "getUISpecifierStringStubs", "=", "function", "(", ")", "{", "var", "stubs", "=", "[", "]", ";", "var", "pagesets", "=", "this", ".", "getPagesets", "(", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "pagesets", ".", "length", ";", "++", "i", ")", "{", "stubs", "=", "stubs", ".", "concat", "(", "pagesets", "[", "i", "]", ".", "getUISpecifierStringStubs", "(", ")", ")", ";", "}", "stubs", ".", "sort", "(", "function", "(", "a", ",", "b", ")", "{", "if", "(", "a", "[", "0", "]", "<", "b", "[", "0", "]", ")", "{", "return", "-", "1", ";", "}", "return", "a", "[", "0", "]", "==", "b", "[", "0", "]", "?", "0", ":", "1", ";", "}", ")", ";", "return", "stubs", ";", "}", "}" ]
Construct the UI map object, and return it. Once the object is instantiated, it binds to a global variable and will not leave scope. @return new UIMap object
[ "Construct", "the", "UI", "map", "object", "and", "return", "it", ".", "Once", "the", "object", "is", "instantiated", "it", "binds", "to", "a", "global", "variable", "and", "will", "not", "leave", "scope", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/ui-element.js#L822-L1163
367
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/downloads.js
downloadManager_cancelActiveDownloads
function downloadManager_cancelActiveDownloads() { // Get a list of all active downloads (nsISimpleEnumerator) var downloads = this._dms.activeDownloads; // Iterate through each active download and cancel it while (downloads.hasMoreElements()) { var download = downloads.getNext().QueryInterface(Ci.nsIDownload); this._dms.cancelDownload(download.id); } }
javascript
function downloadManager_cancelActiveDownloads() { // Get a list of all active downloads (nsISimpleEnumerator) var downloads = this._dms.activeDownloads; // Iterate through each active download and cancel it while (downloads.hasMoreElements()) { var download = downloads.getNext().QueryInterface(Ci.nsIDownload); this._dms.cancelDownload(download.id); } }
[ "function", "downloadManager_cancelActiveDownloads", "(", ")", "{", "// Get a list of all active downloads (nsISimpleEnumerator)", "var", "downloads", "=", "this", ".", "_dms", ".", "activeDownloads", ";", "// Iterate through each active download and cancel it", "while", "(", "downloads", ".", "hasMoreElements", "(", ")", ")", "{", "var", "download", "=", "downloads", ".", "getNext", "(", ")", ".", "QueryInterface", "(", "Ci", ".", "nsIDownload", ")", ";", "this", ".", "_dms", ".", "cancelDownload", "(", "download", ".", "id", ")", ";", "}", "}" ]
Cancel all active downloads
[ "Cancel", "all", "active", "downloads" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/downloads.js#L106-L115
368
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/downloads.js
downloadManager_cleanAll
function downloadManager_cleanAll(downloads) { // Cancel any active downloads this.cancelActiveDownloads(); // If no downloads have been specified retrieve the list from the database if (downloads === undefined || downloads.length == 0) downloads = this.getAllDownloads(); else downloads = downloads.concat(this.getAllDownloads()); // Delete all files referred to in the Download Manager this.deleteDownloadedFiles(downloads); // Clean any entries from the Download Manager database this.cleanUp(); }
javascript
function downloadManager_cleanAll(downloads) { // Cancel any active downloads this.cancelActiveDownloads(); // If no downloads have been specified retrieve the list from the database if (downloads === undefined || downloads.length == 0) downloads = this.getAllDownloads(); else downloads = downloads.concat(this.getAllDownloads()); // Delete all files referred to in the Download Manager this.deleteDownloadedFiles(downloads); // Clean any entries from the Download Manager database this.cleanUp(); }
[ "function", "downloadManager_cleanAll", "(", "downloads", ")", "{", "// Cancel any active downloads", "this", ".", "cancelActiveDownloads", "(", ")", ";", "// If no downloads have been specified retrieve the list from the database", "if", "(", "downloads", "===", "undefined", "||", "downloads", ".", "length", "==", "0", ")", "downloads", "=", "this", ".", "getAllDownloads", "(", ")", ";", "else", "downloads", "=", "downloads", ".", "concat", "(", "this", ".", "getAllDownloads", "(", ")", ")", ";", "// Delete all files referred to in the Download Manager", "this", ".", "deleteDownloadedFiles", "(", "downloads", ")", ";", "// Clean any entries from the Download Manager database", "this", ".", "cleanUp", "(", ")", ";", "}" ]
Cancel any active downloads, remove the files, and clean up the Download Manager database @param {Array of download} downloads Downloaded files which should be deleted (optional)
[ "Cancel", "any", "active", "downloads", "remove", "the", "files", "and", "clean", "up", "the", "Download", "Manager", "database" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/downloads.js#L132-L147
369
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/downloads.js
downloadManager_close
function downloadManager_close(force) { var windowCount = mozmill.utils.getWindows().length; if (this._controller) { // Check if we should force the closing of the DM window if (force) { this._controller.window.close(); } else { var cmdKey = utils.getEntity(this.getDtds(), "cmd.close.commandKey"); this._controller.keypress(null, cmdKey, {accelKey: true}); } this._controller.waitForEval("subject.getWindows().length == " + (windowCount - 1), gTimeout, 100, mozmill.utils); this._controller = null; } }
javascript
function downloadManager_close(force) { var windowCount = mozmill.utils.getWindows().length; if (this._controller) { // Check if we should force the closing of the DM window if (force) { this._controller.window.close(); } else { var cmdKey = utils.getEntity(this.getDtds(), "cmd.close.commandKey"); this._controller.keypress(null, cmdKey, {accelKey: true}); } this._controller.waitForEval("subject.getWindows().length == " + (windowCount - 1), gTimeout, 100, mozmill.utils); this._controller = null; } }
[ "function", "downloadManager_close", "(", "force", ")", "{", "var", "windowCount", "=", "mozmill", ".", "utils", ".", "getWindows", "(", ")", ".", "length", ";", "if", "(", "this", ".", "_controller", ")", "{", "// Check if we should force the closing of the DM window", "if", "(", "force", ")", "{", "this", ".", "_controller", ".", "window", ".", "close", "(", ")", ";", "}", "else", "{", "var", "cmdKey", "=", "utils", ".", "getEntity", "(", "this", ".", "getDtds", "(", ")", ",", "\"cmd.close.commandKey\"", ")", ";", "this", ".", "_controller", ".", "keypress", "(", "null", ",", "cmdKey", ",", "{", "accelKey", ":", "true", "}", ")", ";", "}", "this", ".", "_controller", ".", "waitForEval", "(", "\"subject.getWindows().length == \"", "+", "(", "windowCount", "-", "1", ")", ",", "gTimeout", ",", "100", ",", "mozmill", ".", "utils", ")", ";", "this", ".", "_controller", "=", "null", ";", "}", "}" ]
Close the download manager @param {boolean} force Force the closing of the DM window
[ "Close", "the", "download", "manager" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/downloads.js#L155-L171
370
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/downloads.js
downloadManager_deleteDownloadedFiles
function downloadManager_deleteDownloadedFiles(downloads) { downloads.forEach(function(download) { try { var file = getLocalFileFromNativePathOrUrl(download.target); file.remove(false); } catch (ex) { } }); }
javascript
function downloadManager_deleteDownloadedFiles(downloads) { downloads.forEach(function(download) { try { var file = getLocalFileFromNativePathOrUrl(download.target); file.remove(false); } catch (ex) { } }); }
[ "function", "downloadManager_deleteDownloadedFiles", "(", "downloads", ")", "{", "downloads", ".", "forEach", "(", "function", "(", "download", ")", "{", "try", "{", "var", "file", "=", "getLocalFileFromNativePathOrUrl", "(", "download", ".", "target", ")", ";", "file", ".", "remove", "(", "false", ")", ";", "}", "catch", "(", "ex", ")", "{", "}", "}", ")", ";", "}" ]
Delete all downloads from the local drive @param {download} downloads List of downloaded files
[ "Delete", "all", "downloads", "from", "the", "local", "drive" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/downloads.js#L179-L187
371
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/downloads.js
downloadManager_getAllDownloads
function downloadManager_getAllDownloads() { var dbConn = this._dms.DBConnection; var stmt = null; if (dbConn.schemaVersion < 3) return new Array(); // Run a SQL query and iterate through all results which have been found var downloads = []; stmt = dbConn.createStatement("SELECT * FROM moz_downloads"); while (stmt.executeStep()) { downloads.push({ id: stmt.row.id, name: stmt.row.name, target: stmt.row.target, tempPath: stmt.row.tempPath, startTime: stmt.row.startTime, endTime: stmt.row.endTime, state: stmt.row.state, referrer: stmt.row.referrer, entityID: stmt.row.entityID, currBytes: stmt.row.currBytes, maxBytes: stmt.row.maxBytes, mimeType : stmt.row.mimeType, autoResume: stmt.row.autoResume, preferredApplication: stmt.row.preferredApplication, preferredAction: stmt.row.preferredAction }); }; stmt.reset(); return downloads; }
javascript
function downloadManager_getAllDownloads() { var dbConn = this._dms.DBConnection; var stmt = null; if (dbConn.schemaVersion < 3) return new Array(); // Run a SQL query and iterate through all results which have been found var downloads = []; stmt = dbConn.createStatement("SELECT * FROM moz_downloads"); while (stmt.executeStep()) { downloads.push({ id: stmt.row.id, name: stmt.row.name, target: stmt.row.target, tempPath: stmt.row.tempPath, startTime: stmt.row.startTime, endTime: stmt.row.endTime, state: stmt.row.state, referrer: stmt.row.referrer, entityID: stmt.row.entityID, currBytes: stmt.row.currBytes, maxBytes: stmt.row.maxBytes, mimeType : stmt.row.mimeType, autoResume: stmt.row.autoResume, preferredApplication: stmt.row.preferredApplication, preferredAction: stmt.row.preferredAction }); }; stmt.reset(); return downloads; }
[ "function", "downloadManager_getAllDownloads", "(", ")", "{", "var", "dbConn", "=", "this", ".", "_dms", ".", "DBConnection", ";", "var", "stmt", "=", "null", ";", "if", "(", "dbConn", ".", "schemaVersion", "<", "3", ")", "return", "new", "Array", "(", ")", ";", "// Run a SQL query and iterate through all results which have been found", "var", "downloads", "=", "[", "]", ";", "stmt", "=", "dbConn", ".", "createStatement", "(", "\"SELECT * FROM moz_downloads\"", ")", ";", "while", "(", "stmt", ".", "executeStep", "(", ")", ")", "{", "downloads", ".", "push", "(", "{", "id", ":", "stmt", ".", "row", ".", "id", ",", "name", ":", "stmt", ".", "row", ".", "name", ",", "target", ":", "stmt", ".", "row", ".", "target", ",", "tempPath", ":", "stmt", ".", "row", ".", "tempPath", ",", "startTime", ":", "stmt", ".", "row", ".", "startTime", ",", "endTime", ":", "stmt", ".", "row", ".", "endTime", ",", "state", ":", "stmt", ".", "row", ".", "state", ",", "referrer", ":", "stmt", ".", "row", ".", "referrer", ",", "entityID", ":", "stmt", ".", "row", ".", "entityID", ",", "currBytes", ":", "stmt", ".", "row", ".", "currBytes", ",", "maxBytes", ":", "stmt", ".", "row", ".", "maxBytes", ",", "mimeType", ":", "stmt", ".", "row", ".", "mimeType", ",", "autoResume", ":", "stmt", ".", "row", ".", "autoResume", ",", "preferredApplication", ":", "stmt", ".", "row", ".", "preferredApplication", ",", "preferredAction", ":", "stmt", ".", "row", ".", "preferredAction", "}", ")", ";", "}", ";", "stmt", ".", "reset", "(", ")", ";", "return", "downloads", ";", "}" ]
Get the list of all downloaded files in the database @returns List of downloads @type {Array of download}
[ "Get", "the", "list", "of", "all", "downloaded", "files", "in", "the", "database" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/downloads.js#L195-L220
372
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/downloads.js
downloadManager_open
function downloadManager_open(controller, shortcut) { if (shortcut) { if (mozmill.isLinux) { var cmdKey = utils.getEntity(this.getDtds(), "downloadsUnix.commandkey"); controller.keypress(null, cmdKey, {ctrlKey: true, shiftKey: true}); } else { var cmdKey = utils.getEntity(this.getDtds(), "downloads.commandkey"); controller.keypress(null, cmdKey, {accelKey: true}); } } else { controller.click(new elementslib.Elem(controller.menus["tools-menu"].menu_openDownloads)); } controller.sleep(500); this.waitForOpened(controller); }
javascript
function downloadManager_open(controller, shortcut) { if (shortcut) { if (mozmill.isLinux) { var cmdKey = utils.getEntity(this.getDtds(), "downloadsUnix.commandkey"); controller.keypress(null, cmdKey, {ctrlKey: true, shiftKey: true}); } else { var cmdKey = utils.getEntity(this.getDtds(), "downloads.commandkey"); controller.keypress(null, cmdKey, {accelKey: true}); } } else { controller.click(new elementslib.Elem(controller.menus["tools-menu"].menu_openDownloads)); } controller.sleep(500); this.waitForOpened(controller); }
[ "function", "downloadManager_open", "(", "controller", ",", "shortcut", ")", "{", "if", "(", "shortcut", ")", "{", "if", "(", "mozmill", ".", "isLinux", ")", "{", "var", "cmdKey", "=", "utils", ".", "getEntity", "(", "this", ".", "getDtds", "(", ")", ",", "\"downloadsUnix.commandkey\"", ")", ";", "controller", ".", "keypress", "(", "null", ",", "cmdKey", ",", "{", "ctrlKey", ":", "true", ",", "shiftKey", ":", "true", "}", ")", ";", "}", "else", "{", "var", "cmdKey", "=", "utils", ".", "getEntity", "(", "this", ".", "getDtds", "(", ")", ",", "\"downloads.commandkey\"", ")", ";", "controller", ".", "keypress", "(", "null", ",", "cmdKey", ",", "{", "accelKey", ":", "true", "}", ")", ";", "}", "}", "else", "{", "controller", ".", "click", "(", "new", "elementslib", ".", "Elem", "(", "controller", ".", "menus", "[", "\"tools-menu\"", "]", ".", "menu_openDownloads", ")", ")", ";", "}", "controller", ".", "sleep", "(", "500", ")", ";", "this", ".", "waitForOpened", "(", "controller", ")", ";", "}" ]
Open the Download Manager @param {MozMillController} controller MozMillController of the window to operate on @param {boolean} shortcut If true the keyboard shortcut is used
[ "Open", "the", "Download", "Manager" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/downloads.js#L302-L317
373
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/downloads.js
downloadManager_waitForDownloadState
function downloadManager_waitForDownloadState(download, state, timeout) { this._controller.waitForEval("subject.manager.getDownloadState(subject.download) == subject.state", timeout, 100, {manager: this, download: download, state: state}); }
javascript
function downloadManager_waitForDownloadState(download, state, timeout) { this._controller.waitForEval("subject.manager.getDownloadState(subject.download) == subject.state", timeout, 100, {manager: this, download: download, state: state}); }
[ "function", "downloadManager_waitForDownloadState", "(", "download", ",", "state", ",", "timeout", ")", "{", "this", ".", "_controller", ".", "waitForEval", "(", "\"subject.manager.getDownloadState(subject.download) == subject.state\"", ",", "timeout", ",", "100", ",", "{", "manager", ":", "this", ",", "download", ":", "download", ",", "state", ":", "state", "}", ")", ";", "}" ]
Wait for the given download state @param {MozMillController} controller MozMillController of the window to operate on @param {downloadState} state Expected state of the download @param {number} timeout Timeout for waiting for the download state (optional)
[ "Wait", "for", "the", "given", "download", "state" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/downloads.js#L329-L332
374
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/downloads.js
function(controller, url) { controller.open(url); // Wait until the unknown content type dialog has been opened controller.waitForEval("subject.getMostRecentWindow('').document.documentElement.id == 'unknownContentType'", gTimeout, 100, mozmill.wm); utils.handleWindow("type", "", function (controller) { // Select to save the file directly var saveFile = new elementslib.ID(controller.window.document, "save"); controller.waitThenClick(saveFile, gTimeout); controller.waitForEval("subject.selected == true", gTimeout, 100, saveFile.getNode()); // Wait until the OK button has been enabled and click on it var button = new elementslib.Lookup(controller.window.document, '/id("unknownContentType")/anon({"anonid":"buttons"})/{"dlgtype":"accept"}'); controller.waitForElement(button, gTimeout); controller.waitForEval("subject.okButton.hasAttribute('disabled') == false", gTimeout, 100, {okButton: button.getNode()}); controller.click(button); }); }
javascript
function(controller, url) { controller.open(url); // Wait until the unknown content type dialog has been opened controller.waitForEval("subject.getMostRecentWindow('').document.documentElement.id == 'unknownContentType'", gTimeout, 100, mozmill.wm); utils.handleWindow("type", "", function (controller) { // Select to save the file directly var saveFile = new elementslib.ID(controller.window.document, "save"); controller.waitThenClick(saveFile, gTimeout); controller.waitForEval("subject.selected == true", gTimeout, 100, saveFile.getNode()); // Wait until the OK button has been enabled and click on it var button = new elementslib.Lookup(controller.window.document, '/id("unknownContentType")/anon({"anonid":"buttons"})/{"dlgtype":"accept"}'); controller.waitForElement(button, gTimeout); controller.waitForEval("subject.okButton.hasAttribute('disabled') == false", gTimeout, 100, {okButton: button.getNode()}); controller.click(button); }); }
[ "function", "(", "controller", ",", "url", ")", "{", "controller", ".", "open", "(", "url", ")", ";", "// Wait until the unknown content type dialog has been opened", "controller", ".", "waitForEval", "(", "\"subject.getMostRecentWindow('').document.documentElement.id == 'unknownContentType'\"", ",", "gTimeout", ",", "100", ",", "mozmill", ".", "wm", ")", ";", "utils", ".", "handleWindow", "(", "\"type\"", ",", "\"\"", ",", "function", "(", "controller", ")", "{", "// Select to save the file directly", "var", "saveFile", "=", "new", "elementslib", ".", "ID", "(", "controller", ".", "window", ".", "document", ",", "\"save\"", ")", ";", "controller", ".", "waitThenClick", "(", "saveFile", ",", "gTimeout", ")", ";", "controller", ".", "waitForEval", "(", "\"subject.selected == true\"", ",", "gTimeout", ",", "100", ",", "saveFile", ".", "getNode", "(", ")", ")", ";", "// Wait until the OK button has been enabled and click on it", "var", "button", "=", "new", "elementslib", ".", "Lookup", "(", "controller", ".", "window", ".", "document", ",", "'/id(\"unknownContentType\")/anon({\"anonid\":\"buttons\"})/{\"dlgtype\":\"accept\"}'", ")", ";", "controller", ".", "waitForElement", "(", "button", ",", "gTimeout", ")", ";", "controller", ".", "waitForEval", "(", "\"subject.okButton.hasAttribute('disabled') == false\"", ",", "gTimeout", ",", "100", ",", "{", "okButton", ":", "button", ".", "getNode", "(", ")", "}", ")", ";", "controller", ".", "click", "(", "button", ")", ";", "}", ")", ";", "}" ]
Download the file of unkown type from the given location by saving it automatically to disk @param {MozMillController} controller MozMillController of the browser window @param {string} url URL of the file which has to be downloaded
[ "Download", "the", "file", "of", "unkown", "type", "from", "the", "given", "location", "by", "saving", "it", "automatically", "to", "disk" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/downloads.js#L355-L377
375
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/downloads.js
getLocalFileFromNativePathOrUrl
function getLocalFileFromNativePathOrUrl(aPathOrUrl) { if (aPathOrUrl.substring(0,7) == "file://") { // if this is a URL, get the file from that let ioSvc = Cc["@mozilla.org/network/io-service;1"] .getService(Ci.nsIIOService); // XXX it's possible that using a null char-set here is bad const fileUrl = ioSvc.newURI(aPathOrUrl, null, null) .QueryInterface(Ci.nsIFileURL); return fileUrl.file.clone().QueryInterface(Ci.nsILocalFile); } else { // if it's a pathname, create the nsILocalFile directly var f = new nsLocalFile(aPathOrUrl); return f; } }
javascript
function getLocalFileFromNativePathOrUrl(aPathOrUrl) { if (aPathOrUrl.substring(0,7) == "file://") { // if this is a URL, get the file from that let ioSvc = Cc["@mozilla.org/network/io-service;1"] .getService(Ci.nsIIOService); // XXX it's possible that using a null char-set here is bad const fileUrl = ioSvc.newURI(aPathOrUrl, null, null) .QueryInterface(Ci.nsIFileURL); return fileUrl.file.clone().QueryInterface(Ci.nsILocalFile); } else { // if it's a pathname, create the nsILocalFile directly var f = new nsLocalFile(aPathOrUrl); return f; } }
[ "function", "getLocalFileFromNativePathOrUrl", "(", "aPathOrUrl", ")", "{", "if", "(", "aPathOrUrl", ".", "substring", "(", "0", ",", "7", ")", "==", "\"file://\"", ")", "{", "// if this is a URL, get the file from that", "let", "ioSvc", "=", "Cc", "[", "\"@mozilla.org/network/io-service;1\"", "]", ".", "getService", "(", "Ci", ".", "nsIIOService", ")", ";", "// XXX it's possible that using a null char-set here is bad", "const", "fileUrl", "=", "ioSvc", ".", "newURI", "(", "aPathOrUrl", ",", "null", ",", "null", ")", ".", "QueryInterface", "(", "Ci", ".", "nsIFileURL", ")", ";", "return", "fileUrl", ".", "file", ".", "clone", "(", ")", ".", "QueryInterface", "(", "Ci", ".", "nsILocalFile", ")", ";", "}", "else", "{", "// if it's a pathname, create the nsILocalFile directly", "var", "f", "=", "new", "nsLocalFile", "(", "aPathOrUrl", ")", ";", "return", "f", ";", "}", "}" ]
Get a local file from a native path or URL @param {string} aPathOrUrl Native path or URL of the file @see http://mxr.mozilla.org/mozilla-central/source/toolkit/mozapps/downloads/content/downloads.js#1309
[ "Get", "a", "local", "file", "from", "a", "native", "path", "or", "URL" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/downloads.js#L386-L401
376
SeleniumHQ/selenium
javascript/jsunit/app/jsUnitCore.js
jsUnitFixTop
function jsUnitFixTop() { var tempTop = top; if (!tempTop) { tempTop = window; while (tempTop.parent) { tempTop = tempTop.parent; if (tempTop.top && tempTop.top.jsUnitTestSuite) { tempTop = tempTop.top; break; } } } try { window.top = tempTop; } catch (e) { } }
javascript
function jsUnitFixTop() { var tempTop = top; if (!tempTop) { tempTop = window; while (tempTop.parent) { tempTop = tempTop.parent; if (tempTop.top && tempTop.top.jsUnitTestSuite) { tempTop = tempTop.top; break; } } } try { window.top = tempTop; } catch (e) { } }
[ "function", "jsUnitFixTop", "(", ")", "{", "var", "tempTop", "=", "top", ";", "if", "(", "!", "tempTop", ")", "{", "tempTop", "=", "window", ";", "while", "(", "tempTop", ".", "parent", ")", "{", "tempTop", "=", "tempTop", ".", "parent", ";", "if", "(", "tempTop", ".", "top", "&&", "tempTop", ".", "top", ".", "jsUnitTestSuite", ")", "{", "tempTop", "=", "tempTop", ".", "top", ";", "break", ";", "}", "}", "}", "try", "{", "window", ".", "top", "=", "tempTop", ";", "}", "catch", "(", "e", ")", "{", "}", "}" ]
hack for NS62 bug
[ "hack", "for", "NS62", "bug" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/jsunit/app/jsUnitCore.js#L6-L22
377
SeleniumHQ/selenium
javascript/node/optparse.js
formatHelpMsg
function formatHelpMsg(usage, options) { var prog = path.basename( process.argv[0]) + ' ' + path.basename(process.argv[1]); var help = [ usage.replace(/\$0\b/g, prog), '', 'Options:', formatOption('help', 'Show this message and exit') ]; Object.keys(options).sort().forEach(function(key) { help.push(formatOption(key, options[key].help)); }); help.push(''); return help.join('\n'); }
javascript
function formatHelpMsg(usage, options) { var prog = path.basename( process.argv[0]) + ' ' + path.basename(process.argv[1]); var help = [ usage.replace(/\$0\b/g, prog), '', 'Options:', formatOption('help', 'Show this message and exit') ]; Object.keys(options).sort().forEach(function(key) { help.push(formatOption(key, options[key].help)); }); help.push(''); return help.join('\n'); }
[ "function", "formatHelpMsg", "(", "usage", ",", "options", ")", "{", "var", "prog", "=", "path", ".", "basename", "(", "process", ".", "argv", "[", "0", "]", ")", "+", "' '", "+", "path", ".", "basename", "(", "process", ".", "argv", "[", "1", "]", ")", ";", "var", "help", "=", "[", "usage", ".", "replace", "(", "/", "\\$0\\b", "/", "g", ",", "prog", ")", ",", "''", ",", "'Options:'", ",", "formatOption", "(", "'help'", ",", "'Show this message and exit'", ")", "]", ";", "Object", ".", "keys", "(", "options", ")", ".", "sort", "(", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "help", ".", "push", "(", "formatOption", "(", "key", ",", "options", "[", "key", "]", ".", "help", ")", ")", ";", "}", ")", ";", "help", ".", "push", "(", "''", ")", ";", "return", "help", ".", "join", "(", "'\\n'", ")", ";", "}" ]
Formats a help message for the given parser. @param {string} usage The usage string. All occurences of "$0" will be replaced with the name of the current program. @param {!Object.<!Option>} options The options to format. @return {string} The formatted help message.
[ "Formats", "a", "help", "message", "for", "the", "given", "parser", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/node/optparse.js#L123-L140
378
SeleniumHQ/selenium
javascript/node/optparse.js
formatOption
function formatOption(name, helpMsg) { var result = []; var options = IDENTATION + '--' + name; if (options.length > MAX_HELP_POSITION) { result.push(options); result.push('\n'); result.push(wrapStr(helpMsg, TOTAL_WIDTH, repeatStr(' ', HELP_TEXT_POSITION)).join('\n')); } else { var spaceCount = HELP_TEXT_POSITION - options.length; options += repeatStr(' ', spaceCount) + helpMsg; result.push(options.substring(0, TOTAL_WIDTH)); options = options.substring(TOTAL_WIDTH); if (options) { result.push('\n'); result.push(wrapStr(options, TOTAL_WIDTH, repeatStr(' ', HELP_TEXT_POSITION)).join('\n')); } } return result.join(''); }
javascript
function formatOption(name, helpMsg) { var result = []; var options = IDENTATION + '--' + name; if (options.length > MAX_HELP_POSITION) { result.push(options); result.push('\n'); result.push(wrapStr(helpMsg, TOTAL_WIDTH, repeatStr(' ', HELP_TEXT_POSITION)).join('\n')); } else { var spaceCount = HELP_TEXT_POSITION - options.length; options += repeatStr(' ', spaceCount) + helpMsg; result.push(options.substring(0, TOTAL_WIDTH)); options = options.substring(TOTAL_WIDTH); if (options) { result.push('\n'); result.push(wrapStr(options, TOTAL_WIDTH, repeatStr(' ', HELP_TEXT_POSITION)).join('\n')); } } return result.join(''); }
[ "function", "formatOption", "(", "name", ",", "helpMsg", ")", "{", "var", "result", "=", "[", "]", ";", "var", "options", "=", "IDENTATION", "+", "'--'", "+", "name", ";", "if", "(", "options", ".", "length", ">", "MAX_HELP_POSITION", ")", "{", "result", ".", "push", "(", "options", ")", ";", "result", ".", "push", "(", "'\\n'", ")", ";", "result", ".", "push", "(", "wrapStr", "(", "helpMsg", ",", "TOTAL_WIDTH", ",", "repeatStr", "(", "' '", ",", "HELP_TEXT_POSITION", ")", ")", ".", "join", "(", "'\\n'", ")", ")", ";", "}", "else", "{", "var", "spaceCount", "=", "HELP_TEXT_POSITION", "-", "options", ".", "length", ";", "options", "+=", "repeatStr", "(", "' '", ",", "spaceCount", ")", "+", "helpMsg", ";", "result", ".", "push", "(", "options", ".", "substring", "(", "0", ",", "TOTAL_WIDTH", ")", ")", ";", "options", "=", "options", ".", "substring", "(", "TOTAL_WIDTH", ")", ";", "if", "(", "options", ")", "{", "result", ".", "push", "(", "'\\n'", ")", ";", "result", ".", "push", "(", "wrapStr", "(", "options", ",", "TOTAL_WIDTH", ",", "repeatStr", "(", "' '", ",", "HELP_TEXT_POSITION", ")", ")", ".", "join", "(", "'\\n'", ")", ")", ";", "}", "}", "return", "result", ".", "join", "(", "''", ")", ";", "}" ]
Formats the help message for a single option. Will place the option string and help text on the same line whenever possible. @param {string} name The name of the option. @param {string} helpMsg The option's help message. @return {string} The formatted option.
[ "Formats", "the", "help", "message", "for", "a", "single", "option", ".", "Will", "place", "the", "option", "string", "and", "help", "text", "on", "the", "same", "line", "whenever", "possible", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/node/optparse.js#L150-L172
379
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/localization.js
checkAccessKeysResults
function checkAccessKeysResults(controller, accessKeysSet) { // Sort the access keys to have them in a A->Z order var accessKeysList = accessKeysSet.sort(); // List of access keys var aKeysList = []; // List of values to identify the access keys var valueList = []; // List of rectangles of nodes containing access keys var rects = []; // List of rectangles of nodes with broken access keys var badRects = []; // Makes lists of all access keys and the values the access keys are in for (var i = 0; i < accessKeysList.length; i++) { var accessKey = accessKeysList[i][0]; var node = accessKeysList[i][1]; // Set the id and label to be shown in the console var id = node.id || "(id is undefined)"; var label = node.label || "(label is undefined)"; var box = node.boxObject; var innerIds = []; var innerRects = []; // if the access key is already in our list, take it out to replace it // later if (accessKey == aKeysList[aKeysList.length-1]) { innerIds = valueList.pop(); innerRects = rects.pop(); } else { aKeysList.push([accessKey]); } innerIds.push("[id: " + id + ", label: " + label + "]"); valueList.push(innerIds); innerRects.push([box.x, box.y, box.width, box.height]); rects.push(innerRects); } // Go through all access keys and find the duplicated ones for (var i = 0; i < valueList.length; i++) { // Only access keys contained in more than one node are the ones we are // looking for if (valueList[i].length > 1) { for (var j = 0; j < rects[i].length; j++) { badRects.push(rects[i][j]); } jumlib.assert(false, 'accessKey: ' + aKeysList[i] + ' found in string\'s: ' + valueList[i].join(", ")); } } // If we have found broken access keys, make a screenshot if (badRects.length > 0) { screenshot.create(controller, badRects); } }
javascript
function checkAccessKeysResults(controller, accessKeysSet) { // Sort the access keys to have them in a A->Z order var accessKeysList = accessKeysSet.sort(); // List of access keys var aKeysList = []; // List of values to identify the access keys var valueList = []; // List of rectangles of nodes containing access keys var rects = []; // List of rectangles of nodes with broken access keys var badRects = []; // Makes lists of all access keys and the values the access keys are in for (var i = 0; i < accessKeysList.length; i++) { var accessKey = accessKeysList[i][0]; var node = accessKeysList[i][1]; // Set the id and label to be shown in the console var id = node.id || "(id is undefined)"; var label = node.label || "(label is undefined)"; var box = node.boxObject; var innerIds = []; var innerRects = []; // if the access key is already in our list, take it out to replace it // later if (accessKey == aKeysList[aKeysList.length-1]) { innerIds = valueList.pop(); innerRects = rects.pop(); } else { aKeysList.push([accessKey]); } innerIds.push("[id: " + id + ", label: " + label + "]"); valueList.push(innerIds); innerRects.push([box.x, box.y, box.width, box.height]); rects.push(innerRects); } // Go through all access keys and find the duplicated ones for (var i = 0; i < valueList.length; i++) { // Only access keys contained in more than one node are the ones we are // looking for if (valueList[i].length > 1) { for (var j = 0; j < rects[i].length; j++) { badRects.push(rects[i][j]); } jumlib.assert(false, 'accessKey: ' + aKeysList[i] + ' found in string\'s: ' + valueList[i].join(", ")); } } // If we have found broken access keys, make a screenshot if (badRects.length > 0) { screenshot.create(controller, badRects); } }
[ "function", "checkAccessKeysResults", "(", "controller", ",", "accessKeysSet", ")", "{", "// Sort the access keys to have them in a A->Z order", "var", "accessKeysList", "=", "accessKeysSet", ".", "sort", "(", ")", ";", "// List of access keys", "var", "aKeysList", "=", "[", "]", ";", "// List of values to identify the access keys", "var", "valueList", "=", "[", "]", ";", "// List of rectangles of nodes containing access keys", "var", "rects", "=", "[", "]", ";", "// List of rectangles of nodes with broken access keys", "var", "badRects", "=", "[", "]", ";", "// Makes lists of all access keys and the values the access keys are in", "for", "(", "var", "i", "=", "0", ";", "i", "<", "accessKeysList", ".", "length", ";", "i", "++", ")", "{", "var", "accessKey", "=", "accessKeysList", "[", "i", "]", "[", "0", "]", ";", "var", "node", "=", "accessKeysList", "[", "i", "]", "[", "1", "]", ";", "// Set the id and label to be shown in the console", "var", "id", "=", "node", ".", "id", "||", "\"(id is undefined)\"", ";", "var", "label", "=", "node", ".", "label", "||", "\"(label is undefined)\"", ";", "var", "box", "=", "node", ".", "boxObject", ";", "var", "innerIds", "=", "[", "]", ";", "var", "innerRects", "=", "[", "]", ";", "// if the access key is already in our list, take it out to replace it", "// later", "if", "(", "accessKey", "==", "aKeysList", "[", "aKeysList", ".", "length", "-", "1", "]", ")", "{", "innerIds", "=", "valueList", ".", "pop", "(", ")", ";", "innerRects", "=", "rects", ".", "pop", "(", ")", ";", "}", "else", "{", "aKeysList", ".", "push", "(", "[", "accessKey", "]", ")", ";", "}", "innerIds", ".", "push", "(", "\"[id: \"", "+", "id", "+", "\", label: \"", "+", "label", "+", "\"]\"", ")", ";", "valueList", ".", "push", "(", "innerIds", ")", ";", "innerRects", ".", "push", "(", "[", "box", ".", "x", ",", "box", ".", "y", ",", "box", ".", "width", ",", "box", ".", "height", "]", ")", ";", "rects", ".", "push", "(", "innerRects", ")", ";", "}", "// Go through all access keys and find the duplicated ones", "for", "(", "var", "i", "=", "0", ";", "i", "<", "valueList", ".", "length", ";", "i", "++", ")", "{", "// Only access keys contained in more than one node are the ones we are", "// looking for", "if", "(", "valueList", "[", "i", "]", ".", "length", ">", "1", ")", "{", "for", "(", "var", "j", "=", "0", ";", "j", "<", "rects", "[", "i", "]", ".", "length", ";", "j", "++", ")", "{", "badRects", ".", "push", "(", "rects", "[", "i", "]", "[", "j", "]", ")", ";", "}", "jumlib", ".", "assert", "(", "false", ",", "'accessKey: '", "+", "aKeysList", "[", "i", "]", "+", "' found in string\\'s: '", "+", "valueList", "[", "i", "]", ".", "join", "(", "\", \"", ")", ")", ";", "}", "}", "// If we have found broken access keys, make a screenshot", "if", "(", "badRects", ".", "length", ">", "0", ")", "{", "screenshot", ".", "create", "(", "controller", ",", "badRects", ")", ";", "}", "}" ]
Callback function for parsing the results of testing for duplicated access keys. This function processes the access keys found in one access keys scope looking for access keys that are listed more than one time. At the end, it calls the screenshot.create to create a screenshot with the elements containing the broken access keys highlighted. @param {array of array of object} accessKeysSet @param {MozmillController} controller
[ "Callback", "function", "for", "parsing", "the", "results", "of", "testing", "for", "duplicated", "access", "keys", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/localization.js#L57-L118
380
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/localization.js
checkDimensions
function checkDimensions(child) { if (!child.boxObject) return []; var childBox = child.boxObject; var parent = childBox.parentBox; // toplevel element or hidden elements, like script tags if (!parent || parent == child.element || !parent.boxObject) { return []; } var parentBox = parent.boxObject; var badRects = []; // check width if (childBox.height && childBox.screenX < parentBox.screenX) { badRects.push([childBox.x, childBox.y, parentBox.x - childBox.x, childBox.height]); jumlib.assert(false, 'Node is cut off at the left: ' + _reportNode(child) + '. Parent node: ' + _reportNode(parent)); } if (childBox.height && childBox.screenX + childBox.width > parentBox.screenX + parentBox.width) { badRects.push([parentBox.x + parentBox.width, childBox.y, childBox.x + childBox.width - parentBox.x - parentBox.width, childBox.height]); jumlib.assert(false, 'Node is cut off at the right: ' + _reportNode(child) + '. Parent node: ' + _reportNode(parent)); } // check height // We don't want to test menupopup's, as they always report the full height // of all items in the popup if (child.nodeName != 'menupopup' && parent.nodeName != 'menupopup') { if (childBox.width && childBox.screenY < parentBox.screenY) { badRects.push([childBox.x, childBox.y, parentBox.y - childBox.y, childBox.width]); jumlib.assert(false, 'Node is cut off at the top: ' + _reportNode(child) + '. Parent node: ' + _reportNode(parent)); } if (childBox.width && childBox.screenY + childBox.height > parentBox.screenY + parentBox.height) { badRects.push([childBox.x, parentBox.y + parentBox.height, childBox.width, childBox.y + childBox.height - parentBox.y - parentBox.height]); jumlib.assert(false, 'Node is cut off at the bottom: ' + _reportNode(child) + '. Parent node: ' + _reportNode(parent)); } } return badRects; }
javascript
function checkDimensions(child) { if (!child.boxObject) return []; var childBox = child.boxObject; var parent = childBox.parentBox; // toplevel element or hidden elements, like script tags if (!parent || parent == child.element || !parent.boxObject) { return []; } var parentBox = parent.boxObject; var badRects = []; // check width if (childBox.height && childBox.screenX < parentBox.screenX) { badRects.push([childBox.x, childBox.y, parentBox.x - childBox.x, childBox.height]); jumlib.assert(false, 'Node is cut off at the left: ' + _reportNode(child) + '. Parent node: ' + _reportNode(parent)); } if (childBox.height && childBox.screenX + childBox.width > parentBox.screenX + parentBox.width) { badRects.push([parentBox.x + parentBox.width, childBox.y, childBox.x + childBox.width - parentBox.x - parentBox.width, childBox.height]); jumlib.assert(false, 'Node is cut off at the right: ' + _reportNode(child) + '. Parent node: ' + _reportNode(parent)); } // check height // We don't want to test menupopup's, as they always report the full height // of all items in the popup if (child.nodeName != 'menupopup' && parent.nodeName != 'menupopup') { if (childBox.width && childBox.screenY < parentBox.screenY) { badRects.push([childBox.x, childBox.y, parentBox.y - childBox.y, childBox.width]); jumlib.assert(false, 'Node is cut off at the top: ' + _reportNode(child) + '. Parent node: ' + _reportNode(parent)); } if (childBox.width && childBox.screenY + childBox.height > parentBox.screenY + parentBox.height) { badRects.push([childBox.x, parentBox.y + parentBox.height, childBox.width, childBox.y + childBox.height - parentBox.y - parentBox.height]); jumlib.assert(false, 'Node is cut off at the bottom: ' + _reportNode(child) + '. Parent node: ' + _reportNode(parent)); } } return badRects; }
[ "function", "checkDimensions", "(", "child", ")", "{", "if", "(", "!", "child", ".", "boxObject", ")", "return", "[", "]", ";", "var", "childBox", "=", "child", ".", "boxObject", ";", "var", "parent", "=", "childBox", ".", "parentBox", ";", "// toplevel element or hidden elements, like script tags", "if", "(", "!", "parent", "||", "parent", "==", "child", ".", "element", "||", "!", "parent", ".", "boxObject", ")", "{", "return", "[", "]", ";", "}", "var", "parentBox", "=", "parent", ".", "boxObject", ";", "var", "badRects", "=", "[", "]", ";", "// check width", "if", "(", "childBox", ".", "height", "&&", "childBox", ".", "screenX", "<", "parentBox", ".", "screenX", ")", "{", "badRects", ".", "push", "(", "[", "childBox", ".", "x", ",", "childBox", ".", "y", ",", "parentBox", ".", "x", "-", "childBox", ".", "x", ",", "childBox", ".", "height", "]", ")", ";", "jumlib", ".", "assert", "(", "false", ",", "'Node is cut off at the left: '", "+", "_reportNode", "(", "child", ")", "+", "'. Parent node: '", "+", "_reportNode", "(", "parent", ")", ")", ";", "}", "if", "(", "childBox", ".", "height", "&&", "childBox", ".", "screenX", "+", "childBox", ".", "width", ">", "parentBox", ".", "screenX", "+", "parentBox", ".", "width", ")", "{", "badRects", ".", "push", "(", "[", "parentBox", ".", "x", "+", "parentBox", ".", "width", ",", "childBox", ".", "y", ",", "childBox", ".", "x", "+", "childBox", ".", "width", "-", "parentBox", ".", "x", "-", "parentBox", ".", "width", ",", "childBox", ".", "height", "]", ")", ";", "jumlib", ".", "assert", "(", "false", ",", "'Node is cut off at the right: '", "+", "_reportNode", "(", "child", ")", "+", "'. Parent node: '", "+", "_reportNode", "(", "parent", ")", ")", ";", "}", "// check height", "// We don't want to test menupopup's, as they always report the full height", "// of all items in the popup", "if", "(", "child", ".", "nodeName", "!=", "'menupopup'", "&&", "parent", ".", "nodeName", "!=", "'menupopup'", ")", "{", "if", "(", "childBox", ".", "width", "&&", "childBox", ".", "screenY", "<", "parentBox", ".", "screenY", ")", "{", "badRects", ".", "push", "(", "[", "childBox", ".", "x", ",", "childBox", ".", "y", ",", "parentBox", ".", "y", "-", "childBox", ".", "y", ",", "childBox", ".", "width", "]", ")", ";", "jumlib", ".", "assert", "(", "false", ",", "'Node is cut off at the top: '", "+", "_reportNode", "(", "child", ")", "+", "'. Parent node: '", "+", "_reportNode", "(", "parent", ")", ")", ";", "}", "if", "(", "childBox", ".", "width", "&&", "childBox", ".", "screenY", "+", "childBox", ".", "height", ">", "parentBox", ".", "screenY", "+", "parentBox", ".", "height", ")", "{", "badRects", ".", "push", "(", "[", "childBox", ".", "x", ",", "parentBox", ".", "y", "+", "parentBox", ".", "height", ",", "childBox", ".", "width", ",", "childBox", ".", "y", "+", "childBox", ".", "height", "-", "parentBox", ".", "y", "-", "parentBox", ".", "height", "]", ")", ";", "jumlib", ".", "assert", "(", "false", ",", "'Node is cut off at the bottom: '", "+", "_reportNode", "(", "child", ")", "+", "'. Parent node: '", "+", "_reportNode", "(", "parent", ")", ")", ";", "}", "}", "return", "badRects", ";", "}" ]
Callback function for testing for cropped elements. Checks if the XUL boxObject has screen coordinates outside of the screen coordinates of its parent. If there's no parent, return. @param {node} child @returns List of boxes that can be highlighted on a screenshot @type {array of array of int}
[ "Callback", "function", "for", "testing", "for", "cropped", "elements", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/localization.js#L130-L181
381
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/localization.js
filterAccessKeys
function filterAccessKeys(node) { // Menus will need a separate filter set var notAllowedLocalNames = ["menu", "menubar", "menupopup", "popupset"]; if (!node.disabled && !node.collapsed && !node.hidden && notAllowedLocalNames.indexOf(node.localName) == -1) { // Code specific to the preferences panes to reject out not visible nodes // in the panes. if (node.parentNode && (node.parentNode.localName == "prefwindow" && node.parentNode.currentPane.id != node.id) || ((node.parentNode.localName == "tabpanels" || node.parentNode.localName == "deck") && node.parentNode.selectedPanel.id != node.id)) { return domUtils.DOMWalker.FILTER_REJECT; // end of the specific code } else if (node.accessKey) { return domUtils.DOMWalker.FILTER_ACCEPT; } else { return domUtils.DOMWalker.FILTER_SKIP; } } else { // we don't want to test not visible elements return domUtils.DOMWalker.FILTER_REJECT; } }
javascript
function filterAccessKeys(node) { // Menus will need a separate filter set var notAllowedLocalNames = ["menu", "menubar", "menupopup", "popupset"]; if (!node.disabled && !node.collapsed && !node.hidden && notAllowedLocalNames.indexOf(node.localName) == -1) { // Code specific to the preferences panes to reject out not visible nodes // in the panes. if (node.parentNode && (node.parentNode.localName == "prefwindow" && node.parentNode.currentPane.id != node.id) || ((node.parentNode.localName == "tabpanels" || node.parentNode.localName == "deck") && node.parentNode.selectedPanel.id != node.id)) { return domUtils.DOMWalker.FILTER_REJECT; // end of the specific code } else if (node.accessKey) { return domUtils.DOMWalker.FILTER_ACCEPT; } else { return domUtils.DOMWalker.FILTER_SKIP; } } else { // we don't want to test not visible elements return domUtils.DOMWalker.FILTER_REJECT; } }
[ "function", "filterAccessKeys", "(", "node", ")", "{", "// Menus will need a separate filter set", "var", "notAllowedLocalNames", "=", "[", "\"menu\"", ",", "\"menubar\"", ",", "\"menupopup\"", ",", "\"popupset\"", "]", ";", "if", "(", "!", "node", ".", "disabled", "&&", "!", "node", ".", "collapsed", "&&", "!", "node", ".", "hidden", "&&", "notAllowedLocalNames", ".", "indexOf", "(", "node", ".", "localName", ")", "==", "-", "1", ")", "{", "// Code specific to the preferences panes to reject out not visible nodes", "// in the panes.", "if", "(", "node", ".", "parentNode", "&&", "(", "node", ".", "parentNode", ".", "localName", "==", "\"prefwindow\"", "&&", "node", ".", "parentNode", ".", "currentPane", ".", "id", "!=", "node", ".", "id", ")", "||", "(", "(", "node", ".", "parentNode", ".", "localName", "==", "\"tabpanels\"", "||", "node", ".", "parentNode", ".", "localName", "==", "\"deck\"", ")", "&&", "node", ".", "parentNode", ".", "selectedPanel", ".", "id", "!=", "node", ".", "id", ")", ")", "{", "return", "domUtils", ".", "DOMWalker", ".", "FILTER_REJECT", ";", "// end of the specific code", "}", "else", "if", "(", "node", ".", "accessKey", ")", "{", "return", "domUtils", ".", "DOMWalker", ".", "FILTER_ACCEPT", ";", "}", "else", "{", "return", "domUtils", ".", "DOMWalker", ".", "FILTER_SKIP", ";", "}", "}", "else", "{", "// we don't want to test not visible elements", "return", "domUtils", ".", "DOMWalker", ".", "FILTER_REJECT", ";", "}", "}" ]
Filters out nodes which should not be tested because they are not in the current access key scope. @param {node} node @returns Filter status of the given node @type {array of array of int}
[ "Filters", "out", "nodes", "which", "should", "not", "be", "tested", "because", "they", "are", "not", "in", "the", "current", "access", "key", "scope", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/localization.js#L191-L215
382
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/localization.js
filterCroppedNodes
function filterCroppedNodes(node) { if (!node.boxObject) { return domUtils.DOMWalker.FILTER_SKIP; } else { if (!node.disabled && !node.collapsed && !node.hidden) { // Code specific to the preferences panes to reject out not visible nodes // in the panes. if (node.parentNode && (node.parentNode.localName == "prefwindow" && node.parentNode.currentPane.id != node.id) || ((node.parentNode.localName == "tabpanels" || node.parentNode.localName == "deck") && node.parentNode.selectedPanel.id != node.id)) { return domUtils.DOMWalker.FILTER_REJECT; // end of the specific code } else { return domUtils.DOMWalker.FILTER_ACCEPT; } } else { // we don't want to test not visible elements return domUtils.DOMWalker.FILTER_REJECT; } } }
javascript
function filterCroppedNodes(node) { if (!node.boxObject) { return domUtils.DOMWalker.FILTER_SKIP; } else { if (!node.disabled && !node.collapsed && !node.hidden) { // Code specific to the preferences panes to reject out not visible nodes // in the panes. if (node.parentNode && (node.parentNode.localName == "prefwindow" && node.parentNode.currentPane.id != node.id) || ((node.parentNode.localName == "tabpanels" || node.parentNode.localName == "deck") && node.parentNode.selectedPanel.id != node.id)) { return domUtils.DOMWalker.FILTER_REJECT; // end of the specific code } else { return domUtils.DOMWalker.FILTER_ACCEPT; } } else { // we don't want to test not visible elements return domUtils.DOMWalker.FILTER_REJECT; } } }
[ "function", "filterCroppedNodes", "(", "node", ")", "{", "if", "(", "!", "node", ".", "boxObject", ")", "{", "return", "domUtils", ".", "DOMWalker", ".", "FILTER_SKIP", ";", "}", "else", "{", "if", "(", "!", "node", ".", "disabled", "&&", "!", "node", ".", "collapsed", "&&", "!", "node", ".", "hidden", ")", "{", "// Code specific to the preferences panes to reject out not visible nodes", "// in the panes.", "if", "(", "node", ".", "parentNode", "&&", "(", "node", ".", "parentNode", ".", "localName", "==", "\"prefwindow\"", "&&", "node", ".", "parentNode", ".", "currentPane", ".", "id", "!=", "node", ".", "id", ")", "||", "(", "(", "node", ".", "parentNode", ".", "localName", "==", "\"tabpanels\"", "||", "node", ".", "parentNode", ".", "localName", "==", "\"deck\"", ")", "&&", "node", ".", "parentNode", ".", "selectedPanel", ".", "id", "!=", "node", ".", "id", ")", ")", "{", "return", "domUtils", ".", "DOMWalker", ".", "FILTER_REJECT", ";", "// end of the specific code", "}", "else", "{", "return", "domUtils", ".", "DOMWalker", ".", "FILTER_ACCEPT", ";", "}", "}", "else", "{", "// we don't want to test not visible elements", "return", "domUtils", ".", "DOMWalker", ".", "FILTER_REJECT", ";", "}", "}", "}" ]
Filters out nodes which should not be tested because they are not visible @param {node} node @returns Filter status of the given node @type {array of array of int}
[ "Filters", "out", "nodes", "which", "should", "not", "be", "tested", "because", "they", "are", "not", "visible" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/localization.js#L224-L246
383
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/localization.js
processDimensionsResults
function processDimensionsResults(controller, boxes) { if (boxes && boxes.length > 0) { screenshot.create(controller, boxes); } }
javascript
function processDimensionsResults(controller, boxes) { if (boxes && boxes.length > 0) { screenshot.create(controller, boxes); } }
[ "function", "processDimensionsResults", "(", "controller", ",", "boxes", ")", "{", "if", "(", "boxes", "&&", "boxes", ".", "length", ">", "0", ")", "{", "screenshot", ".", "create", "(", "controller", ",", "boxes", ")", ";", "}", "}" ]
Callback function for parsing the results of testing for cropped elements. This function calls the screenshot.create method if there is at least one box. @param {array of array of int} boxes @param {MozmillController} controller
[ "Callback", "function", "for", "parsing", "the", "results", "of", "testing", "for", "cropped", "elements", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/localization.js#L270-L274
384
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/localization.js
_reportNode
function _reportNode(node) { if (node.id) { return "id: " + node.id; } else if (node.label) { return "label: " + node.label; } else if (node.value) { return "value: " + node.value; } else if (node.hasAttributes()) { var attrs = "node attributes: "; for (var i = node.attributes.length - 1; i >= 0; i--) { attrs += node.attributes[i].name + "->" + node.attributes[i].value + ";"; } return attrs; } else { return "anonymous node"; } }
javascript
function _reportNode(node) { if (node.id) { return "id: " + node.id; } else if (node.label) { return "label: " + node.label; } else if (node.value) { return "value: " + node.value; } else if (node.hasAttributes()) { var attrs = "node attributes: "; for (var i = node.attributes.length - 1; i >= 0; i--) { attrs += node.attributes[i].name + "->" + node.attributes[i].value + ";"; } return attrs; } else { return "anonymous node"; } }
[ "function", "_reportNode", "(", "node", ")", "{", "if", "(", "node", ".", "id", ")", "{", "return", "\"id: \"", "+", "node", ".", "id", ";", "}", "else", "if", "(", "node", ".", "label", ")", "{", "return", "\"label: \"", "+", "node", ".", "label", ";", "}", "else", "if", "(", "node", ".", "value", ")", "{", "return", "\"value: \"", "+", "node", ".", "value", ";", "}", "else", "if", "(", "node", ".", "hasAttributes", "(", ")", ")", "{", "var", "attrs", "=", "\"node attributes: \"", ";", "for", "(", "var", "i", "=", "node", ".", "attributes", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "attrs", "+=", "node", ".", "attributes", "[", "i", "]", ".", "name", "+", "\"->\"", "+", "node", ".", "attributes", "[", "i", "]", ".", "value", "+", "\";\"", ";", "}", "return", "attrs", ";", "}", "else", "{", "return", "\"anonymous node\"", ";", "}", "}" ]
Tries to return a useful string identificator of the given node @param {node} node @returns Identificator of the node @type {String}
[ "Tries", "to", "return", "a", "useful", "string", "identificator", "of", "the", "given", "node" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/localization.js#L283-L299
385
SeleniumHQ/selenium
javascript/selenium-core/xpath/util.js
mapExec
function mapExec(array, func) { for (var i = 0; i < array.length; ++i) { func.call(this, array[i], i); } }
javascript
function mapExec(array, func) { for (var i = 0; i < array.length; ++i) { func.call(this, array[i], i); } }
[ "function", "mapExec", "(", "array", ",", "func", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "array", ".", "length", ";", "++", "i", ")", "{", "func", ".", "call", "(", "this", ",", "array", "[", "i", "]", ",", "i", ")", ";", "}", "}" ]
Applies the given function to each element of the array, preserving this, and passing the index.
[ "Applies", "the", "given", "function", "to", "each", "element", "of", "the", "array", "preserving", "this", "and", "passing", "the", "index", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/xpath/util.js#L180-L184
386
SeleniumHQ/selenium
javascript/selenium-core/xpath/util.js
mapExpr
function mapExpr(array, func) { var ret = []; for (var i = 0; i < array.length; ++i) { ret.push(func(array[i])); } return ret; }
javascript
function mapExpr(array, func) { var ret = []; for (var i = 0; i < array.length; ++i) { ret.push(func(array[i])); } return ret; }
[ "function", "mapExpr", "(", "array", ",", "func", ")", "{", "var", "ret", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "array", ".", "length", ";", "++", "i", ")", "{", "ret", ".", "push", "(", "func", "(", "array", "[", "i", "]", ")", ")", ";", "}", "return", "ret", ";", "}" ]
Returns an array that contains the return value of the given function applied to every element of the input array.
[ "Returns", "an", "array", "that", "contains", "the", "return", "value", "of", "the", "given", "function", "applied", "to", "every", "element", "of", "the", "input", "array", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/xpath/util.js#L188-L194
387
SeleniumHQ/selenium
javascript/selenium-core/xpath/util.js
reverseInplace
function reverseInplace(array) { for (var i = 0; i < array.length / 2; ++i) { var h = array[i]; var ii = array.length - i - 1; array[i] = array[ii]; array[ii] = h; } }
javascript
function reverseInplace(array) { for (var i = 0; i < array.length / 2; ++i) { var h = array[i]; var ii = array.length - i - 1; array[i] = array[ii]; array[ii] = h; } }
[ "function", "reverseInplace", "(", "array", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "array", ".", "length", "/", "2", ";", "++", "i", ")", "{", "var", "h", "=", "array", "[", "i", "]", ";", "var", "ii", "=", "array", ".", "length", "-", "i", "-", "1", ";", "array", "[", "i", "]", "=", "array", "[", "ii", "]", ";", "array", "[", "ii", "]", "=", "h", ";", "}", "}" ]
Reverses the given array in place.
[ "Reverses", "the", "given", "array", "in", "place", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/xpath/util.js#L197-L204
388
SeleniumHQ/selenium
javascript/selenium-core/xpath/util.js
copyArray
function copyArray(dst, src) { if (!src) return; var dstLength = dst.length; for (var i = src.length - 1; i >= 0; --i) { dst[i+dstLength] = src[i]; } }
javascript
function copyArray(dst, src) { if (!src) return; var dstLength = dst.length; for (var i = src.length - 1; i >= 0; --i) { dst[i+dstLength] = src[i]; } }
[ "function", "copyArray", "(", "dst", ",", "src", ")", "{", "if", "(", "!", "src", ")", "return", ";", "var", "dstLength", "=", "dst", ".", "length", ";", "for", "(", "var", "i", "=", "src", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "--", "i", ")", "{", "dst", "[", "i", "+", "dstLength", "]", "=", "src", "[", "i", "]", ";", "}", "}" ]
Shallow-copies an array to the end of another array Basically Array.concat, but works with other non-array collections
[ "Shallow", "-", "copies", "an", "array", "to", "the", "end", "of", "another", "array", "Basically", "Array", ".", "concat", "but", "works", "with", "other", "non", "-", "array", "collections" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/xpath/util.js#L221-L227
389
SeleniumHQ/selenium
javascript/selenium-core/xpath/util.js
copyArrayIgnoringAttributesWithoutValue
function copyArrayIgnoringAttributesWithoutValue(dst, src) { if (!src) return; for (var i = src.length - 1; i >= 0; --i) { // this test will pass so long as the attribute has a non-empty string // value, even if that value is "false", "0", "undefined", etc. if (src[i].nodeValue) { dst.push(src[i]); } } }
javascript
function copyArrayIgnoringAttributesWithoutValue(dst, src) { if (!src) return; for (var i = src.length - 1; i >= 0; --i) { // this test will pass so long as the attribute has a non-empty string // value, even if that value is "false", "0", "undefined", etc. if (src[i].nodeValue) { dst.push(src[i]); } } }
[ "function", "copyArrayIgnoringAttributesWithoutValue", "(", "dst", ",", "src", ")", "{", "if", "(", "!", "src", ")", "return", ";", "for", "(", "var", "i", "=", "src", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "--", "i", ")", "{", "// this test will pass so long as the attribute has a non-empty string", "// value, even if that value is \"false\", \"0\", \"undefined\", etc.", "if", "(", "src", "[", "i", "]", ".", "nodeValue", ")", "{", "dst", ".", "push", "(", "src", "[", "i", "]", ")", ";", "}", "}", "}" ]
This is an optimization for copying attribute lists in IE. IE includes many extraneous properties in its DOM attribute lists, which take require significant extra processing when evaluating attribute steps. With this function, we ignore any such attributes that has an empty string value.
[ "This", "is", "an", "optimization", "for", "copying", "attribute", "lists", "in", "IE", ".", "IE", "includes", "many", "extraneous", "properties", "in", "its", "DOM", "attribute", "lists", "which", "take", "require", "significant", "extra", "processing", "when", "evaluating", "attribute", "steps", ".", "With", "this", "function", "we", "ignore", "any", "such", "attributes", "that", "has", "an", "empty", "string", "value", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/xpath/util.js#L235-L245
390
SeleniumHQ/selenium
javascript/selenium-core/xpath/util.js
xmlValue
function xmlValue(node, disallowBrowserSpecificOptimization) { if (!node) { return ''; } var ret = ''; if (node.nodeType == DOM_TEXT_NODE || node.nodeType == DOM_CDATA_SECTION_NODE) { ret += node.nodeValue; } else if (node.nodeType == DOM_ATTRIBUTE_NODE) { if (ajaxsltIsIE6) { ret += xmlValueIE6Hack(node); } else { ret += node.nodeValue; } } else if (node.nodeType == DOM_ELEMENT_NODE || node.nodeType == DOM_DOCUMENT_NODE || node.nodeType == DOM_DOCUMENT_FRAGMENT_NODE) { if (!disallowBrowserSpecificOptimization) { // IE, Safari, Opera, and friends var innerText = node.innerText; if (innerText != undefined) { return innerText; } // Firefox var textContent = node.textContent; if (textContent != undefined) { return textContent; } } // pobrecito! var len = node.childNodes.length; for (var i = 0; i < len; ++i) { ret += arguments.callee(node.childNodes[i]); } } return ret; }
javascript
function xmlValue(node, disallowBrowserSpecificOptimization) { if (!node) { return ''; } var ret = ''; if (node.nodeType == DOM_TEXT_NODE || node.nodeType == DOM_CDATA_SECTION_NODE) { ret += node.nodeValue; } else if (node.nodeType == DOM_ATTRIBUTE_NODE) { if (ajaxsltIsIE6) { ret += xmlValueIE6Hack(node); } else { ret += node.nodeValue; } } else if (node.nodeType == DOM_ELEMENT_NODE || node.nodeType == DOM_DOCUMENT_NODE || node.nodeType == DOM_DOCUMENT_FRAGMENT_NODE) { if (!disallowBrowserSpecificOptimization) { // IE, Safari, Opera, and friends var innerText = node.innerText; if (innerText != undefined) { return innerText; } // Firefox var textContent = node.textContent; if (textContent != undefined) { return textContent; } } // pobrecito! var len = node.childNodes.length; for (var i = 0; i < len; ++i) { ret += arguments.callee(node.childNodes[i]); } } return ret; }
[ "function", "xmlValue", "(", "node", ",", "disallowBrowserSpecificOptimization", ")", "{", "if", "(", "!", "node", ")", "{", "return", "''", ";", "}", "var", "ret", "=", "''", ";", "if", "(", "node", ".", "nodeType", "==", "DOM_TEXT_NODE", "||", "node", ".", "nodeType", "==", "DOM_CDATA_SECTION_NODE", ")", "{", "ret", "+=", "node", ".", "nodeValue", ";", "}", "else", "if", "(", "node", ".", "nodeType", "==", "DOM_ATTRIBUTE_NODE", ")", "{", "if", "(", "ajaxsltIsIE6", ")", "{", "ret", "+=", "xmlValueIE6Hack", "(", "node", ")", ";", "}", "else", "{", "ret", "+=", "node", ".", "nodeValue", ";", "}", "}", "else", "if", "(", "node", ".", "nodeType", "==", "DOM_ELEMENT_NODE", "||", "node", ".", "nodeType", "==", "DOM_DOCUMENT_NODE", "||", "node", ".", "nodeType", "==", "DOM_DOCUMENT_FRAGMENT_NODE", ")", "{", "if", "(", "!", "disallowBrowserSpecificOptimization", ")", "{", "// IE, Safari, Opera, and friends", "var", "innerText", "=", "node", ".", "innerText", ";", "if", "(", "innerText", "!=", "undefined", ")", "{", "return", "innerText", ";", "}", "// Firefox", "var", "textContent", "=", "node", ".", "textContent", ";", "if", "(", "textContent", "!=", "undefined", ")", "{", "return", "textContent", ";", "}", "}", "// pobrecito!", "var", "len", "=", "node", ".", "childNodes", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "len", ";", "++", "i", ")", "{", "ret", "+=", "arguments", ".", "callee", "(", "node", ".", "childNodes", "[", "i", "]", ")", ";", "}", "}", "return", "ret", ";", "}" ]
Returns the text value of a node; for nodes without children this is the nodeValue, for nodes with children this is the concatenation of the value of all children. Browser-specific optimizations are used by default; they can be disabled by passing "true" in as the second parameter.
[ "Returns", "the", "text", "value", "of", "a", "node", ";", "for", "nodes", "without", "children", "this", "is", "the", "nodeValue", "for", "nodes", "with", "children", "this", "is", "the", "concatenation", "of", "the", "value", "of", "all", "children", ".", "Browser", "-", "specific", "optimizations", "are", "used", "by", "default", ";", "they", "can", "be", "disabled", "by", "passing", "true", "in", "as", "the", "second", "parameter", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/xpath/util.js#L251-L289
391
SeleniumHQ/selenium
javascript/selenium-core/xpath/util.js
xmlText
function xmlText(node, opt_cdata) { var buf = []; xmlTextR(node, buf, opt_cdata); return buf.join(''); }
javascript
function xmlText(node, opt_cdata) { var buf = []; xmlTextR(node, buf, opt_cdata); return buf.join(''); }
[ "function", "xmlText", "(", "node", ",", "opt_cdata", ")", "{", "var", "buf", "=", "[", "]", ";", "xmlTextR", "(", "node", ",", "buf", ",", "opt_cdata", ")", ";", "return", "buf", ".", "join", "(", "''", ")", ";", "}" ]
Returns the representation of a node as XML text.
[ "Returns", "the", "representation", "of", "a", "node", "as", "XML", "text", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/xpath/util.js#L302-L306
392
SeleniumHQ/selenium
javascript/selenium-core/xpath/util.js
predicateExprHasPositionalSelector
function predicateExprHasPositionalSelector(expr, isRecursiveCall) { if (!expr) { return false; } if (!isRecursiveCall && exprReturnsNumberValue(expr)) { // this is a "proximity position"-based predicate return true; } if (expr instanceof FunctionCallExpr) { var value = expr.name.value; return (value == 'last' || value == 'position'); } if (expr instanceof BinaryExpr) { return ( predicateExprHasPositionalSelector(expr.expr1, true) || predicateExprHasPositionalSelector(expr.expr2, true)); } return false; }
javascript
function predicateExprHasPositionalSelector(expr, isRecursiveCall) { if (!expr) { return false; } if (!isRecursiveCall && exprReturnsNumberValue(expr)) { // this is a "proximity position"-based predicate return true; } if (expr instanceof FunctionCallExpr) { var value = expr.name.value; return (value == 'last' || value == 'position'); } if (expr instanceof BinaryExpr) { return ( predicateExprHasPositionalSelector(expr.expr1, true) || predicateExprHasPositionalSelector(expr.expr2, true)); } return false; }
[ "function", "predicateExprHasPositionalSelector", "(", "expr", ",", "isRecursiveCall", ")", "{", "if", "(", "!", "expr", ")", "{", "return", "false", ";", "}", "if", "(", "!", "isRecursiveCall", "&&", "exprReturnsNumberValue", "(", "expr", ")", ")", "{", "// this is a \"proximity position\"-based predicate", "return", "true", ";", "}", "if", "(", "expr", "instanceof", "FunctionCallExpr", ")", "{", "var", "value", "=", "expr", ".", "name", ".", "value", ";", "return", "(", "value", "==", "'last'", "||", "value", "==", "'position'", ")", ";", "}", "if", "(", "expr", "instanceof", "BinaryExpr", ")", "{", "return", "(", "predicateExprHasPositionalSelector", "(", "expr", ".", "expr1", ",", "true", ")", "||", "predicateExprHasPositionalSelector", "(", "expr", ".", "expr2", ",", "true", ")", ")", ";", "}", "return", "false", ";", "}" ]
Determines whether a predicate expression contains a "positional selector". A positional selector filters nodes from the nodelist input based on their position within that list. When such selectors are encountered, the evaluation of the predicate cannot be depth-first, because the positional selector may be based on the result of evaluating predicates that precede it.
[ "Determines", "whether", "a", "predicate", "expression", "contains", "a", "positional", "selector", ".", "A", "positional", "selector", "filters", "nodes", "from", "the", "nodelist", "input", "based", "on", "their", "position", "within", "that", "list", ".", "When", "such", "selectors", "are", "encountered", "the", "evaluation", "of", "the", "predicate", "cannot", "be", "depth", "-", "first", "because", "the", "positional", "selector", "may", "be", "based", "on", "the", "result", "of", "evaluating", "predicates", "that", "precede", "it", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/xpath/util.js#L495-L513
393
SeleniumHQ/selenium
third_party/closure/goog/labs/useragent/browser.js
lookUpValueWithKeys
function lookUpValueWithKeys(keys) { var key = goog.array.find(keys, versionMapHasKey); return versionMap[key] || ''; }
javascript
function lookUpValueWithKeys(keys) { var key = goog.array.find(keys, versionMapHasKey); return versionMap[key] || ''; }
[ "function", "lookUpValueWithKeys", "(", "keys", ")", "{", "var", "key", "=", "goog", ".", "array", ".", "find", "(", "keys", ",", "versionMapHasKey", ")", ";", "return", "versionMap", "[", "key", "]", "||", "''", ";", "}" ]
Gives the value with the first key it finds, otherwise empty string.
[ "Gives", "the", "value", "with", "the", "first", "key", "it", "finds", "otherwise", "empty", "string", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/closure/goog/labs/useragent/browser.js#L244-L247
394
SeleniumHQ/selenium
javascript/node/selenium-webdriver/chrome.js
createExecutor
function createExecutor(url) { let agent = new http.Agent({ keepAlive: true }); let client = url.then(url => new http.HttpClient(url, agent)); let executor = new http.Executor(client); configureExecutor(executor); return executor; }
javascript
function createExecutor(url) { let agent = new http.Agent({ keepAlive: true }); let client = url.then(url => new http.HttpClient(url, agent)); let executor = new http.Executor(client); configureExecutor(executor); return executor; }
[ "function", "createExecutor", "(", "url", ")", "{", "let", "agent", "=", "new", "http", ".", "Agent", "(", "{", "keepAlive", ":", "true", "}", ")", ";", "let", "client", "=", "url", ".", "then", "(", "url", "=>", "new", "http", ".", "HttpClient", "(", "url", ",", "agent", ")", ")", ";", "let", "executor", "=", "new", "http", ".", "Executor", "(", "client", ")", ";", "configureExecutor", "(", "executor", ")", ";", "return", "executor", ";", "}" ]
Creates a command executor with support for ChromeDriver's custom commands. @param {!Promise<string>} url The server's URL. @return {!command.Executor} The new command executor.
[ "Creates", "a", "command", "executor", "with", "support", "for", "ChromeDriver", "s", "custom", "commands", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/node/selenium-webdriver/chrome.js#L172-L178
395
SeleniumHQ/selenium
javascript/node/selenium-webdriver/chrome.js
configureExecutor
function configureExecutor(executor) { executor.defineCommand( Command.LAUNCH_APP, 'POST', '/session/:sessionId/chromium/launch_app'); executor.defineCommand( Command.GET_NETWORK_CONDITIONS, 'GET', '/session/:sessionId/chromium/network_conditions'); executor.defineCommand( Command.SET_NETWORK_CONDITIONS, 'POST', '/session/:sessionId/chromium/network_conditions'); executor.defineCommand( Command.SEND_DEVTOOLS_COMMAND, 'POST', '/session/:sessionId/chromium/send_command'); }
javascript
function configureExecutor(executor) { executor.defineCommand( Command.LAUNCH_APP, 'POST', '/session/:sessionId/chromium/launch_app'); executor.defineCommand( Command.GET_NETWORK_CONDITIONS, 'GET', '/session/:sessionId/chromium/network_conditions'); executor.defineCommand( Command.SET_NETWORK_CONDITIONS, 'POST', '/session/:sessionId/chromium/network_conditions'); executor.defineCommand( Command.SEND_DEVTOOLS_COMMAND, 'POST', '/session/:sessionId/chromium/send_command'); }
[ "function", "configureExecutor", "(", "executor", ")", "{", "executor", ".", "defineCommand", "(", "Command", ".", "LAUNCH_APP", ",", "'POST'", ",", "'/session/:sessionId/chromium/launch_app'", ")", ";", "executor", ".", "defineCommand", "(", "Command", ".", "GET_NETWORK_CONDITIONS", ",", "'GET'", ",", "'/session/:sessionId/chromium/network_conditions'", ")", ";", "executor", ".", "defineCommand", "(", "Command", ".", "SET_NETWORK_CONDITIONS", ",", "'POST'", ",", "'/session/:sessionId/chromium/network_conditions'", ")", ";", "executor", ".", "defineCommand", "(", "Command", ".", "SEND_DEVTOOLS_COMMAND", ",", "'POST'", ",", "'/session/:sessionId/chromium/send_command'", ")", ";", "}" ]
Configures the given executor with Chrome-specific commands. @param {!http.Executor} executor the executor to configure.
[ "Configures", "the", "given", "executor", "with", "Chrome", "-", "specific", "commands", "." ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/node/selenium-webdriver/chrome.js#L185-L202
396
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_open
function addonsManager_open(aSpec) { var spec = aSpec || { }; var type = (spec.type == undefined) ? "menu" : spec.type; var waitFor = (spec.waitFor == undefined) ? true : spec.waitFor; switch (type) { case "menu": var menuItem = new elementslib.Elem(this._controller. menus["tools-menu"].menu_openAddons); this._controller.click(menuItem); break; case "shortcut": var cmdKey = utils.getEntity(this.dtds, "addons.commandkey"); this._controller.keypress(null, cmdKey, {accelKey: true, shiftKey: true}); break; default: throw new Error(arguments.callee.name + ": Unknown event type - " + event.type); } return waitFor ? this.waitForOpened() : null; }
javascript
function addonsManager_open(aSpec) { var spec = aSpec || { }; var type = (spec.type == undefined) ? "menu" : spec.type; var waitFor = (spec.waitFor == undefined) ? true : spec.waitFor; switch (type) { case "menu": var menuItem = new elementslib.Elem(this._controller. menus["tools-menu"].menu_openAddons); this._controller.click(menuItem); break; case "shortcut": var cmdKey = utils.getEntity(this.dtds, "addons.commandkey"); this._controller.keypress(null, cmdKey, {accelKey: true, shiftKey: true}); break; default: throw new Error(arguments.callee.name + ": Unknown event type - " + event.type); } return waitFor ? this.waitForOpened() : null; }
[ "function", "addonsManager_open", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "type", "=", "(", "spec", ".", "type", "==", "undefined", ")", "?", "\"menu\"", ":", "spec", ".", "type", ";", "var", "waitFor", "=", "(", "spec", ".", "waitFor", "==", "undefined", ")", "?", "true", ":", "spec", ".", "waitFor", ";", "switch", "(", "type", ")", "{", "case", "\"menu\"", ":", "var", "menuItem", "=", "new", "elementslib", ".", "Elem", "(", "this", ".", "_controller", ".", "menus", "[", "\"tools-menu\"", "]", ".", "menu_openAddons", ")", ";", "this", ".", "_controller", ".", "click", "(", "menuItem", ")", ";", "break", ";", "case", "\"shortcut\"", ":", "var", "cmdKey", "=", "utils", ".", "getEntity", "(", "this", ".", "dtds", ",", "\"addons.commandkey\"", ")", ";", "this", ".", "_controller", ".", "keypress", "(", "null", ",", "cmdKey", ",", "{", "accelKey", ":", "true", ",", "shiftKey", ":", "true", "}", ")", ";", "break", ";", "default", ":", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Unknown event type - \"", "+", "event", ".", "type", ")", ";", "}", "return", "waitFor", "?", "this", ".", "waitForOpened", "(", ")", ":", "null", ";", "}" ]
Open the Add-ons Manager @param {object} aSpec Information how to open the Add-ons Manager Elements: type - Event, can be menu, or shortcut [optional - default: menu] waitFor - Wait until the Add-ons Manager has been opened [optional - default: true] @returns Reference the tab with the Add-ons Manager open @type {object} Elements: controller - Mozmill Controller of the window index - Index of the tab
[ "Open", "the", "Add", "-", "ons", "Manager" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L131-L152
397
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_waitforOpened
function addonsManager_waitforOpened(aSpec) { var spec = aSpec || { }; var timeout = (spec.timeout == undefined) ? TIMEOUT : spec.timeout; // TODO: restore after 1.5.1 has landed // var self = this; // // mozmill.utils.waitFor(function() { // return self.isOpen; // }, timeout, 100, "Add-ons Manager has been opened"); mozmill.utils.waitForEval("subject.isOpen", timeout, 100, this); // The first tab found will be the selected one var tab = this.getTabs()[0]; tab.controller.waitForPageLoad(); return tab; }
javascript
function addonsManager_waitforOpened(aSpec) { var spec = aSpec || { }; var timeout = (spec.timeout == undefined) ? TIMEOUT : spec.timeout; // TODO: restore after 1.5.1 has landed // var self = this; // // mozmill.utils.waitFor(function() { // return self.isOpen; // }, timeout, 100, "Add-ons Manager has been opened"); mozmill.utils.waitForEval("subject.isOpen", timeout, 100, this); // The first tab found will be the selected one var tab = this.getTabs()[0]; tab.controller.waitForPageLoad(); return tab; }
[ "function", "addonsManager_waitforOpened", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "timeout", "=", "(", "spec", ".", "timeout", "==", "undefined", ")", "?", "TIMEOUT", ":", "spec", ".", "timeout", ";", "// TODO: restore after 1.5.1 has landed", "// var self = this;", "//", "// mozmill.utils.waitFor(function() {", "// return self.isOpen;", "// }, timeout, 100, \"Add-ons Manager has been opened\");", "mozmill", ".", "utils", ".", "waitForEval", "(", "\"subject.isOpen\"", ",", "timeout", ",", "100", ",", "this", ")", ";", "// The first tab found will be the selected one", "var", "tab", "=", "this", ".", "getTabs", "(", ")", "[", "0", "]", ";", "tab", ".", "controller", ".", "waitForPageLoad", "(", ")", ";", "return", "tab", ";", "}" ]
Waits until the Addons Manager has been opened and returns its controller @param {object} aSpec Object with parameters for customization Elements: timeout - Duration to wait for the target state [optional - default: 5s] @returns Currently selected tab
[ "Waits", "until", "the", "Addons", "Manager", "has", "been", "opened", "and", "returns", "its", "controller" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L174-L192
398
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_handleUtilsButton
function addonsManager_handleUtilsButton(aSpec) { var spec = aSpec || { }; var item = spec.item; if (!item) throw new Error(arguments.callee.name + ": Menu item not specified."); var button = this.getElement({type: "utilsButton"}); var menu = this.getElement({type: "utilsButton_menu"}); try { this._controller.click(button); // Click the button and wait until menu has been opened // TODO: restore after 1.5.1 has landed // mozmill.utils.waitFor(function() { // return menu.getNode() && menu.getNode().state == "open"; // }, TIMEOUT, 100, "Menu of utils button has been opened."); mozmill.utils.waitForEval("subject && subject.state == 'open'", TIMEOUT, 100, menu.getNode()); // Click the given menu entry and make sure the var menuItem = this.getElement({ type: "utilsButton_menuItem", value: "#utils-" + item }); this._controller.click(menuItem); } finally { // Make sure the menu has been closed this._controller.keypress(menu, "VK_ESCAPE", {}); // TODO: restore after 1.5.1 has landed // mozmill.utils.waitFor(function() { // return menu.getNode() && menu.getNode().state == "closed"; // }, TIMEOUT, 100, "Menu of utils button has been closed."); mozmill.utils.waitForEval("subject && subject.state == 'closed'", TIMEOUT, 100, menu.getNode()); } }
javascript
function addonsManager_handleUtilsButton(aSpec) { var spec = aSpec || { }; var item = spec.item; if (!item) throw new Error(arguments.callee.name + ": Menu item not specified."); var button = this.getElement({type: "utilsButton"}); var menu = this.getElement({type: "utilsButton_menu"}); try { this._controller.click(button); // Click the button and wait until menu has been opened // TODO: restore after 1.5.1 has landed // mozmill.utils.waitFor(function() { // return menu.getNode() && menu.getNode().state == "open"; // }, TIMEOUT, 100, "Menu of utils button has been opened."); mozmill.utils.waitForEval("subject && subject.state == 'open'", TIMEOUT, 100, menu.getNode()); // Click the given menu entry and make sure the var menuItem = this.getElement({ type: "utilsButton_menuItem", value: "#utils-" + item }); this._controller.click(menuItem); } finally { // Make sure the menu has been closed this._controller.keypress(menu, "VK_ESCAPE", {}); // TODO: restore after 1.5.1 has landed // mozmill.utils.waitFor(function() { // return menu.getNode() && menu.getNode().state == "closed"; // }, TIMEOUT, 100, "Menu of utils button has been closed."); mozmill.utils.waitForEval("subject && subject.state == 'closed'", TIMEOUT, 100, menu.getNode()); } }
[ "function", "addonsManager_handleUtilsButton", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "item", "=", "spec", ".", "item", ";", "if", "(", "!", "item", ")", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Menu item not specified.\"", ")", ";", "var", "button", "=", "this", ".", "getElement", "(", "{", "type", ":", "\"utilsButton\"", "}", ")", ";", "var", "menu", "=", "this", ".", "getElement", "(", "{", "type", ":", "\"utilsButton_menu\"", "}", ")", ";", "try", "{", "this", ".", "_controller", ".", "click", "(", "button", ")", ";", "// Click the button and wait until menu has been opened", "// TODO: restore after 1.5.1 has landed", "// mozmill.utils.waitFor(function() {", "// return menu.getNode() && menu.getNode().state == \"open\";", "// }, TIMEOUT, 100, \"Menu of utils button has been opened.\");", "mozmill", ".", "utils", ".", "waitForEval", "(", "\"subject && subject.state == 'open'\"", ",", "TIMEOUT", ",", "100", ",", "menu", ".", "getNode", "(", ")", ")", ";", "// Click the given menu entry and make sure the ", "var", "menuItem", "=", "this", ".", "getElement", "(", "{", "type", ":", "\"utilsButton_menuItem\"", ",", "value", ":", "\"#utils-\"", "+", "item", "}", ")", ";", "this", ".", "_controller", ".", "click", "(", "menuItem", ")", ";", "}", "finally", "{", "// Make sure the menu has been closed", "this", ".", "_controller", ".", "keypress", "(", "menu", ",", "\"VK_ESCAPE\"", ",", "{", "}", ")", ";", "// TODO: restore after 1.5.1 has landed", "// mozmill.utils.waitFor(function() {", "// return menu.getNode() && menu.getNode().state == \"closed\";", "// }, TIMEOUT, 100, \"Menu of utils button has been closed.\");", "mozmill", ".", "utils", ".", "waitForEval", "(", "\"subject && subject.state == 'closed'\"", ",", "TIMEOUT", ",", "100", ",", "menu", ".", "getNode", "(", ")", ")", ";", "}", "}" ]
Opens the utils button menu and clicks the specified menu entry @param {object} aSpec Information about the menu Elements: item - menu item to click (updateNow, viewUpdates, installFromFile, autoUpdateDefault, resetAddonUpdatesToAutomatic, resetAddonUpdatesToManual)
[ "Opens", "the", "utils", "button", "menu", "and", "clicks", "the", "specified", "menu", "entry" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L227-L269
399
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_enableAddon
function addonsManager_enableAddon(aSpec) { var spec = aSpec || { }; spec.button = "enable"; var button = this.getAddonButton(spec); this._controller.click(button); }
javascript
function addonsManager_enableAddon(aSpec) { var spec = aSpec || { }; spec.button = "enable"; var button = this.getAddonButton(spec); this._controller.click(button); }
[ "function", "addonsManager_enableAddon", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "spec", ".", "button", "=", "\"enable\"", ";", "var", "button", "=", "this", ".", "getAddonButton", "(", "spec", ")", ";", "this", ".", "_controller", ".", "click", "(", "button", ")", ";", "}" ]
Enables the specified add-on @param {object} aSpec Information on which add-on to operate on Elements: addon - Add-on element
[ "Enables", "the", "specified", "add", "-", "on" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L346-L352