How to use callCallback method in Playwright Internal

Best JavaScript code snippet using playwright-internal

core.js

Source:core.js Github

copy

Full Screen

...233 * @param callbackName String callback which should be called234 * @param element some arguments to the callback235 * @param eventData236 */237 function callCallback( callbackName, element, eventData ) {238 eventData.settings = settings;239 eventData.current = current;240 eventData.container = container;241 eventData.parents = element ? getStepParents(element) : null;242 eventData.current = current;243 eventData.jmpress = this;244 var result = {};245 $.each( settings[callbackName], function(idx, callback) {246 result.value = callback.call( jmpress, element, eventData ) || result.value;247 });248 return result.value;249 }250 /**251 *...

Full Screen

Full Screen

websocket.js

Source:websocket.js Github

copy

Full Screen

...97 $('table.username-password', loginBox).show();98 $('table.twofactor', loginBox).hide();99 Structr.refreshUi((command === 'LOGIN'));100 }101 StructrModel.callCallback(data.callback, data.data[data.data['key']]);102 } else if (command === 'GET_LOCAL_STORAGE') {103 if (data.data.localStorageString && data.data.localStorageString.length) {104 LSWrapper.setAsJSON(data.data.localStorageString);105 }106 StructrModel.callCallback(data.callback, data.data);107 } else if (command === 'CONSOLE') {108 StructrModel.callCallback(data.callback, data);109 } else if (command === 'STATUS') {110 if (code === 403) {111 StructrWS.user = null;112 StructrWS.userId = null;113 if (data.data.reason === 'sessionLimitExceeded') {114 Structr.login('Max. number of sessions exceeded.');115 } else {116 Structr.login('Wrong username or password!');117 }118 } else if (code === 401) {119 StructrWS.user = null;120 StructrWS.userId = null;121 if (data.data.reason === 'twofactortoken') {122 Structr.clearLoginForm();123 $('table.username-password', loginBox).show();124 $('table.twofactor', loginBox).hide();125 }126 Structr.login((msg !== null) ? msg : '');127 } else if (code === 202) {128 StructrWS.user = null;129 StructrWS.userId = null;130 Structr.login('');131 Structr.toggle2FALoginBox(data.data);132 } else {133 let codeStr = code ? code.toString() : '';134 if (codeStr === '422') {135 try {136 StructrModel.callCallback(data.callback, null, null, true);137 } catch (e) {}138 }139 let msgClass;140 let requiresConfirmation = false;141 if (codeStr.startsWith('2')) {142 msgClass = 'success';143 } else if (codeStr.startsWith('3')) {144 msgClass = 'info';145 } else if (codeStr.startsWith('4')) {146 msgClass = 'warning';147 requiresConfirmation = true;148 } else {149 msgClass = 'error';150 requiresConfirmation = true;151 }152 if (data.data.requiresConfirmation) {153 requiresConfirmation = data.data.requiresConfirmation;154 }155 if (msg && msg.startsWith('{')) {156 let msgObj = JSON.parse(msg);157 if (dialogBox.is(':visible')) {158 Structr.showAndHideInfoBoxMessage(msgObj.size + ' bytes saved to ' + msgObj.name, msgClass, 2000, 200);159 } else {160 let node = Structr.node(msgObj.id);161 if (node) {162 let progr = node.find('.progress');163 progr.show();164 let size = parseInt(node.find('.size').text());165 let part = msgObj.size;166 node.find('.part').text(part);167 let pw = node.find('.progress').width();168 let w = pw / size * part;169 node.find('.bar').css({width: w + 'px'});170 if (part >= size) {171 blinkGreen(progr);172 window.setTimeout(function () {173 progr.fadeOut('fast');174 _Files.resize();175 }, 1000);176 }177 }178 }179 } else {180 if (codeStr === "404") {181 let msgBuilder = new MessageBuilder().className(msgClass);182 if (requiresConfirmation) {183 msgBuilder.requiresConfirmation();184 }185 if (data.message) {186 msgBuilder.title('Object not found.').text(data.message);187 } else {188 msgBuilder.text('Object not found.');189 }190 msgBuilder.show();191 } else if (data.error && data.error.errors) {192 Structr.errorFromResponse(data.error, null, { requiresConfirmation: true });193 } else {194 let msgBuilder = new MessageBuilder().className(msgClass).text(msg);195 if (requiresConfirmation) {196 msgBuilder.requiresConfirmation();197 }198 msgBuilder.show();199 }200 }201 }202 } else if (command === 'GET_PROPERTY') {203 StructrModel.updateKey(data.id, data.data['key'], data.data[data.data['key']]);204 StructrModel.callCallback(data.callback, data.data[data.data['key']]);205 } else if (command === 'UPDATE' || command === 'SET_PERMISSION') {206 let modelObj = StructrModel.obj(data.id);207 if (!modelObj) {208 data.data.id = data.id;209 modelObj = StructrModel.create(data.data, null, false);210 } else {211 if (modelObj.updatedModel && (typeof modelObj.updatedModel === 'function')) {212 for (let [key, value] of Object.entries(data.data)) {213 modelObj[key] = value;214 }215 modelObj.updatedModel();216 }217 }218 StructrModel.update(data);219 } else if (command === 'GET' || command === 'GET_RELATIONSHIP' || command === 'GET_PROPERTIES') {220 StructrModel.callCallback(data.callback, result[0]);221 } else if (command.startsWith('GET') || command === 'GET_BY_TYPE' || command === 'GET_SCHEMA_INFO' || command === 'CREATE_RELATIONSHIP') {222 StructrModel.callCallback(data.callback, result);223 } else if (command === 'CHILDREN') {224 if (result.length > 0 && result[0].name) {225 result.sort(function (a, b) {226 return a.name.localeCompare(b.name);227 });228 }229 let refObject = StructrModel.obj(data.id);230 if (refObject && refObject.constructor.name === 'StructrGroup') {231 // let security handle this232 } else {233 for (let entity of result) {234 StructrModel.create(entity);235 }236 }237 StructrModel.callCallback(data.callback, result);238 } else if (command.endsWith('CHILDREN')) {239 for (let entity of result) {240 StructrModel.create(entity);241 }242 StructrModel.callCallback(data.callback, result);243 } else if (command.startsWith('SEARCH')) {244 if (type) {245 $('.pageCount', $('.pager' + type)).val(_Pager.pageCount[type]);246 }247 StructrModel.callCallback(data.callback, result, data.rawResultCount);248 } else if (command.startsWith('LIST_UNATTACHED_NODES')) {249 StructrModel.callCallback(data.callback, result);250 } else if (command.startsWith('LIST_SCHEMA_PROPERTIES')) {251 // send full result in a single callback252 StructrModel.callCallback(data.callback, result);253 } else if (command.startsWith('LIST_COMPONENTS')) {254 StructrModel.callCallback(data.callback, result);255 } else if (command.startsWith('LIST_SYNCABLES')) {256 StructrModel.callCallback(data.callback, result);257 } else if (command.startsWith('LIST_ACTIVE_ELEMENTS')) {258 StructrModel.callCallback(data.callback, result);259 } else if (command.startsWith('LIST_LOCALIZATIONS')) {260 StructrModel.callCallback(data.callback, result);261 } else if (command.startsWith('SNAPSHOTS')) {262 StructrModel.callCallback(data.callback, result);263 } else if (command.startsWith('LIST')) {264 StructrModel.callCallback(data.callback, result, data.rawResultCount);265 } else if (command.startsWith('QUERY')) {266 StructrModel.callCallback(data.callback, result, data.rawResultCount);267 } else if (command.startsWith('CLONE') || command === 'REPLACE_TEMPLATE') {268 StructrModel.callCallback(data.callback, result, data.rawResultCount);269 } else if (command === 'DELETE') {270 StructrModel.del(data.id);271 StructrModel.callCallback(data.callback, [], 0);272 } else if (command === 'INSERT_BEFORE' || command === 'APPEND_CHILD' || command === 'APPEND_MEMBER') {273 StructrModel.create(result[0], data.data.refId);274 StructrModel.callCallback(data.callback, result[0]);275 } else if (command.startsWith('APPEND_FILE')) {276 //StructrModel.create(result[0], data.data.refId);277 } else if (command === 'REMOVE') {278 let obj = StructrModel.obj(data.id);279 if (obj) {280 obj.remove();281 }282 StructrModel.callCallback(data.callback);283 } else if (command === 'REMOVE_CHILD') {284 let obj = StructrModel.obj(data.id);285 if (obj) {286 obj.remove(data.data.parentId);287 }288 StructrModel.callCallback(data.callback);289 } else if (command === 'CREATE' || command === 'ADD' || command === 'IMPORT') {290 for (let entity of result) {291 if (command === 'CREATE' && (entity.isPage || entity.isFolder || entity.isFile || entity.isImage || entity.isVideo || entity.isUser || entity.isGroup || entity.isWidget || entity.isResourceAccess)) {292 StructrModel.create(entity);293 } else {294 if (!entity.parent && _Pages.shadowPage && entity.pageId === _Pages.shadowPage.id) {295 entity = StructrModel.create(entity, null, false);296 let el = (entity.isContent || entity.type === 'Template') ? _Elements.appendContentElement(entity, _Pages.components, true) : _Pages.appendElementElement(entity, _Pages.components, true);297 if (Structr.isExpanded(entity.id)) {298 _Entities.ensureExpanded(el);299 }300 let synced = entity.syncedNodesIds;301 if (synced && synced.length) {302 // Change icon303 for (let syncedId of synced) {304 let syncedEl = Structr.node(syncedId);305 if (syncedEl && syncedEl.length) {306 let icon = entity.isContent ? _Elements.getContentIcon(entity) : _Elements.getElementIcon(entity);307 syncedEl.children('.typeIcon').attr('class', 'typeIcon ' + _Icons.getFullSpriteClass(icon));308 _Entities.removeExpandIcon(syncedEl);309 }310 }311 }312 }313 }314 if (command === 'CREATE' && entity.isPage && Structr.lastMenuEntry === _Pages._moduleName) {315 if (entity.createdBy === StructrWS.userId) {316 setTimeout(function () {317 _Pages.previews.showPreviewInIframeIfVisible(entity.id);318 }, 1000);319 }320 } else if (entity.pageId) {321 if (entity.id) {322 _Pages.previews.showPreviewInIframeIfVisible(entity.pageId, entity.id);323 } else {324 _Pages.previews.showPreviewInIframeIfVisible(entity.pageId);325 }326 }327 StructrModel.callCallback(data.callback, entity);328 }329 } else if (command === 'PROGRESS') {330 if (dialogMsg.is(':visible')) {331 let msgObj = JSON.parse(data.message);332 dialogMsg.html('<div class="infoBox info">' + msgObj.message + '</div>');333 }334 } else if (command === 'FINISHED') {335 StructrModel.callCallback(data.callback, data.data);336 } else if (command === 'AUTOCOMPLETE') {337 StructrModel.callCallback(data.callback, result);338 } else if (command === 'FIND_DUPLICATES') {339 StructrModel.callCallback(data.callback, result);340 } else if (command === 'SCHEMA_COMPILED') {341 _Schema.processSchemaRecompileNotification();342 } else if (command === 'GENERIC_MESSAGE') {343 Structr.handleGenericMessage(data.data);344 } else if (command === 'FILE_IMPORT') {345 StructrModel.callCallback(data.callback, result);346 } else if (command === 'GET_SUGGESTIONS') {347 StructrModel.callCallback(data.callback, result);348 } else if (command === 'SERVER_LOG') {349 StructrModel.callCallback(data.callback, result);350 } else if (command === 'SAVE_LOCAL_STORAGE') {351 StructrModel.callCallback(data.callback, result);352 } else if (command === 'APPEND_WIDGET') {353 StructrModel.callCallback(data.callback, result);354 } else {355 console.log('Received unknown command: ' + command);356 if (sessionValid === false) {357 StructrWS.user = null;358 StructrWS.userId = null;359 clearMain();360 Structr.login();361 }362 }363 };364 } catch (exception) {365 if (StructrWS.ws) {366 StructrWS.ws.close();367 StructrWS.ws.length = 0;...

Full Screen

Full Screen

graphCompiler.js

Source:graphCompiler.js Github

copy

Full Screen

...38import getJsCode from './graphOutputs/getJsCode'39import getInteractionMetrics from './graphOutputs/getInteractionMetrics'40export function compile(ast, header, callbacks) {41 // A function to properly call each callback correctly42 function callCallback(element, data) {43 graph.clean(); // Also it cleans the graph44 if (_.isUndefined(callbacks[element]))  {45 return true; // No callback for this stage ? We continue compiling;46 } else {47 let ret = callbacks[element](graph, (_.isObject(data)) ? (_.assign({48 stage: element49 }, data)) : (_.isUndefined(data) ? {50 stage: element51 } : data));52 if (_.isBoolean(ret)) {53 return ret;54 } else {55 throw new Error('Compilation stage callbacks should return a boolean (true to continue compilation, false to stop it), the callback for ' + element + ' returned ' + ret);56 }57 }58 }59 // We add the ad hoc callbacks to the callback stack60 var newCallbacks = _.assign(61 _.clone(callbacks), {62 instantiateInterfaces: (graph, data) => {63 callCallback('getExpandedLidlCode', getExpandedLidl(graph, rootDefinitionNode));64 return callCallback('instantiateInterfaces', data);65 },66 referentialTransparencyInstances: (graph, data) => {67 callCallback('getInteractionMetrics', getInteractionMetrics(graph));68 return callCallback('referentialTransparencyInstances', data);69 },70 orderGraph: (graph, data) => {71 callCallback('getJsCode', getJsCode(graph, header));72 return callCallback('orderGraph', data);73 }74 }75 );76 // Create a graph77 let graph = new Graph();78 // Add the AST to it79 let rootDefinitionNode =80 addDefinitionToGraph(graph, ast);81 // Apply transformations to it82 graphTransformationPipeline(graph, rootDefinitionNode, newCallbacks);83 return graph;84}85export function graphTransformationPipeline(graph, rootDefinitionNode, callbacks) {86 var step = 0;87 var callBackIterationCounter = {};88 // A function to properly call each callback correctly89 function callCallback(element, data) {90 graph.clean(); // Also it cleans the graph91 step = step + 1;92 if (callBackIterationCounter[element] === undefined) callBackIterationCounter[element] = 0;93 callBackIterationCounter[element] = callBackIterationCounter[element] + 1;94 if (_.isUndefined(callbacks[element]))  {95 return true; // No callback for this stage ? We continue compiling;96 } else {97 // try {98 let additionalInfo = {99 stage: element,100 step: step,101 iteration: callBackIterationCounter[element]102 };103 let ret = callbacks[element](graph, (_.isObject(data)) ? (_.assign(additionalInfo, data)) : (_.isUndefined(data) ? additionalInfo : data));104 if (_.isBoolean(ret)) {105 return ret;106 } else {107 throw new Error('Compilation stage callbacks should return a boolean (true to continue compilation, false to stop it), the callback for ' + element + ' returned ' + ret);108 }109 // } catch (e) {110 // return true;111 // }112 }113 }114 try {115 if (false === callCallback('addDefinitionToGraph')) return graph;116 //117 // linkInterfacesToDefinitions(graph);118 // if(false===callCallback('linkInterfacesToDefinitions')) return graph;119 //120 // expandInterfaces(graph);121 // if(false===callCallback('expandInterfaces')) return graph;122 addOperatorTypeAnnotation(graph);123 if (false === callCallback('addOperatorTypeAnnotation')) return graph;124 referentialTransparency(graph);125 if (false === callCallback('referentialTransparency')) return graph;126 linkInteractionsToDefinitions(graph);127 if (false === callCallback('linkInteractionsToDefinitions')) return graph;128 addInterfaceInformationToInteractions(graph);129 if (false === callCallback('addInterfaceInformationToInteractions')) return graph;130 expandDefinitions(graph);131 if (false === callCallback('expandDefinitions')) return graph;132 removeNonRootDefinitions(graph, rootDefinitionNode);133 if (false === callCallback('removeNonRootDefinitions')) return graph;134 clearSubInformation(graph);135 if (false === callCallback('clearSubInformation')) return graph;136 instantiateInterfaces(graph, rootDefinitionNode);137 if (false === callCallback('instantiateInterfaces')) return graph;138 linkArguments(graph, rootDefinitionNode);139 if (false === callCallback('linkArguments')) return graph;140 linkInterface(graph, rootDefinitionNode);141 if (false === callCallback('linkInterface')) return graph;142 keepOnlyInteractions(graph);143 if (false === callCallback('keepOnlyInteractions')) return graph;144 referentialTransparencyInstances(graph);145 if (false === callCallback('referentialTransparencyInstances')) return graph;146 createDataFlowDirection(graph);147 if (false === callCallback('createDataFlowDirection')) return graph;148 voidInteractionCreation(graph);149 if (false === callCallback('voidInteractionCreation')) return graph;150 behaviourSeparation(graph);151 if (false === callCallback('behaviourSeparation')) return graph;152 createDataFlowDirection(graph);153 if (false === callCallback('createDataFlowDirection')) return graph;154 functionLiteralLinking(graph);155 if (false === callCallback('functionLiteralLinking')) return graph;156 createDataFlowDirection(graph);157 if (false === callCallback('createDataFlowDirection')) return graph;158 dataLiteralLinking(graph);159 if (false === callCallback('dataLiteralLinking')) return graph;160 createDataFlowDirection(graph);161 if (false === callCallback('createDataFlowDirection')) return graph;162 functionApplicationLinking(graph);163 if (false === callCallback('functionApplicationLinking')) return graph;164 createDataFlowDirection(graph);165 if (false === callCallback('createDataFlowDirection')) return graph;166 previousNextLinking(graph);167 if (false === callCallback('previousNextLinking')) return graph;168 createDataFlowDirection(graph);169 if (false === callCallback('createDataFlowDirection')) return graph;170 tagCompositionElementEdges(graph);171 if (false === callCallback('tagCompositionElementEdges')) return graph;172 matchingCompositionReduction(graph);173 if (false === callCallback('matchingCompositionReduction')) return graph;174 createDataFlowDirection(graph);175 if (false === callCallback('createDataFlowDirection')) return graph;176 matchingCompositionReduction(graph);177 if (false === callCallback('matchingCompositionReduction')) return graph;178 createDataFlowDirection(graph);179 if (false === callCallback('createDataFlowDirection')) return graph;180 matchingCompositionReduction(graph);181 if (false === callCallback('matchingCompositionReduction')) return graph;182 createDataFlowDirection(graph);183 if (false === callCallback('createDataFlowDirection')) return graph;184 //TODO Should loop that, either in the method or here ... until fixed point185 linkIdentifiers(graph);186 if (false === callCallback('linkIdentifiers')) return graph;187 createDataFlowDirection(graph);188 if (false === callCallback('createDataFlowDirection')) return graph;189 matchingCompositionReduction(graph);190 if (false === callCallback('matchingCompositionReduction')) return graph;191 createDataFlowDirection(graph);192 if (false === callCallback('createDataFlowDirection')) return graph;193 matchingCompositionReduction(graph);194 if (false === callCallback('matchingCompositionReduction')) return graph;195 createDataFlowDirection(graph);196 if (false === callCallback('createDataFlowDirection')) return graph;197 matchingCompositionReduction(graph);198 if (false === callCallback('matchingCompositionReduction')) return graph;199 createDataFlowDirection(graph);200 if (false === callCallback('createDataFlowDirection')) return graph;201 //TODO Should loop that, either in the method or here ... until fixed point202 removeOneSidedAffectation(graph);203 if (false === callCallback('removeOneSidedAffectation')) return graph;204 createDataFlowDirection(graph);205 if (false === callCallback('createDataFlowDirection')) return graph;206 nonMatchingCompositionCompilation(graph);207 if (false === callCallback('nonMatchingCompositionCompilation')) return graph;208 affectationLinking(graph);209 if (false === callCallback('affectationLinking')) return graph;210 createDataFlowDirection(graph);211 if (false === callCallback('createDataFlowDirection')) return graph;212 nonMatchingCompositionCompilation(graph);213 if (false === callCallback('nonMatchingCompositionCompilation')) return graph;214 affectationLinking(graph);215 if (false === callCallback('affectationLinking')) return graph;216 createDataFlowDirection(graph);217 if (false === callCallback('createDataFlowDirection')) return graph;218 nonMatchingCompositionCompilation(graph);219 if (false === callCallback('nonMatchingCompositionCompilation')) return graph;220 affectationLinking(graph);221 if (false === callCallback('affectationLinking')) return graph;222 //TODO Should loop that too ... until fixed point ... but always end with another:223 createDataFlowDirection(graph);224 if (false === callCallback('createDataFlowDirection')) return graph;225 removeDuplicateEdge(graph);226 if (false === callCallback('removeDuplicateEdge')) return graph;227 resolveMultiplePorts(graph);228 if (false === callCallback('resolveMultiplePorts')) return graph;229 createDataFlowDirection(graph);230 if (false === callCallback('createDataFlowDirection')) return graph;231 instantiateTemplates(graph);232 if (false === callCallback('instantiateTemplates')) return graph;233 orderGraph(graph);234 if (false === callCallback('orderGraph')) return graph;235 keepOnlyOrdering(graph);236 if (false === callCallback('keepOnlyOrdering')) return graph;237 if (false === callCallback('graphTransformationPipeline')) return graph;238 return graph;239 } catch (e) {240 callCallback('error', {241 error: e,242 iteration: 1243 });244 throw (e);245 }...

Full Screen

Full Screen

redis-driver.js

Source:redis-driver.js Github

copy

Full Screen

...38 this.getUsers(function (users) {39 this.users = users || []40 this.getRoles(function (roles) {41 this.roles = roles || []42 this.callCallback(callback, null)43 }.bind(this))44 }.bind(this))45}46RedisDriver.prototype.setPrefix = function ( prefix ) {47 this.options.prefix = prefix48}49RedisDriver.prototype.createUser = function (userId, roles, callback) {50 var client = this.generateClient()51 var keyName = this.getKeyName( 'users' )52 client.hset(keyName, userId, JSON.stringify(roles), function (err, value) {53 54 client.quit()55 this.users.push({56 id: userId,57 roles: roles58 })59 this.callCallback(callback, null)60 }.bind(this))61}62RedisDriver.prototype.removeUserById = function (userId, callback) {63 var client = this.generateClient()64 var index = this.getUserIndexById(userId)65 if (index > -1) {66 this.users.splice(index, 1)67 }68 var keyName = this.getKeyName( 'users' )69 client.hdel(keyName, userId, function (err, value) {70 71 keyName = this.getKeyName( 'rules_user_' + userId )72 client.del(keyName, function (err, value) {73 client.quit()74 this.callCallback(callback, null)75 }.bind(this))76 }.bind(this))77}78RedisDriver.prototype.getUserById = function (userId, callback) {79 this.getUserIndexById(userId, function (index) {80 if (index < 0) {81 this.callCallback(callback, null)82 return83 }84 this.callCallback(callback, this.users[index])85 }.bind(this))86}87RedisDriver.prototype.getUserIndexById = function (userId, callback) {88 for (var u=0; u<this.users.length; u++) {89 var user = this.users[u]90 if (user.id == userId) {91 this.callCallback(callback, u)92 return93 }94 }95 this.callCallback(callback, -1)96}97RedisDriver.prototype.getUsers = function (callback) {98 var client = this.generateClient()99 var keyName = this.getKeyName( 'users' )100 client.hgetall(keyName, function (err, users) {101 client.quit()102 if (err) {103 console.log(err)104 this.callCallback(callback, null)105 return106 }107 if (!users) {108 this.callCallback(callback, null)109 return110 }111 var results = []112 for (var user in users) {113 if (users.hasOwnProperty(user)) {114 results.push({115 id: user,116 roles: JSON.parse(users[user])117 })118 }119 }120 this.callCallback(callback, results)121 }.bind(this))122}123RedisDriver.prototype.createRole = function (role, callback) {124 var client = this.generateClient()125 var keyName = this.getKeyName( 'roles' )126 var data = {}127 if (role.inherits) {128 data.inherits = role.inherits129 }130 if (role.permissions) {131 data.permissions = role.permissions132 }133 client.hset(keyName, role.name, JSON.stringify(data), function (err, value) {134 135 client.quit()136 this.callCallback(callback, null)137 }.bind(this))138}139RedisDriver.prototype.setRoles = function (roles, callback) {140 141 this.removeAllRoles(function (err) {142 async.eachSeries(roles, function (role, cb) {143 this.createRole( role, function (err) {144 cb(null)145 })146 147 }.bind(this),148 function done () {149 this.roles = roles150 this.callCallback(callback, null)151 }.bind(this)152 )153 }.bind(this))154}155RedisDriver.prototype.removeRoleByName = function (name, callback) {156 var client = this.generateClient()157 var index = this.getRoleIndexByName(name)158 if (index > -1) {159 this.roles.splice(index, 1)160 }161 var keyName = ''162 async.series(163 [164 function (cb) {165 // Get all role rules166 keyName = this.getKeyName( 'rules_role_' + name )167 client.smembers(keyName, function (err, rules) {168 // Remove all role rules169 keyName = this.getKeyName( 'rules' )170 async.eachSeries(rules, function (rule, cb2) {171 // Remove role rule172 client.srem(keyName, rule, function (err, value) {173 cb2(null)174 })175 },176 function done () {177 cb(null)178 }179 )180 }.bind(this))181 }.bind(this),182 function (cb) {183 // Remove role184 keyName = this.getKeyName( 'roles' )185 client.hdel(keyName, name, function (err, value) {186 187 // Remove role rule index188 keyName = this.getKeyName( 'rules_role_' + name )189 client.del(keyName, function (err, value) {190 cb(null)191 })192 }.bind(this))193 }.bind(this)194 ],195 function (err, results) {196 client.quit()197 this.callCallback(callback, null)198 }.bind(this)199 )200}201RedisDriver.prototype.removeAllRoles = function (callback) {202 var client = this.generateClient()203 var keyName = this.getKeyName( 'roles' )204 client.del(keyName, function (err) {205 206 client.quit()207 this.callCallback(callback, null)208 }.bind(this))209}210RedisDriver.prototype.getRoles = function (callback) {211 var client = this.generateClient()212 var keyName = this.getKeyName( 'roles' )213 client.hgetall(keyName, function (err, roles) {214 client.quit()215 if (err) {216 console.log(err)217 this.callCallback(callback, null)218 return219 }220 if (!roles) {221 this.callCallback(callback, null)222 return223 }224 var results = []225 for (var role in roles) {226 if (roles.hasOwnProperty(role)) {227 var data = JSON.parse(roles[role])228 data.name = role229 results.push(data)230 }231 }232 this.callCallback(callback, results)233 }.bind(this))234}235RedisDriver.prototype.getRoleByName = function (name, callback) {236 this.getRoleIndexByName(name, function (index) {237 if (index < 0) {238 this.callCallback(callback, null)239 return240 }241 this.callCallback(callback, this.roles[index])242 }.bind(this)) 243}244RedisDriver.prototype.getRoleIndexByName = function (name, callback) {245 for (var r=0; r<this.roles.length; r++) {246 var role = this.roles[r]247 if (role.name == name) {248 this.callCallback(callback, r)249 return250 }251 }252 this.callCallback(callback, -1)253}254RedisDriver.prototype.getRolePermissions = function (name, callback) {255 this.getRoleByName(name, function (uRole) {256 if (!uRole) {257 this.callCallback(callback, [])258 return 259 }260 var permissions = uRole.permissions || []261 if (uRole.inherits) {262 var roles = uRole.inherits.split(' ')263 async.eachSeries(roles, function (role, cb) {264 this.getRolePermissions( roles, function (result) {265 if (!result) {266 cb(null)267 return268 }269 permissions = permissions.concat( result )270 cb(null)271 })272 273 }.bind(this),274 function done () {275 this.callCallback(callback, _.uniq( permissions ))276 }.bind(this)277 )278 }279 else {280 this.callCallback(callback, _.uniq( permissions ))281 }282 }.bind(this))283}284RedisDriver.prototype.getInheritRoleNames = function (name, callback) {285 this.getRoleByName(name, function (role) {286 if (!role) {287 this.callCallback(callback, [])288 return 289 }290 var names = [name]291 if (role.inherits) {292 var inherits = role.inherits.split(' ')293 async.eachSeries(inherits, function (inherit, cb) {294 this.getInheritRoleNames( inherit, function (result) {295 if (!result) {296 cb(null)297 return298 }299 names = names.concat( result )300 cb(null)301 })302 303 }.bind(this),304 function done () {305 this.callCallback(callback, _.uniq( names ))306 }.bind(this)307 )308 }309 else {310 this.callCallback(callback, names)311 }312 }.bind(this))313}314RedisDriver.prototype.getUserRoles = function (user, callback) {315 var roles = []316 var names = []317 async.series(318 [319 function (cb) {320 async.eachSeries(user.roles, function (role, cb2) {321 this.getInheritRoleNames( role, function (result) {322 names = names.concat( result )323 cb2(null)324 })325 326 }.bind(this),327 function done () {328 cb(null)329 }.bind(this)330 )331 }.bind(this),332 function (cb) {333 names = _.uniq( names )334 async.eachSeries(names, function (name, cb2) {335 this.getRoleByName(name, function (role) {336 roles.push( role )337 cb2(null)338 })339 }.bind(this),340 function done () {341 cb(null)342 }.bind(this)343 )344 }.bind(this)345 ],346 function (err, results) {347 this.callCallback(callback, roles)348 }.bind(this)349 )350}351RedisDriver.prototype.createUserRule = function (userId, rule, callback) {352 var client = this.generateClient()353 var keyName = this.getKeyName( 'rules' )354 client.sadd(keyName, rule, function (err, value) {355 356 keyName = this.getKeyName( 'rules_user_' + userId )357 client.sadd(keyName, rule, function (err, value) {358 client.quit()359 this.callCallback(callback, null)360 }.bind(this))361 }.bind(this))362}363RedisDriver.prototype.removeUserRule = function (userId, rule, callback) {364 var client = this.generateClient()365 366 var keyName = this.getKeyName( 'rules' )367 client.srem(keyName, rule, function (err, value) {368 369 keyName = this.getKeyName( 'rules_user_' + userId )370 client.srem(keyName, rule, function (err, value) {371 372 client.quit()373 this.callCallback(callback, null)374 }.bind(this))375 }.bind(this))376}377RedisDriver.prototype.createRoleRule = function (name, rule, callback) {378 var client = this.generateClient()379 var keyName = this.getKeyName( 'rules' )380 client.sadd(keyName, rule, function (err, value) {381 382 keyName = this.getKeyName( 'rules_role_' + name )383 client.sadd(keyName, rule, function (err, value) {384 client.quit()385 this.callCallback(callback, null)386 }.bind(this))387 }.bind(this))388}389RedisDriver.prototype.removeRoleRule = function (name, rule, callback) {390 var client = this.generateClient()391 392 var keyName = this.getKeyName( 'rules' )393 client.srem(keyName, rule, function (err, value) {394 395 keyName = this.getKeyName( 'rules_role_' + name )396 client.srem(keyName, rule, function (err, value) {397 398 client.quit()399 this.callCallback(callback, null)400 }.bind(this))401 }.bind(this))402}403RedisDriver.prototype.removeAllRules = function (callback) {404 var client = this.generateClient()405 var keyName = this.getKeyName( 'rules' )406 client.del(keyName, function (err) {407 408 client.quit()409 this.callCallback(callback, null)410 }.bind(this))411}412RedisDriver.prototype.isRuleExists = function (rule, callback) {413 var client = this.generateClient()414 var keyName = this.getKeyName( 'rules' )415 client.sismember(keyName, rule, function (err, value) {416 417 client.quit()418 this.callCallback(callback, value)419 }.bind(this))420}421RedisDriver.prototype.getAllUserRules = function (userId, callback) {422 var rules = []423 this.getUserById(userId, function (user) {424 if (!user) {425 this.callCallback(callback, rules)426 return427 }428 this.getCustomUserRules(user.id, function (user_rules) {429 rules = rules.concat(user_rules)430 this.getUserRoles(user, function (roles) {431 async.eachSeries(roles, function (role, cb) {432 this.getRoleRules(role.name, function (role_rules) {433 rules = rules.concat(role_rules)434 cb(null)435 })436 }.bind(this),437 function done () {438 this.callCallback(callback, rules)439 }.bind(this)440 )441 }.bind(this))442 }.bind(this)) 443 }.bind(this))444}445RedisDriver.prototype.getCustomUserRules = function (userId, callback) {446 var client = this.generateClient()447 var keyName = this.getKeyName( 'rules_user_' + userId )448 client.smembers(keyName, function (err, rules) {449 450 client.quit()451 this.callCallback(callback, rules)452 }.bind(this))453}454RedisDriver.prototype.getRoleRules = function (name, callback) {455 var client = this.generateClient()456 var keyName = this.getKeyName( 'rules_role_' + name )457 client.smembers(keyName, function (err, rules) {458 459 client.quit()460 this.callCallback(callback, rules)461 }.bind(this))462}463RedisDriver.prototype.getRules = function (callback) {464 var client = this.generateClient()465 var keyName = this.getKeyName( 'rules' )466 client.smembers(keyName, function (err, rules) {467 468 client.quit()469 this.callCallback(callback, rules)470 }.bind(this))471}...

Full Screen

Full Screen

memory-driver.js

Source:memory-driver.js Github

copy

Full Screen

...18MemoryDriver.prototype.init = function (callback) {19 this.users = []20 this.roles = []21 this.rules = {}22 this.callCallback(callback, null)23}24MemoryDriver.prototype.createUser = function (userId, roles, callback) {25 this.users.push({26 id: userId,27 roles: roles28 })29 this.callCallback(callback, null)30}31MemoryDriver.prototype.getUsers = function (callback) {32 this.callCallback(callback, this.users)33}34MemoryDriver.prototype.getUserById = function (userId, callback) {35 for (var u=0; u<this.users.length; u++) {36 var user = this.users[u]37 if (user.id == userId) {38 this.callCallback(callback, user)39 return40 }41 }42 this.callCallback(callback, null)43}44MemoryDriver.prototype.createRole = function (role, callback) {45 this.roles.push( role )46 this.callCallback(callback, null)47}48MemoryDriver.prototype.removeRoleByName = function (name, callback) {49 var index = this.getRoleIndexByName(name)50 if (index > -1) {51 this.roles.splice(index, 1)52 }53 this.callCallback(callback, null)54}55MemoryDriver.prototype.removeAllRoles = function (callback) {56 this.roles = []57 this.callCallback(callback, null)58}59MemoryDriver.prototype.setRoles = function (roles, callback) {60 this.roles = roles61 this.callCallback(callback, null)62}63MemoryDriver.prototype.getRoles = function (callback) {64 this.callCallback(callback, this.roles)65}66MemoryDriver.prototype.getRoleByName = function (name, callback) {67 this.getRoleIndexByName(name, function (index) {68 if (index < 0) {69 this.callCallback(callback, null)70 return71 }72 this.callCallback(callback, this.roles[index])73 }.bind(this)) 74}75MemoryDriver.prototype.getRoleIndexByName = function (name, callback) {76 for (var r=0; r<this.roles.length; r++) {77 var role = this.roles[r]78 if (role.name == name) {79 this.callCallback(callback, r)80 return81 }82 }83 this.callCallback(callback, -1)84}85MemoryDriver.prototype.getRolePermissions = function (name, callback) {86 this.getRoleByName(name, function (uRole) {87 if (!uRole) {88 this.callCallback(callback, [])89 return 90 }91 var permissions = uRole.permissions || []92 if (uRole.inherits) {93 var roles = uRole.inherits.split(' ')94 async.eachSeries(roles, function (role, cb) {95 this.getRolePermissions( roles, function (result) {96 if (!result) {97 cb(null)98 return99 }100 permissions = permissions.concat( result )101 cb(null)102 })103 104 }.bind(this),105 function done () {106 this.callCallback(callback, _.uniq( permissions ))107 }.bind(this)108 )109 }110 else {111 this.callCallback(callback, _.uniq( permissions ))112 }113 }.bind(this))114}115MemoryDriver.prototype.getInheritRoleNames = function (name, callback) {116 this.getRoleByName(name, function (role) {117 if (!role) {118 this.callCallback(callback, [])119 return 120 }121 var names = [name]122 if (role.inherits) {123 var inherits = role.inherits.split(' ')124 async.eachSeries(inherits, function (inherit, cb) {125 this.getInheritRoleNames( inherit, function (result) {126 if (!result) {127 cb(null)128 return129 }130 names = names.concat( result )131 cb(null)132 })133 134 }.bind(this),135 function done () {136 this.callCallback(callback, _.uniq( names ))137 }.bind(this)138 )139 }140 else {141 this.callCallback(callback, names)142 }143 }.bind(this))144}145MemoryDriver.prototype.getUserRoles = function (user, callback) {146 var roles = []147 var names = []148 async.series(149 [150 function (cb) {151 async.eachSeries(user.roles, function (role, cb2) {152 this.getInheritRoleNames( role, function (result) {153 names = names.concat( result )154 cb2(null)155 })156 157 }.bind(this),158 function done () {159 cb(null)160 }.bind(this)161 )162 }.bind(this),163 function (cb) {164 names = _.uniq( names )165 async.eachSeries(names, function (name, cb2) {166 this.getRoleByName(name, function (role) {167 roles.push( role )168 cb2(null)169 })170 }.bind(this),171 function done () {172 cb(null)173 }.bind(this)174 )175 }.bind(this)176 ],177 function (err, results) {178 this.callCallback(callback, roles)179 }.bind(this)180 )181}182MemoryDriver.prototype.createRule = function (rule, callback) {183 this.rules[rule] = 1184 this.callCallback(callback, null)185}186MemoryDriver.prototype.createRoleRule = function (role, rule, callback) {187 this.createRule(rule, callback)188}189MemoryDriver.prototype.createUserRule = function (userId, rule, callback) {190 this.createRule(rule, callback)191}192MemoryDriver.prototype.removeRule = function (rule, callback) {193 delete this.rules[rule]194 this.callCallback(callback, null)195}196MemoryDriver.prototype.removeAllRules = function (callback) {197 this.rules = {}198 this.callCallback(callback, null)199}200MemoryDriver.prototype.setRules = function (rules, callback) {201 this.rules = rules202 this.callCallback(callback, null)203}204MemoryDriver.prototype.isRuleExists = function (rule, callback) {205 this.callCallback(callback, typeof this.rules[rule] !== 'undefined')206}207MemoryDriver.prototype.getRules = function (callback) {208 var r = []209 for (var name in this.rules) {210 if (this.rules.hasOwnProperty(name)) {211 r.push(name)212 }213 }214 this.callCallback(callback, r)215}...

Full Screen

Full Screen

driver.js

Source:driver.js Github

copy

Full Screen

...15 }16}17Driver.prototype.init = function (callback) {18 console.log('init - not implemented yet.')19 this.callCallback(callback, null)20}21Driver.prototype.createUser = function (userId, roles, callback) {22 console.log('createUser - not implemented yet.')23 this.callCallback(callback, null)24}25Driver.prototype.removeUserById = function (userId, callback) {26 console.log('removeUserById - not implemented yet.')27 this.callCallback(callback, null)28}29Driver.prototype.getUserById = function (userId, callback) {30 console.log('getUserById - not implemented yet.')31 this.callCallback(callback, null)32}33Driver.prototype.getUserIndexById = function (userId, callback) {34 console.log('getUserIndexById - not implemented yet.')35 this.callCallback(callback, null)36}37Driver.prototype.getUsers = function (callback) {38 console.log('getUsers - not implemented yet.')39 this.callCallback(callback, null)40}41Driver.prototype.createRole = function (role, callback) {42 console.log('createRole - not implemented yet.')43 this.callCallback(callback, null)44}45Driver.prototype.setRoles = function (roles, callback) {46 console.log('setRoles - not implemented yet.')47 this.callCallback(callback, null)48}49Driver.prototype.removeRoleByName = function (name, callback) {50 console.log('removeRoleByName - not implemented yet.')51 this.callCallback(callback, null)52}53Driver.prototype.removeAllRoles = function (callback) {54 console.log('removeAllRoles - not implemented yet.')55 this.callCallback(callback, null)56}57Driver.prototype.getRoles = function (callback) {58 console.log('getRoles - not implemented yet.')59 this.callCallback(callback, null)60}61Driver.prototype.getRoleByName = function (name, callback) {62 console.log('getRoleByName - not implemented yet.')63 this.callCallback(callback, null)64}65Driver.prototype.getRoleIndexByName = function (name, callback) {66 console.log('getRoleIndexByName - not implemented yet.')67 this.callCallback(callback, -1)68}69Driver.prototype.getRolePermissions = function (name, callback) {70 console.log('getRolePermissions - not implemented yet.')71 this.callCallback(callback, null)72}73Driver.prototype.getInheritRoleNames = function (name, callback) {74 console.log('getInheritRoleNames - not implemented yet.')75 this.callCallback(callback, null)76}77Driver.prototype.getUserRoles = function (user, callback) {78 console.log('getUserRoles - not implemented yet.')79 this.callCallback(callback, null)80}81Driver.prototype.createUserRule = function (userId, rule, callback) {82 console.log('createUserRule - not implemented yet.')83 this.callCallback(callback, null)84}85Driver.prototype.removeUserRule = function (userId, rule, callback) {86 console.log('removeUserRule - not implemented yet.')87 this.callCallback(callback, null)88}89Driver.prototype.createRoleRule = function (name, rule, callback) {90 console.log('createRoleRule - not implemented yet.')91 this.callCallback(callback, null)92}93Driver.prototype.removeRoleRule = function (name, rule, callback) {94 console.log('removeRoleRule - not implemented yet.')95 this.callCallback(callback, null)96}97Driver.prototype.removeAllRules = function (callback) {98 console.log('removeAllRules - not implemented yet.')99 this.callCallback(callback, null)100}101Driver.prototype.isRuleExists = function (rule, callback) {102 console.log('isRuleExists - not implemented yet.')103 this.callCallback(callback, null)104}105Driver.prototype.getGlobalRules = function (userId, callback) {106 console.log('getGlobalRules - not implemented yet.')107 this.callCallback(callback, null)108}109Driver.prototype.getUserRules = function (userId, callback) {110 console.log('getUserRules - not implemented yet.')111 this.callCallback(callback, null)112}113Driver.prototype.getRoleRules = function (name, callback) {114 console.log('getRoleRules - not implemented yet.')115 this.callCallback(callback, null)116}117Driver.prototype.getRules = function (callback) {118 console.log('getRules - not implemented yet.')119 this.callCallback(callback, null)120}121Driver.prototype.showRules = function (callback) {122 console.log()123 console.log('[Rules]')124 this.getRules(function (rules) {125 if (rules &&126 rules.length > 0) {127 for (var r=0; r<rules.length; r++) {128 console.log('rule: ' + rules[r])129 }130 }131 else {132 console.log('No rules.')133 }134 this.callCallback(callback, null)135 }.bind(this))136}137Driver.prototype.showUsers = function (callback) {138 console.log()139 console.log('[Users]')140 this.getUsers(function (users) {141 if (users &&142 users.length > 0) {143 for (var u=0; u<users.length; u++) {144 console.log('user: ', users[u])145 }146 }147 else {148 console.log('No users.')149 }150 this.callCallback(callback, null)151 }.bind(this))152}153Driver.prototype.showRoles = function (callback) {154 console.log()155 console.log('[Roles]')156 this.getRoles(function (roles) {157 if (roles &&158 roles.length > 0) {159 for (var r=0; r<roles.length; r++) {160 console.log('role: ', roles[r])161 }162 }163 else {164 console.log('No roles.')165 }166 this.callCallback(callback, null)167 }.bind(this))168}...

Full Screen

Full Screen

ReceiveNotificationsJob.js

Source:ReceiveNotificationsJob.js Github

copy

Full Screen

...14 while (response = await this.webhookServiceApi.receiveNotification()) {15 let webhookBody = response.body;16 if (webhookBody.typeWebhook === this.webhookServiceApi.noteTypes.incomingMessageReceived) {17 if (webhookBody.messageData.typeMessage == "imageMessage") {18 this.callCallback(this.webhookServiceApi.callbackTypes.onReceivingMessageImage, webhookBody)19 } else if (webhookBody.messageData.typeMessage == "videoMessage") {20 this.callCallback(this.webhookServiceApi.callbackTypes.onReceivingMessageVideo, webhookBody)21 } else if (webhookBody.messageData.typeMessage == "documentMessage") {22 this.callCallback(this.webhookServiceApi.callbackTypes.onReceivingMessageDocument, webhookBody)23 } else if (webhookBody.messageData.typeMessage == "audioMessage") {24 this.callCallback(this.webhookServiceApi.callbackTypes.onReceivingMessageAudio, webhookBody)25 } else if (webhookBody.messageData.typeMessage == "documentMessage") {26 this.callCallback(this.webhookServiceApi.callbackTypes.onReceivingMessageDocument, webhookBody)27 } else if (webhookBody.messageData.typeMessage == "textMessage") {28 this.callCallback(this.webhookServiceApi.callbackTypes.onReceivingMessageText, webhookBody)29 } else if (webhookBody.messageData.typeMessage == "extendedTextMessage") {30 this.callCallback(this.webhookServiceApi.callbackTypes.onReceivingMessageTextURL, webhookBody)31 } else if (webhookBody.messageData.typeMessage == "contactMessage") {32 this.callCallback(this.webhookServiceApi.callbackTypes.onReceivingMessageContact, webhookBody)33 } else if (webhookBody.messageData.typeMessage == "locationMessage") {34 this.callCallback(this.webhookServiceApi.callbackTypes.onReceivingMessageLocation, webhookBody)35 }36 } else if (webhookBody.typeWebhook === this.webhookServiceApi.noteTypes.stateInstanceChanged) { 37 this.callCallback(this.webhookServiceApi.callbackTypes.onReceivingAccountStatus, webhookBody)38 } else if (webhookBody.typeWebhook === this.webhookServiceApi.noteTypes.outgoingMessageStatus) { 39 this.callCallback(this.webhookServiceApi.callbackTypes.onReceivingOutboundMessageStatus, webhookBody)40 } else if (webhookBody.typeWebhook === this.webhookServiceApi.noteTypes.deviceInfo) { 41 this.callCallback(this.webhookServiceApi.callbackTypes.onReceivingDeviceStatus, webhookBody)42 }43 await this.webhookServiceApi.deleteNotification(response.receiptId);44 }45 } catch (ex) {46 console.error(ex.toString());47 }48 if (!this.needInterrupt) {49 this.timerId = setInterval(this.run, this.intervalSec * 1000);50 }51 }52 callCallback(webhookType, body) {53 const callback = this.webhookServiceApi._callbacks.get(webhookType)54 if (callback) {55 // Found webhook callback;56 callback.call(this, body);57 // Callback invoked successfully;58 } else {59 // Callback not found;60 };61 }62 63}...

Full Screen

Full Screen

others.simu.class.js

Source:others.simu.class.js Github

copy

Full Screen

...16 }.bind(this), parseInt(ms/5));17 }.bind(this));18 };19 Others.prototype.fermerStabilisateur = function(callback) {20 this.callCallback(callback, 200);21 };22 Others.prototype.ouvrirStabilisateurMoyen = function(callback) {23 this.callCallback(callback, 200);24 };25 26 Others.prototype.ouvrirStabilisateurGrand = function(callback) {27 this.callCallback(callback, 200);28 };29 Others.prototype.fermerBloqueur = function(callback) {30 this.callCallback(callback, 200);31 };32 Others.prototype.ouvrirBloqueurMoyen = function(callback) {33 this.callCallback(callback, 200);34 };35 Others.prototype.ouvrirBloqueurGrand = function(callback) {36 this.callCallback(callback, 200);37 };38 Others.prototype.sortirClap = function(callback) {39 this.callCallback(callback, 200);40 };41 Others.prototype.rangerClap = function(callback) {42 this.callCallback(callback, 200);43 };44 Others.prototype.prendreGobelet = function(callback) {45 this.callCallback(callback, 200);46 };47 Others.prototype.lacherGobelet = function(callback) {48 this.callCallback(callback, 200);49 };50 Others.prototype.monterAscenseur = function(callback) {51 this.callCallback(callback, 1000);52 };53 Others.prototype.monterUnPeuAscenseur = function(callback) {54 this.callCallback(callback, 300);55 };56 Others.prototype.descendreUnPeuAscenseur = function(callback) {57 this.callCallback(callback, 300);58 };59 Others.prototype.monterMoyenAscenseur = function(callback) {60 this.callCallback(callback, 500);61 };62 Others.prototype.descendreMoyenAscenseur = function(callback) {63 this.callCallback(callback, 500);64 };65 Others.prototype.descendreAscenseur = function(callback) {66 this.callCallback(callback, 1000);67 };68 69 return Others;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { callCallback } = require('playwright/lib/client/helper');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 await callCallback(page, 'evaluate', () => {7 const userAgent = navigator.userAgent;8 console.log(userAgent);9 });10 await browser.close();11})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { callCallback } = require("playwright/lib/utils/utils.js");2const { chromium } = require("playwright");3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 const [response] = await Promise.all([7 ]);8 await callCallback(response, "body");9 await browser.close();10})();11const { callCallback } = require("playwright/lib/utils/utils.js");12const { chromium } = require("playwright");13(async () => {14 const browser = await chromium.launch();15 const page = await browser.newPage();16 const [response] = await Promise.all([17 ]);18 await callCallback(response, "body");19 await browser.close();20})();21const { callCallback } = require("playwright/lib/utils/utils.js");22const { chromium } = require("playwright");23(async () => {24 const browser = await chromium.launch();25 const page = await browser.newPage();26 const [response] = await Promise.all([27 ]);28 await callCallback(response, "body");29 await browser.close();30})();31const { callCallback } = require("playwright/lib/utils/utils.js");32const { chromium } = require("playwright");33(async () => {34 const browser = await chromium.launch();35 const page = await browser.newPage();36 const [response] = await Promise.all([37 ]);38 await callCallback(response, "body");39 await browser.close();40})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { callCallback } = require('@playwright/test/lib/utils/utils');2const { test } = require('@playwright/test');3test('test', async ({ page }) => {4 await callCallback(async () => {5 });6});7PWTEST_PLAYWRIGHT_PATH="$(npm root -g)/playwright-core" npx playwright-test8test('my test', async ({ page }) => {9});10test('my test', async ({ page }) => {11 expect(await page.title()).toBe('Playwright');12});13test.describe('my suite', () => {14 test('my test', async ({ page }) => {15 expect(await page.title()).toBe('Playwright');16 });17});18test.skip('my test', async ({ page }) => {19});20test.fixme('my test', async ({ page }) => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2const { callCallback } = require('playwright/lib/server/cjs/utils/utils');3(async () => {4 const browser = await playwright['chromium'].launch();5 const page = await browser.newPage();6 await page.screenshot({ path: 'example.png' });7 await browser.close();8 callCallback('test');9})();10const playwright = require('playwright');11const { callCallback } = require('playwright/lib/server/cjs/utils/utils');12(async () => {13 const browser = await playwright['chromium'].launch();14 const page = await browser.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { callCallback } = require('playwright/lib/utils/utils');2const { test } = require('@playwright/test');3test('test', async ({ page }) => {4 await callCallback(async () => {5 }, 'goto');6});7[Apache 2.0](LICENSE)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { callCallback } = require('playwright/lib/utils/stackTrace');2const { test } = require('@playwright/test');3test('test', async ({ page }) => {4 await callCallback('test', async () => {5 await page.click('text="Get started"');6 });7});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { callCallback } = require('playwright/lib/internal/remote/callChannel');2const { BrowserContext } = require('playwright/lib/server/browserContext');3const { Page } = require('playwright/lib/server/page');4const { Frame } = require('playwright/lib/server/frame');5const { ElementHandle } = require('playwright/lib/server/elementHandler');6const context = new BrowserContext(null, null, null);7const page = new Page(null, context, null, null);8const frame = new Frame(null, page, null, null);9const elementHandle = new ElementHandle(null, frame, null, null);10callCallback(elementHandle, 'method', ['arg1', 'arg2'], 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful