Best JavaScript code snippet using ghostjs
IsolatedFileSystemManager.js
Source:IsolatedFileSystemManager.js
1/*2 * Copyright (C) 2012 Google Inc. All rights reserved.3 *4 * Redistribution and use in source and binary forms, with or without5 * modification, are permitted provided that the following conditions are6 * met:7 *8 * * Redistributions of source code must retain the above copyright9 * notice, this list of conditions and the following disclaimer.10 * * Redistributions in binary form must reproduce the above11 * copyright notice, this list of conditions and the following disclaimer12 * in the documentation and/or other materials provided with the13 * distribution.14 * * Neither the name of Google Inc. nor the names of its15 * contributors may be used to endorse or promote products derived from16 * this software without specific prior written permission.17 *18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.29 */30/**31 * @constructor32 * @extends {WebInspector.Object}33 */34WebInspector.IsolatedFileSystemManager = function()35{36 /** @type {!Object.<string, WebInspector.IsolatedFileSystem>} */37 this._fileSystems = {};38 /** @type {Object.<string, Array.<function(DOMFileSystem)>>} */39 this._pendingFileSystemRequests = {};40 this._fileSystemMapping = new WebInspector.FileSystemMapping();41 if (this.supportsFileSystems())42 this._requestFileSystems();43}44/** @typedef {{fileSystemName: string, rootURL: string, fileSystemPath: string}} */45WebInspector.IsolatedFileSystemManager.FileSystem;46WebInspector.IsolatedFileSystemManager.Events = {47 FileSystemAdded: "FileSystemAdded",48 FileSystemRemoved: "FileSystemRemoved"49}50WebInspector.IsolatedFileSystemManager.prototype = {51 /**52 * @return {WebInspector.FileSystemMapping}53 */54 mapping: function()55 {56 return this._fileSystemMapping;57 },58 /**59 * @return {boolean}60 */61 supportsFileSystems: function()62 {63 return InspectorFrontendHost.supportsFileSystems();64 },65 _requestFileSystems: function()66 {67 console.assert(!this._loaded);68 InspectorFrontendHost.requestFileSystems();69 },70 addFileSystem: function()71 {72 InspectorFrontendHost.addFileSystem();73 },74 /**75 * @param {string} fileSystemPath76 */77 removeFileSystem: function(fileSystemPath)78 {79 InspectorFrontendHost.removeFileSystem(fileSystemPath);80 },81 /**82 * @param {Array.<WebInspector.IsolatedFileSystemManager.FileSystem>} fileSystems83 */84 _fileSystemsLoaded: function(fileSystems)85 {86 var addedFileSystemPaths = {};87 for (var i = 0; i < fileSystems.length; ++i) {88 this._innerAddFileSystem(fileSystems[i]);89 addedFileSystemPaths[fileSystems[i].fileSystemPath] = true;90 }91 var fileSystemPaths = this._fileSystemMapping.fileSystemPaths();92 for (var i = 0; i < fileSystemPaths.length; ++i) {93 var fileSystemPath = fileSystemPaths[i];94 if (!addedFileSystemPaths[fileSystemPath])95 this._fileSystemRemoved(fileSystemPath);96 }97 this._loaded = true;98 this._processPendingFileSystemRequests();99 },100 /**101 * @param {WebInspector.IsolatedFileSystemManager.FileSystem} fileSystem102 */103 _innerAddFileSystem: function(fileSystem)104 {105 var fileSystemPath = fileSystem.fileSystemPath;106 this._fileSystemMapping.addFileSystem(fileSystemPath);107 var isolatedFileSystem = new WebInspector.IsolatedFileSystem(this, fileSystemPath, fileSystem.fileSystemName, fileSystem.rootURL);108 this._fileSystems[fileSystemPath] = isolatedFileSystem;109 this.dispatchEventToListeners(WebInspector.IsolatedFileSystemManager.Events.FileSystemAdded, isolatedFileSystem);110 },111 /**112 * @return {Array.<string>}113 */114 _fileSystemPaths: function()115 {116 return Object.keys(this._fileSystems);117 },118 _processPendingFileSystemRequests: function()119 {120 for (var fileSystemPath in this._pendingFileSystemRequests) {121 var callbacks = this._pendingFileSystemRequests[fileSystemPath];122 for (var i = 0; i < callbacks.length; ++i)123 callbacks[i](this._isolatedFileSystem(fileSystemPath));124 }125 delete this._pendingFileSystemRequests;126 },127 /**128 * @param {string} errorMessage129 * @param {WebInspector.IsolatedFileSystemManager.FileSystem} fileSystem130 */131 _fileSystemAdded: function(errorMessage, fileSystem)132 {133 var fileSystemPath;134 if (errorMessage)135 WebInspector.showErrorMessage(errorMessage)136 else if (fileSystem) {137 this._innerAddFileSystem(fileSystem);138 fileSystemPath = fileSystem.fileSystemPath;139 }140 },141 /**142 * @param {string} fileSystemPath143 */144 _fileSystemRemoved: function(fileSystemPath)145 {146 this._fileSystemMapping.removeFileSystem(fileSystemPath);147 var isolatedFileSystem = this._fileSystems[fileSystemPath];148 delete this._fileSystems[fileSystemPath];149 if (isolatedFileSystem)150 this.dispatchEventToListeners(WebInspector.IsolatedFileSystemManager.Events.FileSystemRemoved, isolatedFileSystem);151 },152 /**153 * @param {string} fileSystemPath154 * @return {DOMFileSystem}155 */156 _isolatedFileSystem: function(fileSystemPath)157 {158 var fileSystem = this._fileSystems[fileSystemPath];159 if (!fileSystem)160 return null;161 if (!InspectorFrontendHost.isolatedFileSystem)162 return null;163 return InspectorFrontendHost.isolatedFileSystem(fileSystem.name(), fileSystem.rootURL());164 },165 /**166 * @param {string} fileSystemPath167 * @param {function(DOMFileSystem)} callback168 */169 requestDOMFileSystem: function(fileSystemPath, callback)170 {171 if (!this._loaded) {172 if (!this._pendingFileSystemRequests[fileSystemPath])173 this._pendingFileSystemRequests[fileSystemPath] = this._pendingFileSystemRequests[fileSystemPath] || [];174 this._pendingFileSystemRequests[fileSystemPath].push(callback);175 return;176 }177 callback(this._isolatedFileSystem(fileSystemPath));178 },179 __proto__: WebInspector.Object.prototype180}181/**182 * @type {?WebInspector.IsolatedFileSystemManager}183 */184WebInspector.isolatedFileSystemManager = null;185/**186 * @constructor187 * @param {WebInspector.IsolatedFileSystemManager} IsolatedFileSystemManager188 */189WebInspector.IsolatedFileSystemDispatcher = function(IsolatedFileSystemManager)190{191 this._IsolatedFileSystemManager = IsolatedFileSystemManager;192}193WebInspector.IsolatedFileSystemDispatcher.prototype = {194 /**195 * @param {Array.<WebInspector.IsolatedFileSystemManager.FileSystem>} fileSystems196 */197 fileSystemsLoaded: function(fileSystems)198 {199 this._IsolatedFileSystemManager._fileSystemsLoaded(fileSystems);200 },201 /**202 * @param {string} fileSystemPath203 */204 fileSystemRemoved: function(fileSystemPath)205 {206 this._IsolatedFileSystemManager._fileSystemRemoved(fileSystemPath);207 },208 /**209 * @param {string} errorMessage210 * @param {WebInspector.IsolatedFileSystemManager.FileSystem} fileSystem211 */212 fileSystemAdded: function(errorMessage, fileSystem)213 {214 this._IsolatedFileSystemManager._fileSystemAdded(errorMessage, fileSystem);215 }216}217/**218 * @type {?WebInspector.IsolatedFileSystemDispatcher}219 */...
filetypes.js
Source:filetypes.js
1/*2 RoxyFileman - web based file manager. Ready to use with CKEditor, TinyMCE. 3 Can be easily integrated with any other WYSIWYG editor or CMS.4 Copyright (C) 2013, RoxyFileman.com - Lyubomir Arsov. All rights reserved.5 For licensing, see LICENSE.txt or http://RoxyFileman.com/license6 This program is free software: you can redistribute it and/or modify7 it under the terms of the GNU General Public License as published by8 the Free Software Foundation, either version 3 of the License.9 This program is distributed in the hope that it will be useful,10 but WITHOUT ANY WARRANTY; without even the implied warranty of11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12 GNU General Public License for more details.13 You should have received a copy of the GNU General Public License14 along with this program. If not, see <http://www.gnu.org/licenses/>.15 Contact: Lyubomir Arsov, liubo (at) web-lobby.com16*/17var fileTypeIcons = new Object();18fileTypeIcons['3gp'] = 'file_extension_3gp.png';19fileTypeIcons['7z'] = 'file_extension_7z.png';20fileTypeIcons['ace'] = 'file_extension_ace.png';21fileTypeIcons['ai'] = 'file_extension_ai.png';22fileTypeIcons['aif'] = 'file_extension_aif.png';23fileTypeIcons['aiff'] = 'file_extension_aiff.png';24fileTypeIcons['amr'] = 'file_extension_amr.png';25fileTypeIcons['asf'] = 'file_extension_asf.png';26fileTypeIcons['asx'] = 'file_extension_asx.png';27fileTypeIcons['bat'] = 'file_extension_bat.png';28fileTypeIcons['bin'] = 'file_extension_bin.png';29fileTypeIcons['bmp'] = 'file_extension_bmp.png';30fileTypeIcons['bup'] = 'file_extension_bup.png';31fileTypeIcons['cab'] = 'file_extension_cab.png';32fileTypeIcons['cbr'] = 'file_extension_cbr.png';33fileTypeIcons['cda'] = 'file_extension_cda.png';34fileTypeIcons['cdl'] = 'file_extension_cdl.png';35fileTypeIcons['cdr'] = 'file_extension_cdr.png';36fileTypeIcons['chm'] = 'file_extension_chm.png';37fileTypeIcons['dat'] = 'file_extension_dat.png';38fileTypeIcons['divx'] = 'file_extension_divx.png';39fileTypeIcons['dll'] = 'file_extension_dll.png';40fileTypeIcons['dmg'] = 'file_extension_dmg.png';41fileTypeIcons['doc'] = 'file_extension_doc.png';42fileTypeIcons['dss'] = 'file_extension_dss.png';43fileTypeIcons['dvf'] = 'file_extension_dvf.png';44fileTypeIcons['dwg'] = 'file_extension_dwg.png';45fileTypeIcons['eml'] = 'file_extension_eml.png';46fileTypeIcons['eps'] = 'file_extension_eps.png';47fileTypeIcons['exe'] = 'file_extension_exe.png';48fileTypeIcons['fla'] = 'file_extension_fla.png';49fileTypeIcons['flv'] = 'file_extension_flv.png';50fileTypeIcons['gif'] = 'file_extension_gif.png';51fileTypeIcons['gz'] = 'file_extension_gz.png';52fileTypeIcons['hqx'] = 'file_extension_hqx.png';53fileTypeIcons['htm'] = 'file_extension_htm.png';54fileTypeIcons['html'] = 'file_extension_html.png';55fileTypeIcons['ifo'] = 'file_extension_ifo.png';56fileTypeIcons['indd'] = 'file_extension_indd.png';57fileTypeIcons['iso'] = 'file_extension_iso.png';58fileTypeIcons['jar'] = 'file_extension_jar.png';59fileTypeIcons['jpeg'] = 'file_extension_jpeg.png';60fileTypeIcons['jpg'] = 'file_extension_jpg.png';61fileTypeIcons['lnk'] = 'file_extension_lnk.png';62fileTypeIcons['log'] = 'file_extension_log.png';63fileTypeIcons['m4a'] = 'file_extension_m4a.png';64fileTypeIcons['m4b'] = 'file_extension_m4b.png';65fileTypeIcons['m4p'] = 'file_extension_m4p.png';66fileTypeIcons['m4v'] = 'file_extension_m4v.png';67fileTypeIcons['mcd'] = 'file_extension_mcd.png';68fileTypeIcons['mdb'] = 'file_extension_mdb.png';69fileTypeIcons['mid'] = 'file_extension_mid.png';70fileTypeIcons['mov'] = 'file_extension_mov.png';71fileTypeIcons['mp2'] = 'file_extension_mp2.png';72fileTypeIcons['mp3'] = 'file_extension_mp3.png';73fileTypeIcons['mp4'] = 'file_extension_mp4.png';74fileTypeIcons['mpeg'] = 'file_extension_mpeg.png';75fileTypeIcons['mpg'] = 'file_extension_mpg.png';76fileTypeIcons['msi'] = 'file_extension_msi.png';77fileTypeIcons['mswmm'] = 'file_extension_mswmm.png';78fileTypeIcons['ogg'] = 'file_extension_ogg.png';79fileTypeIcons['pdf'] = 'file_extension_pdf.png';80fileTypeIcons['png'] = 'file_extension_png.png';81fileTypeIcons['pps'] = 'file_extension_pps.png';82fileTypeIcons['ps'] = 'file_extension_ps.png';83fileTypeIcons['psd'] = 'file_extension_psd.png';84fileTypeIcons['pst'] = 'file_extension_pst.png';85fileTypeIcons['ptb'] = 'file_extension_ptb.png';86fileTypeIcons['pub'] = 'file_extension_pub.png';87fileTypeIcons['qbb'] = 'file_extension_qbb.png';88fileTypeIcons['qbw'] = 'file_extension_qbw.png';89fileTypeIcons['qxd'] = 'file_extension_qxd.png';90fileTypeIcons['ram'] = 'file_extension_ram.png';91fileTypeIcons['rar'] = 'file_extension_rar.png';92fileTypeIcons['rm'] = 'file_extension_rm.png';93fileTypeIcons['rmvb'] = 'file_extension_rmvb.png';94fileTypeIcons['rtf'] = 'file_extension_rtf.png';95fileTypeIcons['sea'] = 'file_extension_sea.png';96fileTypeIcons['ses'] = 'file_extension_ses.png';97fileTypeIcons['sit'] = 'file_extension_sit.png';98fileTypeIcons['sitx'] = 'file_extension_sitx.png';99fileTypeIcons['ss'] = 'file_extension_ss.png';100fileTypeIcons['swf'] = 'file_extension_swf.png';101fileTypeIcons['tgz'] = 'file_extension_tgz.png';102fileTypeIcons['thm'] = 'file_extension_thm.png';103fileTypeIcons['tif'] = 'file_extension_tif.png';104fileTypeIcons['tmp'] = 'file_extension_tmp.png';105fileTypeIcons['torrent'] = 'file_extension_torrent.png';106fileTypeIcons['ttf'] = 'file_extension_ttf.png';107fileTypeIcons['txt'] = 'file_extension_txt.png';108fileTypeIcons['vcd'] = 'file_extension_vcd.png';109fileTypeIcons['vob'] = 'file_extension_vob.png';110fileTypeIcons['wav'] = 'file_extension_wav.png';111fileTypeIcons['wma'] = 'file_extension_wma.png';112fileTypeIcons['wmv'] = 'file_extension_wmv.png';113fileTypeIcons['wps'] = 'file_extension_wps.png';114fileTypeIcons['xls'] = 'file_extension_xls.png';115fileTypeIcons['xpi'] = 'file_extension_xpi.png';...
Using AI Code Generation
1var ghost = require('ghostjs');2 .type('#lst-ib', 'Hello World')3 .click('.lsb')4 .wait(1000)5 .screenshot('screenshot.png')6 .end();
Using AI Code Generation
1var ghost = require('ghostjs');2 return ghost.sendKeys('GhostJS', 'input[name="q"]');3}).then(function() {4 return ghost.click('input[name="btnG"]');5}).then(function() {6 return ghost.wait(2000);7}).then(function() {8 return ghost.saveScreenshot('google.png');9}).then(function() {10 return ghost.exit();11}).catch(function(e) {12 console.error(e.stack);13 ghost.exit(1);14});15### ghost.open(url)16### ghost.sendKeys(text, selector)17### ghost.click(selector)18### ghost.wait(ms)19### ghost.saveScreenshot(path)20### ghost.exit([code])21### ghost.injectJs(path)22### ghost.evaluate(fn)23### ghost.evaluateAsync(fn)24### ghost.on(event, fn)25### ghost.off(event, fn)26### ghost.once(event, fn)27### ghost.removeAllListeners(event)28### ghost.removeAllListeners()29### ghost.get(url)30### ghost.post(url, data)31### ghost.setHeaders(headers)32### ghost.setHeaders(url, headers)33### ghost.setHeaders(url, headers, method)34### ghost.clearHeaders()35### ghost.clearHeaders(url)36### ghost.clearHeaders(url, method)37### ghost.setCookies(cookies)38### ghost.setCookies(url
Using AI Code Generation
1var ghost = require('ghostjs');2.then(function() {3 return ghost.wait(1000);4})5.then(function() {6 return ghost.screenshot();7})8.then(function(image) {9 return ghost.writeFile('google.png', image);10})11.then(function() {12 return ghost.exit();13})14.catch(function(err) {15 console.log(err);16 ghost.exit(1);17});18var ghost = require('ghostjs');19.then(function() {20 return ghost.wait(1000);21})22.then(function() {23 return ghost.screenshot();24})25.then(function(image) {26 return ghost.writeFile('google.png', image);27})28.then(function() {29 return ghost.exit();30})31.catch(function(err) {32 console.log(err);33 ghost.exit(1);34});35var ghost = require('ghostjs');36.then(function() {37 return ghost.wait(1000);38})39.then(function() {40 return ghost.screenshot();41})42.then(function(image) {43 return ghost.writeFile('google.png', image);44})45.then(function() {46 return ghost.exit();47})48.catch(function(err) {49 console.log(err);50 ghost.exit(1);51});52var ghost = require('ghostjs');53.then(function() {54 return ghost.wait(1000);55})56.then(function() {57 return ghost.screenshot();58})59.then(function(image) {60 return ghost.writeFile('google.png', image);61})62.then(function() {63 return ghost.exit();64})65.catch(function(err) {66 console.log(err);67 ghost.exit(1);68});69var ghost = require('ghostjs');70.then(function() {71 return ghost.wait(1000);72})73.then(function() {74 return ghost.screenshot();75})76.then(function(image) {77 return ghost.writeFile('google.png', image);78})79.then(function() {80 return ghost.exit();81})82.catch(function(err) {83 console.log(err);84 ghost.exit(1);85});
Using AI Code Generation
1const ghost = require('ghostjs');2const file = ghost.file;3file.write('test.txt', 'Hello World!');4const ghost = require('ghostjs');5const file = ghost.file;6file.write('test.txt', 'Hello World!');7- [Click and type](
Using AI Code Generation
1const { Ghost } = require("ghostjs");2const { By, Key } = require("ghostjs");3const { Builder, Capabilities, until } = require("selenium-webdriver");4(async () => {5 const ghost = new Ghost();6 await ghost.click(By.name("q"));7 await ghost.sendKeys("ghostjs");8 await ghost.sendKeys(Key.ENTER);9 await ghost.wait(until.titleIs("ghostjs - Google Search"));10 await ghost.screenshot("google.png");11 await ghost.close();12})();13### `new Ghost(options)`14const { Ghost } = require("ghostjs");15const { Builder, Capabilities } = require("selenium-webdriver");16const ghost = new Ghost({17 driver: new Builder()18 .forBrowser("firefox")19 .withCapabilities(Capabilities.firefox())20 .build()21});22const { Ghost } = require("ghostjs");23const ghost = new Ghost({24});25const { Ghost } = require("ghostjs");26const ghost = new Ghost({27});28const { Ghost } = require("ghostjs");29const ghost = new Ghost({30});31### `ghost.open(url)`
Using AI Code Generation
1const ghost = require('ghostjs');2const fs = require('fs');3 await ghost.screenshot('test.png');4 await ghost.wait(5000);5 await ghost.close();6});7const ghost = require('ghostjs');8const fs = require('fs');9 await ghost.wait(5000);10 await ghost.screenshot('test.png');11 await ghost.close();12});13### **`ghost.screenshot(selector, filename, options)`**14await ghost.screenshot('.selector', 'screenshot.png');15await ghost.screenshot('.selector', 'screenshot.png', { format: 'jpeg', quality: 80 });16### **`ghost.wait(ms)`**17await ghost.wait(5000);18### **`ghost.waitUntilVisible(selector, timeout)`**19await ghost.waitUntilVisible('#selector', 10000);20### **`ghost.waitUntilHidden(selector, timeout)`**21await ghost.waitUntilHidden('#selector', 10000);22### **`ghost.waitUntilExists(selector, timeout)`**23Waits for the element specified by `selector` to be added to the DOM. If the element is not added to the DOM within the specified `timeout` (in milliseconds), an
Using AI Code Generation
1var file = require('./file');2var test = require('./test');3var test2 = require('./test2');4var test3 = require('./test3');5var file = require('./file');6var test = require('./test');7var test2 = require('./test2');8var test3 = require('./test3');9console.log("test.js");
Using AI Code Generation
1var ghost = require('ghostjs'),2 assert = require('assert');3ghost.getText(".test").then(function (text) {4 assert.equal(text, "test");5});6ghost.getImage(".test").then(function (image) {7 assert.equal(image, "test.png");8});9ghost.getLink(".test").then(function (link) {10});11ghost.getTitle().then(function (title) {12 assert.equal(title, "test");13});14ghost.getUrl().then(function (url) {15});16ghost.getSource().then(function (source) {17 assert.equal(source, "<html><head></head><body><div class="test">test</div></body></html>");18});19ghost.getHtml(".test").then(function (html) {20 assert.equal(html, "<div class="test">test</div>");21});22ghost.getValue(".test").then(function (value) {23 assert.equal(value, "test");24});25ghost.getCount(".test").then(function (count) {26 assert.equal(count, 2);27});28ghost.getAttribute(".test", "class").then(function (attribute) {29 assert.equal(attribute, "test");30});31ghost.getCss(".test", "color").then(function (css) {32 assert.equal(css, "red");33});34ghost.exists(".test").then(function (exists) {35 assert.equal(exists, true);36});37ghost.isVisible(".test").then(function (visible) {38 assert.equal(visible, true);39});40ghost.isEnabled(".test").then(function (enabled) {41 assert.equal(enabled, true);42});43ghost.isSelected(".test").then(function (selected) {44 assert.equal(selected, true);45});46ghost.getText(".test").then(function (text) {47 assert.equal(text, "test");48});49ghost.getText(".test").then(function (text) {50 assert.equal(text, "test");51});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!