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
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
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
train
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
train
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
train
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
train
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'", "]", "}", ")", ".", "then", "(", "console", ".", "log", ",", "console", ".", "error", ")", "}" ]
robodog.modal
[ "robodog", ".", "modal" ]
7ae18bf992d544a64da998f033258ec09a3de275
https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/examples/transloadit/main.js#L81-L99
train
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", ")", "{", "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
train
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", ")", "{", "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
train
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", ")", "{", "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", ")", "{", "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
train
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", ")", "{", "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
train
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", ")", "{", "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
train
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", ")", "{", "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
train
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", ";", "controller", ".", "open", "(", "targetUrl", ")", ";", "controller", ".", "waitForPageLoad", "(", ")", ";", "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
train
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
train
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
train
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
train
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
train
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
train
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", ")", "{", "urls", ".", "push", "(", "\"resource:///res/dtd/xhtml11.dtd\"", ")", ";", "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
train
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
train
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", ")", "{", "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", "{", "mozmill", ".", "utils", ".", "waitFor", "(", "function", "(", ")", "{", "window", "=", "func_ptr", "(", "text", ")", ";", "return", "window", "!=", "null", ";", "}", ",", "\"Window has been found.\"", ")", ";", "controller", "=", "new", "mozmill", ".", "controller", ".", "MozMillController", "(", "window", ")", ";", "controller", ".", "sleep", "(", "200", ")", ";", "if", "(", "callback", ")", "{", "callback", "(", "controller", ")", ";", "}", "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
train
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
train
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
train
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
train
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", "(", ")", "{", "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
train
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
train
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", "(", ")", "{", "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
train
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
train
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
train
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
train
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.\"", ")", ";", "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
train
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
train
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
train
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
train
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
train
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", ")", "{", "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
train
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", "(", ")", "{", "this", ".", "jsonStreamParser_", "=", "null", ";", "this", ".", "errorMessage_", "=", "null", ";", "this", ".", "streamPos_", "=", "0", ";", "this", ".", "state_", "=", "State", ".", "INIT", ";", "this", ".", "result_", "=", "[", "]", ";", "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
train
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
train
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
train
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", "(", ")", "{", "var", "window", "=", "domUtils", ".", "unwrapNode", "(", "mozmill", ".", "wm", ".", "getMostRecentWindow", "(", "''", ")", ")", ";", "var", "chrome", "=", "window", ".", "QueryInterface", "(", "Ci", ".", "nsIInterfaceRequestor", ")", ".", "getInterface", "(", "Ci", ".", "nsIWebNavigation", ")", ".", "QueryInterface", "(", "Ci", ".", "nsIDocShellTreeItem", ")", ".", "treeOwner", ".", "QueryInterface", "(", "Ci", ".", "nsIInterfaceRequestor", ")", ".", "getInterface", "(", "Ci", ".", "nsIWebBrowserChrome", ")", ";", "if", "(", "!", "chrome", ".", "isWindowModal", "(", ")", ")", "{", "return", "null", ";", "}", "var", "found", "=", "false", ";", "if", "(", "window", ".", "opener", ")", "{", "var", "opener", "=", "domUtils", ".", "unwrapNode", "(", "window", ".", "opener", ")", ";", "found", "=", "(", "mozmill", ".", "utils", ".", "getChromeWindow", "(", "opener", ")", "==", "this", ".", "_opener", ")", ";", "}", "else", "{", "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
train
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", ")", "{", "var", "window", "=", "this", ".", "findWindow", "(", ")", ";", "if", "(", "window", "&&", "(", "\"documentLoaded\"", "in", "window", ")", ")", "{", "try", "{", "this", ".", "_callback", "(", "new", "mozmill", ".", "controller", ".", "MozMillController", "(", "window", ")", ")", ";", "}", "catch", "(", "ex", ")", "{", "this", ".", "exception", "=", "ex", ";", "}", "if", "(", "window", ")", "{", "window", ".", "close", "(", ")", ";", "}", "this", ".", "finished", "=", "true", ";", "this", ".", "stop", "(", ")", ";", "}", "else", "{", "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
train
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
train
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", ")", ";", "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
train
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
train
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
train
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
train
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", ")", "{", "this", ".", "validate", "=", "function", "(", "uiArgumentShorthand", ")", "{", "var", "msg", "=", "\"UIArgument validation error:\\n\"", "+", "\\n", ";", "print_r", "(", "uiArgumentShorthand", ")", "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!'", ")", ";", "}", "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", "]", ";", "}", "}", "}" ]
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
train
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", ")", "{", "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", "]", ")", ":", "{", "}", ";", "}", ";", "this", ".", "toString", "=", "function", "(", ")", "{", "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", "{", "var", "kwargs", "=", "to_kwargs", "(", "this", ".", "args", ")", ";", "}", "return", "this", ".", "pagesetName", "+", "'::'", "+", "this", ".", "elementName", "+", "'('", "+", "kwargs", "+", "')'", ";", "}", ";", "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
train
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", "(", ")", "{", "UIMap", ".", "self", "=", "this", ";", "if", "(", "is_IDE", "(", ")", ")", "{", "Editor", ".", "uiMap", "=", "this", ";", "Editor", ".", "UI_PREFIX", "=", "UI_GLOBAL", ".", "UI_PREFIX", ";", "}", "this", ".", "pagesets", "=", "new", "Object", "(", ")", ";", "this", ".", "addPageset", "=", "function", "(", "pagesetShorthand", ")", "{", "try", "{", "var", "pageset", "=", "new", "Pageset", "(", "pagesetShorthand", ")", ";", "}", "catch", "(", "e", ")", "{", "safe_alert", "(", "\"Could not create pageset from shorthand:\\n\"", "+", "\\n", "+", "print_r", "(", "pagesetShorthand", ")", "+", "\"\\n\"", ")", ";", "\\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", ";", "this", ".", "addElement", "=", "function", "(", "pagesetName", ",", "uiElementShorthand", ")", "{", "try", "{", "var", "uiElement", "=", "new", "UIElement", "(", "uiElementShorthand", ")", ";", "}", "catch", "(", "e", ")", "{", "safe_alert", "(", "\"Could not create UI element from shorthand:\\n\"", "+", "\\n", "+", "print_r", "(", "uiElementShorthand", ")", "+", "\"\\n\"", ")", ";", "\\n", "}", "e", ".", "message", "return", "false", ";", "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\"", "+", "\\n", ")", ";", "e", ".", "message", "}", "return", "false", ";", "return", "true", ";", "this", ".", "getPageset", "=", "function", "(", "uiSpecifierString", ")", "{", "try", "{", "var", "uiSpecifier", "=", "new", "UISpecifier", "(", "uiSpecifierString", ")", ";", "return", "this", ".", "pagesets", "[", "uiSpecifier", ".", "pagesetName", "]", ";", "}", "catch", "(", "e", ")", "{", "return", "null", ";", "}", "}", "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", ";", "}", "}", ";", "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", ";", "}", ";", "}" ]
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
train
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", "(", ")", "{", "var", "downloads", "=", "this", ".", "_dms", ".", "activeDownloads", ";", "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
train
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", ")", "{", "this", ".", "cancelActiveDownloads", "(", ")", ";", "if", "(", "downloads", "===", "undefined", "||", "downloads", ".", "length", "==", "0", ")", "downloads", "=", "this", ".", "getAllDownloads", "(", ")", ";", "else", "downloads", "=", "downloads", ".", "concat", "(", "this", ".", "getAllDownloads", "(", ")", ")", ";", "this", ".", "deleteDownloadedFiles", "(", "downloads", ")", ";", "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
train
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", ")", "{", "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
train
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
train
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", "(", ")", ";", "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
train
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
train
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
train
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", ")", ";", "controller", ".", "waitForEval", "(", "\"subject.getMostRecentWindow('').document.documentElement.id == 'unknownContentType'\"", ",", "gTimeout", ",", "100", ",", "mozmill", ".", "wm", ")", ";", "utils", ".", "handleWindow", "(", "\"type\"", ",", "\"\"", ",", "function", "(", "controller", ")", "{", "var", "saveFile", "=", "new", "elementslib", ".", "ID", "(", "controller", ".", "window", ".", "document", ",", "\"save\"", ")", ";", "controller", ".", "waitThenClick", "(", "saveFile", ",", "gTimeout", ")", ";", "controller", ".", "waitForEval", "(", "\"subject.selected == true\"", ",", "gTimeout", ",", "100", ",", "saveFile", ".", "getNode", "(", ")", ")", ";", "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
train
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://\"", ")", "{", "let", "ioSvc", "=", "Cc", "[", "\"@mozilla.org/network/io-service;1\"", "]", ".", "getService", "(", "Ci", ".", "nsIIOService", ")", ";", "const", "fileUrl", "=", "ioSvc", ".", "newURI", "(", "aPathOrUrl", ",", "null", ",", "null", ")", ".", "QueryInterface", "(", "Ci", ".", "nsIFileURL", ")", ";", "return", "fileUrl", ".", "file", ".", "clone", "(", ")", ".", "QueryInterface", "(", "Ci", ".", "nsILocalFile", ")", ";", "}", "else", "{", "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
train
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
train
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
train
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'", ")", ";", "\\n", "}", "else", "result", ".", "push", "(", "wrapStr", "(", "helpMsg", ",", "TOTAL_WIDTH", ",", "repeatStr", "(", "' '", ",", "HELP_TEXT_POSITION", ")", ")", ".", "join", "(", "'\\n'", ")", ")", ";", "\\n", "}" ]
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
train
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", ")", "{", "var", "accessKeysList", "=", "accessKeysSet", ".", "sort", "(", ")", ";", "var", "aKeysList", "=", "[", "]", ";", "var", "valueList", "=", "[", "]", ";", "var", "rects", "=", "[", "]", ";", "var", "badRects", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "accessKeysList", ".", "length", ";", "i", "++", ")", "{", "var", "accessKey", "=", "accessKeysList", "[", "i", "]", "[", "0", "]", ";", "var", "node", "=", "accessKeysList", "[", "i", "]", "[", "1", "]", ";", "var", "id", "=", "node", ".", "id", "||", "\"(id is undefined)\"", ";", "var", "label", "=", "node", ".", "label", "||", "\"(label is undefined)\"", ";", "var", "box", "=", "node", ".", "boxObject", ";", "var", "innerIds", "=", "[", "]", ";", "var", "innerRects", "=", "[", "]", ";", "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", ")", ";", "}", "for", "(", "var", "i", "=", "0", ";", "i", "<", "valueList", ".", "length", ";", "i", "++", ")", "{", "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", "(", "\", \"", ")", "}" ]
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
train
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", ";", "if", "(", "!", "parent", "||", "parent", "==", "child", ".", "element", "||", "!", "parent", ".", "boxObject", ")", "{", "return", "[", "]", ";", "}", "var", "parentBox", "=", "parent", ".", "boxObject", ";", "var", "badRects", "=", "[", "]", ";", "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", ")", ")", ";", "}", "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
train
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", ")", "{", "var", "notAllowedLocalNames", "=", "[", "\"menu\"", ",", "\"menubar\"", ",", "\"menupopup\"", ",", "\"popupset\"", "]", ";", "if", "(", "!", "node", ".", "disabled", "&&", "!", "node", ".", "collapsed", "&&", "!", "node", ".", "hidden", "&&", "notAllowedLocalNames", ".", "indexOf", "(", "node", ".", "localName", ")", "==", "-", "1", ")", "{", "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", ";", "}", "else", "if", "(", "node", ".", "accessKey", ")", "{", "return", "domUtils", ".", "DOMWalker", ".", "FILTER_ACCEPT", ";", "}", "else", "{", "return", "domUtils", ".", "DOMWalker", ".", "FILTER_SKIP", ";", "}", "}", "else", "{", "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
train
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", ")", "{", "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", ";", "}", "else", "{", "return", "domUtils", ".", "DOMWalker", ".", "FILTER_ACCEPT", ";", "}", "}", "else", "{", "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
train
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
train
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
train
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
train
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
train
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
train
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
train
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", ")", "{", "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
train
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", ")", "{", "var", "innerText", "=", "node", ".", "innerText", ";", "if", "(", "innerText", "!=", "undefined", ")", "{", "return", "innerText", ";", "}", "var", "textContent", "=", "node", ".", "textContent", ";", "if", "(", "textContent", "!=", "undefined", ")", "{", "return", "textContent", ";", "}", "}", "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
train
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
train
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", ")", ")", "{", "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
train
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
train
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
train
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
train
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
train
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", ";", "mozmill", ".", "utils", ".", "waitForEval", "(", "\"subject.isOpen\"", ",", "timeout", ",", "100", ",", "this", ")", ";", "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
train
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", ")", ";", "mozmill", ".", "utils", ".", "waitForEval", "(", "\"subject && subject.state == 'open'\"", ",", "TIMEOUT", ",", "100", ",", "menu", ".", "getNode", "(", ")", ")", ";", "var", "menuItem", "=", "this", ".", "getElement", "(", "{", "type", ":", "\"utilsButton_menuItem\"", ",", "value", ":", "\"#utils-\"", "+", "item", "}", ")", ";", "this", ".", "_controller", ".", "click", "(", "menuItem", ")", ";", "}", "finally", "{", "this", ".", "_controller", ".", "keypress", "(", "menu", ",", "\"VK_ESCAPE\"", ",", "{", "}", ")", ";", "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
train
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
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_disableAddon
function addonsManager_disableAddon(aSpec) { var spec = aSpec || { }; spec.button = "disable"; var button = this.getAddonButton(spec); this._controller.click(button); }
javascript
function addonsManager_disableAddon(aSpec) { var spec = aSpec || { }; spec.button = "disable"; var button = this.getAddonButton(spec); this._controller.click(button); }
[ "function", "addonsManager_disableAddon", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "spec", ".", "button", "=", "\"disable\"", ";", "var", "button", "=", "this", ".", "getAddonButton", "(", "spec", ")", ";", "this", ".", "_controller", ".", "click", "(", "button", ")", ";", "}" ]
Disables the specified add-on @param {object} aSpec Information on which add-on to operate on Elements: addon - Add-on element
[ "Disables", "the", "specified", "add", "-", "on" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L361-L367
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_installAddon
function addonsManager_installAddon(aSpec) { var spec = aSpec || { }; var addon = spec.addon; var timeout = spec.timeout; var button = "install"; var waitFor = (spec.waitFor == undefined) ? true : spec.waitFor; var button = this.getAddonButton({addon: addon, button: button}); this._controller.click(button); if (waitFor) this.waitForDownloaded({addon: addon, timeout: timeout}); }
javascript
function addonsManager_installAddon(aSpec) { var spec = aSpec || { }; var addon = spec.addon; var timeout = spec.timeout; var button = "install"; var waitFor = (spec.waitFor == undefined) ? true : spec.waitFor; var button = this.getAddonButton({addon: addon, button: button}); this._controller.click(button); if (waitFor) this.waitForDownloaded({addon: addon, timeout: timeout}); }
[ "function", "addonsManager_installAddon", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "addon", "=", "spec", ".", "addon", ";", "var", "timeout", "=", "spec", ".", "timeout", ";", "var", "button", "=", "\"install\"", ";", "var", "waitFor", "=", "(", "spec", ".", "waitFor", "==", "undefined", ")", "?", "true", ":", "spec", ".", "waitFor", ";", "var", "button", "=", "this", ".", "getAddonButton", "(", "{", "addon", ":", "addon", ",", "button", ":", "button", "}", ")", ";", "this", ".", "_controller", ".", "click", "(", "button", ")", ";", "if", "(", "waitFor", ")", "this", ".", "waitForDownloaded", "(", "{", "addon", ":", "addon", ",", "timeout", ":", "timeout", "}", ")", ";", "}" ]
Installs the specified add-on @param {object} aSpec Information on which add-on to operate on Elements: addon - Add-on element waitFor - Wait until the category has been selected [optional - default: true] timeout - Duration to wait for the download [optional - default: 15s]
[ "Installs", "the", "specified", "add", "-", "on" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L380-L392
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_removeAddon
function addonsManager_removeAddon(aSpec) { var spec = aSpec || { }; spec.button = "remove"; var button = this.getAddonButton(spec); this._controller.click(button); }
javascript
function addonsManager_removeAddon(aSpec) { var spec = aSpec || { }; spec.button = "remove"; var button = this.getAddonButton(spec); this._controller.click(button); }
[ "function", "addonsManager_removeAddon", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "spec", ".", "button", "=", "\"remove\"", ";", "var", "button", "=", "this", ".", "getAddonButton", "(", "spec", ")", ";", "this", ".", "_controller", ".", "click", "(", "button", ")", ";", "}" ]
Removes the specified add-on @param {object} aSpec Information on which add-on to operate on Elements: addon - Add-on element
[ "Removes", "the", "specified", "add", "-", "on" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L401-L407
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_undo
function addonsManager_undo(aSpec) { var spec = aSpec || { }; spec.link = "undo"; var link = this.getAddonLink(spec); this._controller.click(link); }
javascript
function addonsManager_undo(aSpec) { var spec = aSpec || { }; spec.link = "undo"; var link = this.getAddonLink(spec); this._controller.click(link); }
[ "function", "addonsManager_undo", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "spec", ".", "link", "=", "\"undo\"", ";", "var", "link", "=", "this", ".", "getAddonLink", "(", "spec", ")", ";", "this", ".", "_controller", ".", "click", "(", "link", ")", ";", "}" ]
Undo the last action performed for the given add-on @param {object} aSpec Information on which add-on to operate on Elements: addon - Add-on element
[ "Undo", "the", "last", "action", "performed", "for", "the", "given", "add", "-", "on" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L416-L422
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_addons
function addonsManager_addons(aSpec) { var spec = aSpec || {}; return this.getElements({ type: "addons", subtype: spec.attribute, value: spec.value, parent: this.selectedView }); }
javascript
function addonsManager_addons(aSpec) { var spec = aSpec || {}; return this.getElements({ type: "addons", subtype: spec.attribute, value: spec.value, parent: this.selectedView }); }
[ "function", "addonsManager_addons", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "return", "this", ".", "getElements", "(", "{", "type", ":", "\"addons\"", ",", "subtype", ":", "spec", ".", "attribute", ",", "value", ":", "spec", ".", "value", ",", "parent", ":", "this", ".", "selectedView", "}", ")", ";", "}" ]
Returns the addons from the currently selected view which match the filter criteria @param {object} aSpec Information about the filter to apply Elements: attribute - DOM attribute of the wanted addon [optional - default: ""] value - Value of the DOM attribute [optional - default: ""] @returns List of addons @type {array of ElemBase}
[ "Returns", "the", "addons", "from", "the", "currently", "selected", "view", "which", "match", "the", "filter", "criteria" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L438-L447
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_getAddonButton
function addonsManager_getAddonButton(aSpec) { var spec = aSpec || { }; var addon = spec.addon; var button = spec.button; if (!button) throw new Error(arguments.callee.name + ": Button not specified."); return this.getAddonChildElement({addon: addon, type: button + "Button"}); }
javascript
function addonsManager_getAddonButton(aSpec) { var spec = aSpec || { }; var addon = spec.addon; var button = spec.button; if (!button) throw new Error(arguments.callee.name + ": Button not specified."); return this.getAddonChildElement({addon: addon, type: button + "Button"}); }
[ "function", "addonsManager_getAddonButton", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "addon", "=", "spec", ".", "addon", ";", "var", "button", "=", "spec", ".", "button", ";", "if", "(", "!", "button", ")", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Button not specified.\"", ")", ";", "return", "this", ".", "getAddonChildElement", "(", "{", "addon", ":", "addon", ",", "type", ":", "button", "+", "\"Button\"", "}", ")", ";", "}" ]
Returns the element of the specified add-ons button @param {object} aSpec Information on which add-on to operate on Elements: addon - Add-on element button - Button (disable, enable, preferences, remove) @returns Add-on button @type {ElemBase}
[ "Returns", "the", "element", "of", "the", "specified", "add", "-", "ons", "button" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L460-L469
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_getAddonLink
function addonsManager_getAddonLink(aSpec) { var spec = aSpec || { }; var addon = spec.addon; var link = spec.link; if (!link) throw new Error(arguments.callee.name + ": Link not specified."); return this.getAddonChildElement({addon: addon, type: link + "Link"}); }
javascript
function addonsManager_getAddonLink(aSpec) { var spec = aSpec || { }; var addon = spec.addon; var link = spec.link; if (!link) throw new Error(arguments.callee.name + ": Link not specified."); return this.getAddonChildElement({addon: addon, type: link + "Link"}); }
[ "function", "addonsManager_getAddonLink", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "addon", "=", "spec", ".", "addon", ";", "var", "link", "=", "spec", ".", "link", ";", "if", "(", "!", "link", ")", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Link not specified.\"", ")", ";", "return", "this", ".", "getAddonChildElement", "(", "{", "addon", ":", "addon", ",", "type", ":", "link", "+", "\"Link\"", "}", ")", ";", "}" ]
Returns the element of the specified add-ons link @param {object} aSpec Information on which add-on to operate on Elements: addon - Add-on element link - Link List view (more, restart, undo) Detail view (findUpdates, restart, undo) @return Add-on link @type {ElemBase}
[ "Returns", "the", "element", "of", "the", "specified", "add", "-", "ons", "link" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L484-L493
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_getAddonRadiogroup
function addonsManager_getAddonRadiogroup(aSpec) { var spec = aSpec || { }; var addon = spec.addon; var radiogroup = spec.radiogroup; if (!radiogroup) throw new Error(arguments.callee.name + ": Radiogroup not specified."); return this.getAddonChildElement({addon: addon, type: radiogroup + "Radiogroup"}); }
javascript
function addonsManager_getAddonRadiogroup(aSpec) { var spec = aSpec || { }; var addon = spec.addon; var radiogroup = spec.radiogroup; if (!radiogroup) throw new Error(arguments.callee.name + ": Radiogroup not specified."); return this.getAddonChildElement({addon: addon, type: radiogroup + "Radiogroup"}); }
[ "function", "addonsManager_getAddonRadiogroup", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "addon", "=", "spec", ".", "addon", ";", "var", "radiogroup", "=", "spec", ".", "radiogroup", ";", "if", "(", "!", "radiogroup", ")", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Radiogroup not specified.\"", ")", ";", "return", "this", ".", "getAddonChildElement", "(", "{", "addon", ":", "addon", ",", "type", ":", "radiogroup", "+", "\"Radiogroup\"", "}", ")", ";", "}" ]
Returns the element of the specified add-ons radio group @param {object} aSpec Information on which add-on to operate on Elements: addon - Add-on element radiogroup - Radiogroup Detail View (autoUpdate) @returns Add-on radiogroup @type {ElemBase}
[ "Returns", "the", "element", "of", "the", "specified", "add", "-", "ons", "radio", "group" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L507-L516
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_getAddonChildElement
function addonsManager_getAddonChildElement(aSpec) { var spec = aSpec || { }; var addon = spec.addon; var attribute = spec.attribute; var value = spec.value; var type = spec.type; if (!addon) throw new Error(arguments.callee.name + ": Add-on not specified."); // If no type has been set retrieve a general element which needs an // attribute and value if (!type) { type = "element"; if (!attribute) throw new Error(arguments.callee.name + ": DOM attribute not specified."); if (!value) throw new Error(arguments.callee.name + ": Value not specified."); } // For the details view the elements don't have anonymous nodes if (this.selectedView.getNode().id == "detail-view") { return this.getElement({ type: "detailView_" + type, subtype: attribute, value: value }); } else { return this.getElement({ type: "listView_" + type, subtype: attribute, value: value, parent: addon }); } }
javascript
function addonsManager_getAddonChildElement(aSpec) { var spec = aSpec || { }; var addon = spec.addon; var attribute = spec.attribute; var value = spec.value; var type = spec.type; if (!addon) throw new Error(arguments.callee.name + ": Add-on not specified."); // If no type has been set retrieve a general element which needs an // attribute and value if (!type) { type = "element"; if (!attribute) throw new Error(arguments.callee.name + ": DOM attribute not specified."); if (!value) throw new Error(arguments.callee.name + ": Value not specified."); } // For the details view the elements don't have anonymous nodes if (this.selectedView.getNode().id == "detail-view") { return this.getElement({ type: "detailView_" + type, subtype: attribute, value: value }); } else { return this.getElement({ type: "listView_" + type, subtype: attribute, value: value, parent: addon }); } }
[ "function", "addonsManager_getAddonChildElement", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "addon", "=", "spec", ".", "addon", ";", "var", "attribute", "=", "spec", ".", "attribute", ";", "var", "value", "=", "spec", ".", "value", ";", "var", "type", "=", "spec", ".", "type", ";", "if", "(", "!", "addon", ")", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Add-on not specified.\"", ")", ";", "if", "(", "!", "type", ")", "{", "type", "=", "\"element\"", ";", "if", "(", "!", "attribute", ")", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": DOM attribute not specified.\"", ")", ";", "if", "(", "!", "value", ")", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Value not specified.\"", ")", ";", "}", "if", "(", "this", ".", "selectedView", ".", "getNode", "(", ")", ".", "id", "==", "\"detail-view\"", ")", "{", "return", "this", ".", "getElement", "(", "{", "type", ":", "\"detailView_\"", "+", "type", ",", "subtype", ":", "attribute", ",", "value", ":", "value", "}", ")", ";", "}", "else", "{", "return", "this", ".", "getElement", "(", "{", "type", ":", "\"listView_\"", "+", "type", ",", "subtype", ":", "attribute", ",", "value", ":", "value", ",", "parent", ":", "addon", "}", ")", ";", "}", "}" ]
Retrieve the given child element of the specified add-on @param {object} aSpec Information for getting the add-ons child node Elements: addon - Add-on element type - Type of the element [optional - default: use attribute/value] attribute - DOM attribute of the node value - Value of the DOM attribute @returns Element @type {ElemBase}
[ "Retrieve", "the", "given", "child", "element", "of", "the", "specified", "add", "-", "on" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L532-L568
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_waitForDownloaded
function addonsManager_waitForDownloaded(aSpec) { var spec = aSpec || { }; var addon = spec.addon; var timeout = (spec.timeout == undefined) ? TIMEOUT_DOWNLOAD : spec.timeout; if (!addon) throw new Error(arguments.callee.name + ": Add-on not specified."); var self = this; var node = addon.getNode(); // TODO: restore after 1.5.1 has landed // mozmill.utils.waitFor(function () { // return node.getAttribute("pending") == "install" && // node.getAttribute("status") != "installing"; // }, timeout, 100, "'" + node.getAttribute("name") + "' has been downloaded"); mozmill.utils.waitForEval("subject.getAttribute('pending') == 'install' &&" + "subject.getAttribute('status') != 'installing'", timeout, 100, node); }
javascript
function addonsManager_waitForDownloaded(aSpec) { var spec = aSpec || { }; var addon = spec.addon; var timeout = (spec.timeout == undefined) ? TIMEOUT_DOWNLOAD : spec.timeout; if (!addon) throw new Error(arguments.callee.name + ": Add-on not specified."); var self = this; var node = addon.getNode(); // TODO: restore after 1.5.1 has landed // mozmill.utils.waitFor(function () { // return node.getAttribute("pending") == "install" && // node.getAttribute("status") != "installing"; // }, timeout, 100, "'" + node.getAttribute("name") + "' has been downloaded"); mozmill.utils.waitForEval("subject.getAttribute('pending') == 'install' &&" + "subject.getAttribute('status') != 'installing'", timeout, 100, node); }
[ "function", "addonsManager_waitForDownloaded", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "addon", "=", "spec", ".", "addon", ";", "var", "timeout", "=", "(", "spec", ".", "timeout", "==", "undefined", ")", "?", "TIMEOUT_DOWNLOAD", ":", "spec", ".", "timeout", ";", "if", "(", "!", "addon", ")", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Add-on not specified.\"", ")", ";", "var", "self", "=", "this", ";", "var", "node", "=", "addon", ".", "getNode", "(", ")", ";", "mozmill", ".", "utils", ".", "waitForEval", "(", "\"subject.getAttribute('pending') == 'install' &&\"", "+", "\"subject.getAttribute('status') != 'installing'\"", ",", "timeout", ",", "100", ",", "node", ")", ";", "}" ]
Wait until the specified add-on has been downloaded @param {object} aSpec Object with parameters for customization Elements: addon - Add-on element to wait for being downloaded timeout - Duration to wait for the target state [optional - default: 15s]
[ "Wait", "until", "the", "specified", "add", "-", "on", "has", "been", "downloaded" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L579-L599
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_categories
function addonsManager_categories(aSpec) { var spec = aSpec || { }; var categories = this.getElements({ type: "categories", subtype: spec.attribute, value: spec.value }); if (categories.length == 0) throw new Error(arguments.callee.name + ": Categories could not be found."); return categories; }
javascript
function addonsManager_categories(aSpec) { var spec = aSpec || { }; var categories = this.getElements({ type: "categories", subtype: spec.attribute, value: spec.value }); if (categories.length == 0) throw new Error(arguments.callee.name + ": Categories could not be found."); return categories; }
[ "function", "addonsManager_categories", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "categories", "=", "this", ".", "getElements", "(", "{", "type", ":", "\"categories\"", ",", "subtype", ":", "spec", ".", "attribute", ",", "value", ":", "spec", ".", "value", "}", ")", ";", "if", "(", "categories", ".", "length", "==", "0", ")", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Categories could not be found.\"", ")", ";", "return", "categories", ";", "}" ]
Returns the categories which match the filter criteria @param {object} aSpec Information about the filter to apply Elements: attribute - DOM attribute of the wanted category [optional - default: ""] value - Value of the DOM attribute [optional - default: ""] @returns List of categories @type {array of ElemBase}
[ "Returns", "the", "categories", "which", "match", "the", "filter", "criteria" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L629-L642
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_getCategoryById
function addonsManager_getCategoryById(aSpec) { var spec = aSpec || { }; var id = spec.id; if (!id) throw new Error(arguments.callee.name + ": Category ID not specified."); return this.getCategories({ attribute: "id", value: "category-" + id })[0]; }
javascript
function addonsManager_getCategoryById(aSpec) { var spec = aSpec || { }; var id = spec.id; if (!id) throw new Error(arguments.callee.name + ": Category ID not specified."); return this.getCategories({ attribute: "id", value: "category-" + id })[0]; }
[ "function", "addonsManager_getCategoryById", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "id", "=", "spec", ".", "id", ";", "if", "(", "!", "id", ")", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Category ID not specified.\"", ")", ";", "return", "this", ".", "getCategories", "(", "{", "attribute", ":", "\"id\"", ",", "value", ":", "\"category-\"", "+", "id", "}", ")", "[", "0", "]", ";", "}" ]
Get the category element for the specified id @param {object} aSpec Information for getting a category Elements: id - Category id (search, discover, languages, searchengines, extensions, themes, plugins, availableUpdates, recentUpdates) @returns Category @type {ElemBase}
[ "Get", "the", "category", "element", "for", "the", "specified", "id" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L656-L667
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_getCategoryId
function addonsManager_getCategoryId(aSpec) { var spec = aSpec || { }; var category = spec.category; if (!category) throw new Error(arguments.callee.name + ": Category not specified."); return category.getNode().id; }
javascript
function addonsManager_getCategoryId(aSpec) { var spec = aSpec || { }; var category = spec.category; if (!category) throw new Error(arguments.callee.name + ": Category not specified."); return category.getNode().id; }
[ "function", "addonsManager_getCategoryId", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "category", "=", "spec", ".", "category", ";", "if", "(", "!", "category", ")", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Category not specified.\"", ")", ";", "return", "category", ".", "getNode", "(", ")", ".", "id", ";", "}" ]
Get the ID of the given category element @param {object} aSpec Information for getting a category Elements: category - Category to get the id from @returns Category Id @type {string}
[ "Get", "the", "ID", "of", "the", "given", "category", "element" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L679-L687
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_setCategory
function addonsManager_setCategory(aSpec) { var spec = aSpec || { }; var category = spec.category; var waitFor = (spec.waitFor == undefined) ? true : spec.waitFor; if (!category) throw new Error(arguments.callee.name + ": Category not specified."); this._controller.click(category); if (waitFor) this.waitForCategory({category: category}); }
javascript
function addonsManager_setCategory(aSpec) { var spec = aSpec || { }; var category = spec.category; var waitFor = (spec.waitFor == undefined) ? true : spec.waitFor; if (!category) throw new Error(arguments.callee.name + ": Category not specified."); this._controller.click(category); if (waitFor) this.waitForCategory({category: category}); }
[ "function", "addonsManager_setCategory", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "category", "=", "spec", ".", "category", ";", "var", "waitFor", "=", "(", "spec", ".", "waitFor", "==", "undefined", ")", "?", "true", ":", "spec", ".", "waitFor", ";", "if", "(", "!", "category", ")", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Category not specified.\"", ")", ";", "this", ".", "_controller", ".", "click", "(", "category", ")", ";", "if", "(", "waitFor", ")", "this", ".", "waitForCategory", "(", "{", "category", ":", "category", "}", ")", ";", "}" ]
Select the given category @param {object} aSpec Information for selecting a category Elements: category - Category element waitFor - Wait until the category has been selected [optional - default: true]
[ "Select", "the", "given", "category" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L698-L710
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_setCategoryById
function addonsManager_setCategoryById(aSpec) { var spec = aSpec || { }; var id = spec.id; var waitFor = (spec.waitFor == undefined) ? true : spec.waitFor; if (!id) throw new Error(arguments.callee.name + ": Category ID not specified."); // Retrieve the category and set it as active var category = this.getCategoryById({id: id}); if (category) this.setCategory({category: category, waitFor: waitFor}); else throw new Error(arguments.callee.name + ": Category '" + id + " not found."); }
javascript
function addonsManager_setCategoryById(aSpec) { var spec = aSpec || { }; var id = spec.id; var waitFor = (spec.waitFor == undefined) ? true : spec.waitFor; if (!id) throw new Error(arguments.callee.name + ": Category ID not specified."); // Retrieve the category and set it as active var category = this.getCategoryById({id: id}); if (category) this.setCategory({category: category, waitFor: waitFor}); else throw new Error(arguments.callee.name + ": Category '" + id + " not found."); }
[ "function", "addonsManager_setCategoryById", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "id", "=", "spec", ".", "id", ";", "var", "waitFor", "=", "(", "spec", ".", "waitFor", "==", "undefined", ")", "?", "true", ":", "spec", ".", "waitFor", ";", "if", "(", "!", "id", ")", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Category ID not specified.\"", ")", ";", "var", "category", "=", "this", ".", "getCategoryById", "(", "{", "id", ":", "id", "}", ")", ";", "if", "(", "category", ")", "this", ".", "setCategory", "(", "{", "category", ":", "category", ",", "waitFor", ":", "waitFor", "}", ")", ";", "else", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Category '\"", "+", "id", "+", "\" not found.\"", ")", ";", "}" ]
Select the category with the given id @param {object} aSpec Information for selecting a category Elements: id - Category id (search, discover, languages, searchengines, extensions, themes, plugins, availableUpdates, recentUpdates) waitFor - Wait until the category has been selected [optional - default: true]
[ "Select", "the", "category", "with", "the", "given", "id" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L723-L737
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_waitForCategory
function addonsManager_waitForCategory(aSpec) { var spec = aSpec || { }; var category = spec.category; var timeout = (spec.timeout == undefined) ? TIMEOUT : spec.timeout; if (!category) throw new Error(arguments.callee.name + ": Category not specified."); // TODO: restore after 1.5.1 has landed // var self = this; // mozmill.utils.waitFor(function () { // return self.selectedCategory.getNode() == category.getNode(); // }, timeout, 100, "Category '" + category.getNode().id + "' has been set"); mozmill.utils.waitForEval("subject.self.selectedCategory.getNode() == subject.aCategory.getNode()", timeout, 100, {self: this, aCategory: category}); }
javascript
function addonsManager_waitForCategory(aSpec) { var spec = aSpec || { }; var category = spec.category; var timeout = (spec.timeout == undefined) ? TIMEOUT : spec.timeout; if (!category) throw new Error(arguments.callee.name + ": Category not specified."); // TODO: restore after 1.5.1 has landed // var self = this; // mozmill.utils.waitFor(function () { // return self.selectedCategory.getNode() == category.getNode(); // }, timeout, 100, "Category '" + category.getNode().id + "' has been set"); mozmill.utils.waitForEval("subject.self.selectedCategory.getNode() == subject.aCategory.getNode()", timeout, 100, {self: this, aCategory: category}); }
[ "function", "addonsManager_waitForCategory", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "category", "=", "spec", ".", "category", ";", "var", "timeout", "=", "(", "spec", ".", "timeout", "==", "undefined", ")", "?", "TIMEOUT", ":", "spec", ".", "timeout", ";", "if", "(", "!", "category", ")", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Category not specified.\"", ")", ";", "mozmill", ".", "utils", ".", "waitForEval", "(", "\"subject.self.selectedCategory.getNode() == subject.aCategory.getNode()\"", ",", "timeout", ",", "100", ",", "{", "self", ":", "this", ",", "aCategory", ":", "category", "}", ")", ";", "}" ]
Wait until the specified category has been selected @param {object} aSpec Object with parameters for customization Elements: category - Category element to wait for timeout - Duration to wait for the target state [optional - default: 5s]
[ "Wait", "until", "the", "specified", "category", "has", "been", "selected" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L748-L765
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_search
function addonsManager_search(aSpec) { var spec = aSpec || { }; var value = spec.value; var timeout = (spec.timeout == undefined) ? TIMEOUT_SEARCH : spec.timeout; var waitFor = (spec.waitFor == undefined) ? true : spec.waitFor; if (!value) throw new Error(arguments.callee.name + ": Search term not specified."); var textbox = this.getElement({type: "search_textbox"}); this.clearSearchField(); this._controller.type(textbox, value); this._controller.keypress(textbox, "VK_RETURN", {}); if (waitFor) this.waitForSearchFinished(); }
javascript
function addonsManager_search(aSpec) { var spec = aSpec || { }; var value = spec.value; var timeout = (spec.timeout == undefined) ? TIMEOUT_SEARCH : spec.timeout; var waitFor = (spec.waitFor == undefined) ? true : spec.waitFor; if (!value) throw new Error(arguments.callee.name + ": Search term not specified."); var textbox = this.getElement({type: "search_textbox"}); this.clearSearchField(); this._controller.type(textbox, value); this._controller.keypress(textbox, "VK_RETURN", {}); if (waitFor) this.waitForSearchFinished(); }
[ "function", "addonsManager_search", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "var", "value", "=", "spec", ".", "value", ";", "var", "timeout", "=", "(", "spec", ".", "timeout", "==", "undefined", ")", "?", "TIMEOUT_SEARCH", ":", "spec", ".", "timeout", ";", "var", "waitFor", "=", "(", "spec", ".", "waitFor", "==", "undefined", ")", "?", "true", ":", "spec", ".", "waitFor", ";", "if", "(", "!", "value", ")", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Search term not specified.\"", ")", ";", "var", "textbox", "=", "this", ".", "getElement", "(", "{", "type", ":", "\"search_textbox\"", "}", ")", ";", "this", ".", "clearSearchField", "(", ")", ";", "this", ".", "_controller", ".", "type", "(", "textbox", ",", "value", ")", ";", "this", ".", "_controller", ".", "keypress", "(", "textbox", ",", "\"VK_RETURN\"", ",", "{", "}", ")", ";", "if", "(", "waitFor", ")", "this", ".", "waitForSearchFinished", "(", ")", ";", "}" ]
Search for a specified add-on @param {object} aSpec Information to execute the search Elements: value - Search term timeout - Duration to wait for search results [optional - default: 30s] waitFor - Wait until the search has been finished [optional - default: true]
[ "Search", "for", "a", "specified", "add", "-", "on" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L793-L810
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_getSearchFilter
function addonsManager_getSearchFilter(aSpec) { var spec = aSpec || { }; return this.getElements({ type: "search_filterRadioButtons", subtype: spec.attribute, value: spec.value }); }
javascript
function addonsManager_getSearchFilter(aSpec) { var spec = aSpec || { }; return this.getElements({ type: "search_filterRadioButtons", subtype: spec.attribute, value: spec.value }); }
[ "function", "addonsManager_getSearchFilter", "(", "aSpec", ")", "{", "var", "spec", "=", "aSpec", "||", "{", "}", ";", "return", "this", ".", "getElements", "(", "{", "type", ":", "\"search_filterRadioButtons\"", ",", "subtype", ":", "spec", ".", "attribute", ",", "value", ":", "spec", ".", "value", "}", ")", ";", "}" ]
Returns the available search filters which match the filter criteria @param {object} aSpec Information about the filter to apply Elements: attribute - DOM attribute of the wanted filter [optional - default: ""] value - Value of the DOM attribute [optional - default: ""] @returns List of search filters @type {array of ElemBase}
[ "Returns", "the", "available", "search", "filters", "which", "match", "the", "filter", "criteria" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L867-L875
train
SeleniumHQ/selenium
third_party/js/mozmill/shared-modules/addons.js
addonsManager_getSearchFilterByValue
function addonsManager_getSearchFilterByValue(aValue) { if (!aValue) throw new Error(arguments.callee.name + ": Search filter value not specified."); return this.getElement({ type: "search_filterRadioGroup", subtype: "value", value: aValue }); }
javascript
function addonsManager_getSearchFilterByValue(aValue) { if (!aValue) throw new Error(arguments.callee.name + ": Search filter value not specified."); return this.getElement({ type: "search_filterRadioGroup", subtype: "value", value: aValue }); }
[ "function", "addonsManager_getSearchFilterByValue", "(", "aValue", ")", "{", "if", "(", "!", "aValue", ")", "throw", "new", "Error", "(", "arguments", ".", "callee", ".", "name", "+", "\": Search filter value not specified.\"", ")", ";", "return", "this", ".", "getElement", "(", "{", "type", ":", "\"search_filterRadioGroup\"", ",", "subtype", ":", "\"value\"", ",", "value", ":", "aValue", "}", ")", ";", "}" ]
Get the search filter element for the specified value @param {string} aValue Search filter value (local, remote) @returns Search filter element @type {ElemBase}
[ "Get", "the", "search", "filter", "element", "for", "the", "specified", "value" ]
38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd
https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L886-L895
train