How to use toHandlers method in Playwright Internal

Best JavaScript code snippet using playwright-internal

ablib.js

Source:ablib.js Github

copy

Full Screen

1/**2 *3 * Secure Addressing4 *5 * Copyright (C) 2014 Hiroya Matsuba6 *7 * This file is part of Secure Addressing8 *9 * Secure Addressing is free software: you can redistribute it and/or modify10 * it under the terms of the GNU General Public License as published by11 * the Free Software Foundation, either version 3 of the License, or12 * (at your option) any later version.13 *14 * Secure Addressing is distributed in the hope that it will be useful,15 * but WITHOUT ANY WARRANTY; without even the implied warranty of16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the17 * GNU General Public License for more details.18 *19 * You should have received a copy of the GNU General Public License20 * along with Foobar. If not, see <http://www.gnu.org/licenses/>.21 *22**/23var EXPORTED_SYMBOLS = ["getAbEnt", "makeDataFromCard"];24var ttldb = 3 * 24 * 3600;25Components.utils.import("resource://gre/modules/Timer.jsm");26Components.utils.import("chrome://secure-addressing/content/log.js");27Components.utils.import("chrome://secure-addressing/content/memcache.js");28Components.utils.import("resource://gre/modules/Services.jsm");29Components.utils.import("resource://gre/modules/FileUtils.jsm");30var ldapHandler = new Object();31var abManager = Components.classes["@mozilla.org/abmanager;1"]32 .getService(Components.interfaces.nsIAbManager);33function makeDataFromCard(card) {34 if (!card) {35 return null;36 }37 let ret;38 try {39 ret = {40 email: card.primaryEmail,41 name: card.displayName,42 company: card.getProperty("Company", "") ,43 department: card.getProperty("Department", "") ,44 title: card.getProperty("JobTitle", ""),45 phone: card.getProperty("WorkPhone", ""),46 address: card.getProperty("WorkAddress", ""),47 };48 } catch (e) {49 err("error in making data from card: " + e + "\n");50 ret = null;51 }52 return ret;53}54var abListener = {55 onItemAdded: function(parentdir, item) {56 //dbg("item added\n");57 if (!(item instanceof Components.interfaces.nsIAbCard)) {58 return;59 }60 if (!(parentdir instanceof Components.interfaces.nsIAbDirectory)) {61 return;62 }63 let email = item.primaryEmail;64 let name = item.displayName;65 //dbg("got: " + email + " = " + name + "\n");66 let uri = parentdir.URI;67 let obj;68 if (uri in ldapHandler) {69 obj = ldapHandler[uri];70 } else {71 }72 let data = makeDataFromCard(item);73 if (obj && data) {74 obj.ldap_handler(data);75 } else {76 //dbg("no handler\n");77 if (!parentdir.isRemote) {78 memcacheInvalidate(email);79 }80 }81 },82 onItemRemoved: function(parentdir, item) {83 if (!(parentdir instanceof Components.interfaces.nsIAbDirectory)) {84 return;85 }86 if (!(item instanceof Components.interfaces.nsIAbCard)) {87 return;88 }89 if (!parentdir.isRemote) {90 memcacheInvalidate(item.primaryEmail);91 }92 },93 onItemPropertyChanged: function(item, aProperty, aOldValue, aNewValue) {94 if (!(item instanceof Components.interfaces.nsIAbCard)) {95 return;96 }97 memcacheInvalidate(item.primaryEmail);98 }99};100abManager.addAddressBookListener(abListener, Components.interfaces.nsIAbListener.all);101var dbs = new Object();102var queries = new Object();103function dbQuery(dbname) {104 let mDBConn;105 try {106 let file = FileUtils.getFile("ProfD", ["ldapcache.sqlite"]);107 mDBConn = Services.storage.openDatabase(file);108 mDBConn.executeSimpleSQL("CREATE TABLE IF NOT EXISTS " + dbname +109 " (email TEXT PRIMARY KEY, name TEXT, " +110 "company TEXT, department TEXT, title TEXT, " +111 "phone TEXT, address TEXT, lastupdate INTEGER)");112 } catch(e) {113 err("create table error " + e + "\n");114 }115 let obj = this;116 this.dbconn = mDBConn;117 this.add_data = function(data) {118 if (!data) {119 return;120 }121 let st = this.dbconn.createAsyncStatement("INSERT INTO " + dbname + 122 " VALUES(:email, :name, " +123 ":company, :department, :title, :phone, " +124 ":address, :lastupdate)");125 //st.params.dbname = dbname;126 st.params.email = data.email;127 st.params.name = data.name;128 st.params.company = data.company;129 st.params.department = data.department;130 st.params.title = data.title;131 st.params.phone = data.phone;132 st.params.address = data.address;133 st.params.lastupdate = 0;134 let asyncHandler = {135 handleResult : function(result) {},136 handleError : function(err) {},137 handleCompletion : function(reason) {138 let st2 = obj.dbconn.createAsyncStatement("UPDATE " + dbname +139 " SET lastupdate = " +140 ":lastupdate WHERE email = :email");141 //st2.params.dbname = dbname;142 st2.params.email = data.email;143 st2.params.lastupdate = Date.now();144 st2.executeAsync({handleResult: function(){return;},145 handleError: function(){return;},146 handleCompletion: function(){return;}});147 }148 };149 st.executeAsync(asyncHandler); 150 };151 this.search = function(email, callback, param) {152 let st;153 try {154 st = mDBConn.createAsyncStatement("SELECT * FROM " + dbname + " WHERE email = :email");155 st.params.email = email;156 } catch(e) {157 err("db error " + e + "\n");158 }159 let all_results = new Array();160 var asyncHndler = {161 handleResult: function(results) {162 for(let row = results.getNextRow(); row; row = results.getNextRow()) {163 try {164 var ret = {165 email: row.getResultByName("email"),166 name: row.getResultByName("name"),167 company: row.getResultByName("company"),168 department: row.getResultByName("department"),169 title: row.getResultByName("title"),170 phone: row.getResultByName("phone"),171 address: row.getResultByName("address"),172 lastupdate: row.getResultByName("lastupdate"),173 };174 all_results.push(ret);175 } catch(e) {176 err("error in receiving DB: " + e + "\n");177 }178 }179 },180 handleError: function(aError) {181 err("callback error " + aError.message + " " + aError.result + "\n");182 },183 handleCompletion: function(aReason) {184 if (!callback) {185 return;186 }187 if (aReason != Components.interfaces.mozIStorageStatementCallback.REASON_FINISHED) {188 callback(param, null, 3);189 return;190 }191 if ((all_results.length > 0) &&192 (Date.now() - all_results[0].lastupdate < ttldb * 1000)) {193 callback(param, all_results[0], 0);194 } else {195 callback(param, null, 4);196 }197 return;198 },199 };200 st.executeAsync(asyncHndler);201 return;202 };203}204function getDB(dbname) {205 if (dbname in dbs) {206 return dbs[dbname];207 } else {208 let n = new dbQuery(dbname);209 dbs[dbname] = n;210 return n;211 }212}213function saQuery(ab, baseuri, cache, email) {214 let dbname = baseuri.replace("://", "_").replace(/-/g, "_").replace(/\./g, "_");215 let mDBConn = null;216 this.dbquery = getDB(dbname);217 let obj = this;218 this.cache = cache;219 this.dbconn = mDBConn;220 this.queryURI = ab.URI;221 this.addressBook = ab;222 this.dbname = dbname;223 this.handlers = new Array();224 this.tohandlers = new Array();225 this.register_handler = function(func, param) {226 /* call now for already known addresses */227 for(let i = 0; i < this.cards.length; i++) {228 func(param, this.cards[i], true);229 }230 let item = {func: func, param: param};231 this.handlers.push(item);232 return;233 };234 this.register_tohandler = function(func) {235 if (func) {236 this.tohandlers.push(func);237 }238 };239 this.call_handler = function(data) {240 for(let i = 0; i < this.handlers.length; i++) {241 let func = this.handlers[i].func;242 let param = this.handlers[i].param;243 func(param, data, true);244 }245 };246 this.cards = new Array();247 this.ldap_handler = function(data) {248 if (obj.dbquery) {249 obj.dbquery.add_data(data);250 }251 obj.cards.push(data);252 obj.call_handler([data]);253 //dbg("found card: data = " + data.name + "\n");254 if (obj.timeout2) {255 try {256 clearTimeout(obj.timerID);257 obj.timerID = setTimeout(function() {obj.timer_expired();}, 258 obj.timeout2 * 1000);259 } catch(e) {260 err("error " + e + "\n");261 }262 }263 };264 this.ldapsearch = function() {265 ldapHandler[this.queryURI] = this;266 let cards = obj.addressBook.childCards;267 while (cards.hasMoreElements()) {268 let card = cards.getNext();269 if (card instanceof Components.interfaces.nsIAbCard) {270 err("chid card found in LDAP dir\n");271 }272 }273 };274 this.timerID = -1;275 this.nexpire = 0;276 this.timer_expired = function() {277 //dbg("timer expired: " + obj.nexpire + "\n");278 obj.nexpire++;279 if (obj.cards.length == 0) {280 obj.call_handler([]);281 if (cache) {282 let adddata = {283 email: email, name: "", company: "", department: "",284 title: "", phone: "", address: "",285 };286 //obj.dbquery.add_data(adddata);287 }288 }289 if (obj.queryURI in ldapHandler) {290 delete ldapHandler[obj.queryURI];291 }292 if (obj.queryURI in queries) {293 delete queries[obj.queryURI];294 }295 for(let i = 0; i < obj.tohandlers.length; i++) {296 let func = obj.tohandlers[i];297 func();298 }299 obj.handlers = null;300 obj.tohandlers = null;301 };302 this.issued = false;303 this.search = function(func, arg, timeo, timeo2, tohndl) {304 let obj = this;305 if (!timeo) {306 timeo = 10 * 1000;307 } else {308 timeo = timeo * 1000;309 }310 if (this.timerID >= 0) {311 clearTimeout(this.timerID);312 }313 this.timeout2 = timeo2;314 this.timerID = setTimeout(function() {obj.timer_expired();}, timeo);315 this.register_handler(func, arg);316 this.register_tohandler(tohndl);317 if (this.issued) {318 return;319 }320 this.issued = true;321 if (cache) {322 let cachecb = function(dummy, data, error) {323 if (data) {324 obj.cards.push(data);325 obj.call_handler([data]);326 } else {327 try{328 obj.ldapsearch();329 } catch(e) {330 err(e);331 }332 } 333 return;334 };335 this.dbquery.search(email, cachecb, 0);336 } else {337 this.ldapsearch();338 }339 return;340 };341}342function getQuery(ab, baseuri, cache, email) {343 let quri = ab.URI;344 if (quri in queries) {345 return queries[quri];346 } else {347 let n = new saQuery(ab, baseuri, cache, email);348 queries[quri] = n;349 return n;350 }351}352function analyzeQuery(condition) {353 let uc = true;354 let email;355 let total = 0;356 let str = "?(and";357 for(let i = 0; i < condition.length; i++) {358 let ci = condition[i];359 let substr = "(or";360 for(let j = 0; j < ci.length; j++) {361 if ((total != 0) || 362 (ci[j].key != "PrimaryEmail") ||363 (ci[j].op != "=")) {364 uc = false;365 }366 let subsubstr = "(" + ci[j].key + "," + ci[j].op + "," +367 encodeURIComponent(ci[j].value) + ")";368 substr += subsubstr;369 email = ci[j].value;370 total++;371 }372 substr += ")";373 str += substr;374 }375 str += ")";376 //dbg("query = " + str + ", cache = " + uc + "\n");377 if (!uc) {378 email = "";379 }380 return {str: str, cache: uc, email:email};381}382function getAbEnt(uri, query, func, arg, timeo, timeo2, tohndl) {383 let q = analyzeQuery(query);384 let abURI = uri + q.str;385 let ab;386 try {387 ab = abManager.getDirectory(abURI);388 } catch(e) {389 func(arg, [], false);390 return;391 }392 if (ab.isRemote) {393 //dbg("abent remote: " + abURI);394 let rq = getQuery(ab, uri, q.cache, q.email);395 rq.search(func, arg, timeo, timeo2, tohndl);396 return 0;397 }398 399 let cards = ab.childCards;400 let cary = new Array();401 while (cards.hasMoreElements()) {402 let card = cards.getNext();403 if (card instanceof Components.interfaces.nsIAbCard) {404 let c = makeDataFromCard(card);405 cary.push(c);406 }407 }408 func(arg, cary, false);409 return 0;...

Full Screen

Full Screen

BasePage.js

Source:BasePage.js Github

copy

Full Screen

1function GetFormControl(tsControlName){2 var loForm = GetMainForm();3 if(loForm!=null) return loForm[tsControlName];4 else return null;5}6function GetMainForm(){7 if(document.forms.length>0){8 return document.forms[0];9 }else{10 return null;11 }12}13function BoundHyperlink_onclick(toHyperlink, tsPostAction){14 if(toHyperlink.PostBack=="1"){15 var loForm = GetMainForm();16 var lsOldPostAction = "";17 if(tsPostAction!=null){18 lsOldPostAction = loForm["MnfPostAction"].value;19 loForm["MnfPostAction"].value = tsPostAction;20 }21 loForm[toHyperlink.KeyQueryName].value = toHyperlink.KeyValue;22 NetPostBack("","");23 if(tsPostAction!=null) loForm["MnfPostAction"].value = lsOldPostAction;24 }else25 SubmitUrl(toHyperlink.href, tsPostAction);26 return false;27}28function SubmitUrl(tsUrl, tsPostAction){29 var loForm = GetMainForm();30 var lsOldAction = loForm.action;31 var lsOldPostAction = "";32 if(tsPostAction!=null){33 lsOldPostAction = loForm["MnfPostAction"].value;34 loForm["MnfPostAction"].value = tsPostAction;35 }36 loForm.action = tsUrl;37 if(loForm.__VIEWSTATE!=null) loForm.__VIEWSTATE.name="___VIEWSTATE";38 if(loForm.__EVENTTARGET!=null) loForm.__EVENTTARGET.name="___EVENTTARGET";39 if(loForm.__EVENTARGUMENT!=null) loForm.__EVENTARGUMENT.name="___EVENTARGUMENT";40 loForm.submit();41 loForm.action = lsOldAction;42 if(tsPostAction!=null) loForm["MnfPostAction"].value = lsOldPostAction;43 return true;44}45function PostBackForm(tsTarget, tsPostAction){46 var loForm = GetMainForm();47 var lsOldTarget = loForm.target;48 var lsOldPostAction = "";49 if(tsPostAction!=null){50 lsOldPostAction = loForm["MnfPostAction"].value;51 loForm["MnfPostAction"].value = tsPostAction;52 }53 if(tsTarget!=null&&tsTarget!="") loForm.target = tsTarget;54 if(typeof(MnfOnSubmit) != "undefined") MnfOnSubmit();55 loForm.submit();56 loForm.target = lsOldTarget;57 if(tsPostAction!=null) loForm["MnfPostAction"].value = lsOldPostAction;58}59function PostBackToParent(){60 var loParent = GetDialogParent();61 var lsOldParentName = loParent.name;62 loParent.name = "ParentWindow";63 PostBackForm("ParentWindow");64 loParent.name =lsOldParentName;65}66function PostBackSortAction(tsSortFields){67 var loForm = GetMainForm();68 loForm.VicDataGrid_SortFields.value = tsSortFields;69 NetPostBack('','');70}71function NetPostBack(eventTarget, eventArgument) {72 var theform;73 if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {74 theform = document.Form1;75 }76 else {77 theform = document.forms["Form1"];78 }79 80 if(theform==null) theform=GetMainForm();81 82 if(theform.__EVENTTARGET!=null) theform.__EVENTTARGET.value = eventTarget.split("$").join(":");83 if(theform.__EVENTARGUMENT!=null) theform.__EVENTARGUMENT.value = eventArgument;84 theform.submit();85}86function AppendQueryString(tsURL, tsQueryString){87 var lsURL = new String(tsURL);88 var lnIndex = lsURL.indexOf("?");89 if(tsQueryString=="") return tsURL;90 if(lnIndex>=0){91 return tsURL+"&"+tsQueryString; 92 }else{93 return tsURL+"?"+tsQueryString;94 }95}96function GetAppPath(){97 var loForm = GetMainForm();98 if(loForm.MNF_AppPath!=null) return "/"+loForm.MNF_AppPath.value;99 return "";100}101function AppendAppPath(tsUrl){102 if(tsUrl.substring(0,1)=="/")103 return GetAppPath()+tsUrl;104 else105 return tsUrl;106}107function GetDialogParent(){108 return window.parent.opener;109}110function DialogArgu(){111 this.Action = "";112}113function OpenDialog(tsURL,toArgu,tsInputParameters, tnWidth,tnHeight,tnTop,tnLeft,tsStyle)114{115 var lsStyle="resizable:yes;status=no;dialogHeight:"+tnHeight+"px;dialogWidth:"+tnWidth+"px;";116 lsStyle = lsStyle+";"+tsStyle; 117 var loArgus = new Object();118 if(tsURL.indexOf("?") != -1)119 tsURL += "&RIDD="+Math.random()120 else121 tsURL += "?RIDD="+Math.random()122 loArgus.Url = tsURL;123 loArgus.Opener = window;124 loArgus.Argu = toArgu;125 loArgus.InputParameters = tsInputParameters;126 window.showModalDialog("/MyFramework/SystemFrame/DialogFrame.aspx",loArgus ,lsStyle);127 return true;128}129function OpenWindow(tsURL, tsWindowName,tnWidth, tnHeight){130 var sW=screen.width;131 var sH=screen.height;132 var wL=(sW-tnWidth)/2;133 var wH=(sH-tnHeight)/2;134 var Win = window.open(tsURL,tsWindowName,'width=' + tnWidth + ',height=' + tnHeight + ',resizable=yes,scrollbars=yes,menubar=no,status=yes,left='+wL+',top='+wH);135}136function CallHandlers(toHandlers){137 for(var lnIndex=0; lnIndex<toHandlers.length; lnIndex++){138 if(lnIndex>0)toHandlers[lnIndex]();139 }140 if(toHandlers.length>0&&toHandlers[0]!=null) toHandlers[0]();141}142function showsubmenu(sid)143{144 145 var lsOldMenuId=document.getElementById("OldleftId");146 whichEl = eval("submenu" + sid);147 whichEl1 = eval("menuTitle" + sid);148 if (whichEl.style.display == "none")149 {150 var lsOldMenuId=document.getElementById("OldleftId");151 if(lsOldMenuId.value!="")152 {153 eval("submenu" + lsOldMenuId.value + ".style.display=\"none\";");154 eval("menuTitle" + lsOldMenuId.value + ".background=\"/MyFramework/Image/GLeftImage/crm_left.gif\";");155 156 }157 lsOldMenuId.value=sid;158 eval("submenu" + sid + ".style.display=\"\";");159 whichEl1.background="/MyFramework/Image/GLeftImage/crm_left1.gif";160 }161 else162 {163 eval("submenu" + sid + ".style.display=\"none\";");164 whichEl1.background="/MyFramework/Image/GLeftImage/crm_left.gif";165 }166 167}168function mouseover(sid)169{170 whichEl = eval("menuTitle" + sid);171 whichEl.background="/MyFramework/Image/TopImage/anniu_left_01.gif";172 173}174function mouseout(sid)175{176 whichEl = eval("submenu" + sid);177 whichEl1 = eval("menuTitle" + sid);178 if (whichEl.style.display == "none")179 {180 whichEl1.background="/MyFramework/Image/GLeftImage/crm_left.gif";181 }182 else183 whichEl1.background="/MyFramework/Image/GLeftImage/crm_left1.gif";184}185 //Çå¿ÕÒ³ÃæÊäÈëÐÅÏ¢ 186 function InputBlank()187 {188 var InputObj = document.all.tags("input");189 var TextAreaObj= document.all.tags("textarea");190 191 for( var i=0; i<InputObj.length; i++ )192 {193 if( InputObj[i].type.toLowerCase() == "text" )194 {195 InputObj[i].value = "";196 }197 }198 199 for(var j = 0; j<TextAreaObj.length; j++)200 {201 TextAreaObj[j].value = "";202 }203 204 }205 206 207//µÃµ½µ±Ç°¶ÔÏóµÄleftºÍTop Öµ208function getObjectLeft(toObject){ 209 var lnLeftValue = toObject.offsetLeft; 210 while(toObject = toObject.offsetParent){ 211 lnLeftValue += toObject.offsetLeft; 212 } 213 return lnLeftValue; 214} 215function getObjectTop(toObject){ 216 var lnTopValue = toObject.offsetTop; 217 while(toObject=toObject.offsetParent){ 218 lnTopValue += toObject.offsetTop; 219 } 220 return lnTopValue;221}222//Çå³ýËùÓÐÑ¡Ïî223function clearOptions(toList){224 for(var lnIndex=toList.options.length-1; lnIndex>=0; lnIndex--){225 toList.options[lnIndex]= null;226 } 227}228//µÃµ½Ñ¡ÔñµÄÑ¡Ïî229function getSelectedOption(toList){230 for(var lnIndex=0; lnIndex<toList.options.length; lnIndex++){231 if(toList.options[lnIndex].selected){232 return toList.options[lnIndex];233 }234 }235 return null; 236}237function hidebar(){238 lsLeftMenuTableName="";239 if(document.all["tbcrmleftmenu"]!=undefined)240 lsLeftMenuTableName = "tbcrmleftmenu";241 else242 return false; 243 if(document.all[lsLeftMenuTableName].style.display=="none"){244 document.all["igHideBarImpage"].src='/MyFramework/Image/GLeftImage/framehide.gif';245 document.all[lsLeftMenuTableName].style.display = "block";246 }else{247 document.all[lsLeftMenuTableName].style.display = "none";248 document.all["igHideBarImpage"].src='/MyFramework/Image/GLeftImage/frameshow.gif';249 }250 return true;251}252//window.history.forward(1);// ʹµã»÷Â乤¾ßÌõÉϺóÍËÓëÇ°½ø°´Å¥ÎÞЧ 253document.onkeydown=function ShieldBack()254{ 255 if ((event.altKey)&&((event.keyCode==37)|| //ÆÁ±ÎAlt+ ·½Ïò¼ü ¡û256 (event.keyCode==39))){ //ÆÁ±ÎAlt+ ·½Ïò¼ü ¡ú257 //alert("²»×¼ÄãʹÓÃALT+·½Ïò¼üÇ°½ø»òºóÍËÍøÒ³£¡"); 258 event.returnValue=false; 259 } 260 if ((event.keyCode == 8) && (event.srcElement.type != "text" && event.srcElement.type != "textarea" && event.srcElement.type != "password")) { 261 //ÆÁ±ÎBackSpace¼ü262 event.keyCode = 0; 263 event.cancelBubble = true; 264 event.returnValue=false; 265 } 266}267/* ËÄÉáÎåÈë268 * ForRound(Dight,How):ÊýÖµ¸ñʽ»¯º¯Êý£¬DightÒª 269 * ¸ñʽ»¯µÄÊý×Ö£¬HowÒª±£ÁôµÄСÊýλÊý¡£ 270 */ 271function ForRound(Dight,How) 272{273 Dight = Math.round(Dight*Math.pow(10,How))/Math.pow(10,How); 274 return Dight; ...

Full Screen

Full Screen

powerConsumption.js

Source:powerConsumption.js Github

copy

Full Screen

1import * as consts from '../../../consts';2import S6FInstaPowerToHourly from '../../events/mapper/toHandlers/s6fresnel/S6FInstaPowerToHourly';3import S6InstaPowerToAlert from '../../events/mapper/toHandlers/s6fresnel/S6InstaPowerToAlert';4import SONInstaPowerToHourly from '../../events/mapper/toHandlers/sonoff/SONInstaPowerToHourly';5import SONDailyConsumeToDaily from '../../events/mapper/toHandlers/sonoff/SONDailyConsumeToDaily';6const PowerConsumptionRules = (ruleEngine, {7 hourlyStatHandler,8 dailyStatHandler,9 updateOnlineStatusHandler,10 powerAlertHandler,11 closeAlertHandler,12}) => {13 // S6 Instant power message14 ruleEngine.add({15 predicate: msg => msg.Type === consts.EVENT_TYPE_FRESNEL_POWER_CONSUME ||16 msg.Type === consts.EVENT_TYPE_TOPIC_POWER_CONSUME,17 fn: (msg) => {18 hourlyStatHandler.process(S6FInstaPowerToHourly(msg));19 updateOnlineStatusHandler.process(S6FInstaPowerToHourly(msg));20 },21 });22 // S6 Alert if power < 0.123 ruleEngine.add({24 predicate: msg => (msg.Type === consts.EVENT_TYPE_FRESNEL_POWER_CONSUME ||25 msg.Type === consts.EVENT_TYPE_TOPIC_POWER_CONSUME) &&26 msg.Payload.value < 0.1,27 fn: (msg) => {28 powerAlertHandler.process(S6FInstaPowerToHourly(msg));29 },30 });31 // Close power Alert if power >= 0.132 ruleEngine.add({33 predicate: msg => (msg.Type === consts.EVENT_TYPE_FRESNEL_POWER_CONSUME ||34 msg.Type === consts.EVENT_TYPE_TOPIC_POWER_CONSUME) &&35 msg.Payload.value >= 0.1,36 fn: (msg) => {37 closeAlertHandler.process(S6InstaPowerToAlert(msg));38 },39 });40 // Sonoff Instan power message41 ruleEngine.add({42 predicate: msg => msg.Type === consts.EVENT_TYPE_ENERGY,43 fn: (msg) => {44 hourlyStatHandler.process(SONInstaPowerToHourly(msg));45 dailyStatHandler.process(SONDailyConsumeToDaily(msg));46 updateOnlineStatusHandler.process(SONInstaPowerToHourly(msg));47 powerAlertHandler.process(SONInstaPowerToHourly(msg));48 },49 });50};...

Full Screen

Full Screen

simple-drag-pkg.esm.js

Source:simple-drag-pkg.esm.js Github

copy

Full Screen

...36 return (openBlock(), createElementBlock("div", mergeProps({37 class: "sen-drag",38 draggable: "true",39 style: _ctx.style40 }, toHandlers(_ctx.events)), toDisplayString(_ctx.text), 17 /* TEXT, FULL_PROPS */))41}42script.render = render;43script.__scopeId = "data-v-0e50d8ad";44script.__file = "src/Drag.vue";45const components = [script];46function install(app) {47 components.forEach((component) => {48 app.component(component.name, component);49 });50}51var index = {52 install,53};54export { script as Drag, index as default };

Full Screen

Full Screen

lwtRules.js

Source:lwtRules.js Github

copy

Full Screen

1import * as consts from '../../../consts';2import SONLwtToHandler from '../../events/mapper/toHandlers/sonoff/SONLwtToHandler';3import S6LwtToHandler from '../../events/mapper/toHandlers/s6fresnel/S6LwtToHandler';4import lwtAPPEventToHandler from '../../events/mapper/toHandlers/appEvents/lwtAPPEventToHandler';5import lwtAPPEventToAlertHandler from '../../events/mapper/toHandlers/appEvents/lwtAppEventToAlertHandler';6import { STATUS_OFFLINE, STATUS_ONLINE } from '../../common/lwtConsts';7const LwtRules = (ruleEngine, {8 lwtHandler,9 closeAlertHandler,10 lwtStatusAlertHandler,11}) => {12 /* Sonoff */13 ruleEngine.add({14 predicate: msg => msg.Type === consts.EVENT_TYPE_LWT,15 fn: msg => lwtHandler.process(SONLwtToHandler(msg)),16 });17 /* Alerts */18 ruleEngine.add({19 predicate: msg => (msg.type === consts.APPEVENT_TYPE_LWT_ALERT &&20 msg.status === STATUS_OFFLINE),21 fn: msg => lwtStatusAlertHandler.process(lwtAPPEventToHandler(msg)),22 });23 ruleEngine.add({24 predicate: msg => (msg.type === consts.APPEVENT_TYPE_LWT_ALERT &&25 msg.status === STATUS_ONLINE),26 fn: msg => closeAlertHandler.process(lwtAPPEventToAlertHandler(msg)),27 });28 /* S6 Fresnel device */29 ruleEngine.add({30 predicate: msg => msg.Type === consts.EVENT_TYPE_FRESNEL_LWT ||31 msg.Type === consts.EVENT_TYPE_TOPIC_LWT,32 fn: msg => lwtHandler.process(S6LwtToHandler(msg)),33 });34};...

Full Screen

Full Screen

deviceRulse.js

Source:deviceRulse.js Github

copy

Full Screen

1import * as consts from '../../../consts';2import S6InfoToDevice from '../../events/mapper/toHandlers/s6fresnel/S6InfoToDevice';3import S6InfoToDeviceGroups from '../../events/mapper/toHandlers/s6fresnel/S6InfoToDeviceGroups';4import S6CrontabToDeviceCrontab from '../../events/mapper/toHandlers/s6fresnel/S6CrontabToDeviceCrontab';5import SONInfoToDevice from '../../events/mapper/toHandlers/sonoff/SONInfoToDevice';6const DeviceInfoRules = (ruleEngine, {7 deviceHandler,8 deviceGroupsHandler,9 deviceCrontabHandler,10}) => {11 ruleEngine.add({12 predicate: msg => msg.Type === consts.EVENT_TYPE_INFO,13 fn: msg => deviceHandler.process(SONInfoToDevice(msg)),14 });15 ruleEngine.add({16 predicate: msg => msg.Type === consts.EVENT_TYPE_FRESNEL_INFO ||17 msg.Type === consts.EVENT_TYPE_TOPIC_INFO,18 fn: (msg) => {19 deviceHandler.process(S6InfoToDevice(msg));20 deviceGroupsHandler.process(S6InfoToDeviceGroups(msg));21 },22 });23 ruleEngine.add({24 predicate: msg => msg.Type === consts.EVENT_TYPE_TOPIC_CRONTAB,25 fn: msg => deviceCrontabHandler.process(S6CrontabToDeviceCrontab(msg)),26 });27};...

Full Screen

Full Screen

collapse-transition.vue_vue_type_template_id_f68ae30a_lang.mjs

Source:collapse-transition.vue_vue_type_template_id_f68ae30a_lang.mjs Github

copy

Full Screen

1import { openBlock, createBlock, Transition, toHandlers, withCtx, renderSlot } from 'vue';2function render(_ctx, _cache, $props, $setup, $data, $options) {3 return openBlock(), createBlock(Transition, toHandlers(_ctx.on), {4 default: withCtx(() => [5 renderSlot(_ctx.$slots, "default")6 ]),7 _: 38 }, 16);9}10export { render };...

Full Screen

Full Screen

collapse-transition.vue_vue&type=template&id=f68ae30a&lang.mjs

Source:collapse-transition.vue_vue&type=template&id=f68ae30a&lang.mjs Github

copy

Full Screen

1import { openBlock, createBlock, Transition, toHandlers, withCtx, renderSlot } from 'vue';2function render(_ctx, _cache, $props, $setup, $data, $options) {3 return openBlock(), createBlock(Transition, toHandlers(_ctx.on), {4 default: withCtx(() => [5 renderSlot(_ctx.$slots, "default")6 ]),7 _: 38 }, 16);9}10export { render };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toHandlers } = require('playwright/lib/server/frames');2const { chromium } = require('playwright');3const browser = await chromium.launch({ headless: false });4const context = await browser.newContext();5const page = await context.newPage();6await page.route('**', route => toHandlers(route).request(request => {7 console.log('request intercepted');8 request.continue();9}));10await page.click('input[type="text"]');11await page.keyboard.type('Playwright');12const { toHandlers } = require('playwright/lib/server/frames');13const { chromium } = require('playwright');14const browser = await chromium.launch({ headless: false });15const context = await browser.newContext();16const page = await context.newPage();17await page.route('**', route => toHandlers(route).request(request => {18 console.log('request intercepted');19 request.continue();20}));21await page.click('input[type="text"]');22await page.keyboard.type('Playwright');23const { toHandlers } = require('playwright/lib/server/frames');24const { chromium } = require('playwright');25const browser = await chromium.launch({ headless: false });26const context = await browser.newContext();27const page = await context.newPage();28await page.route('**', route => toHandlers(route).request(request => {29 console.log('request intercepted');30 request.continue();31}));32await page.click('input[type="text"]');33await page.keyboard.type('Playwright');34const { toHandlers } = require('playwright/lib/server/frames');35const { chromium } = require('playwright');36const browser = await chromium.launch({ headless: false });37const context = await browser.newContext();38const page = await context.newPage();39await page.route('**', route => toHandlers(route).request(request => {40 console.log('request intercepted');41 request.continue();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toHandlers } = require('playwright-core/lib/server/frames');2const { toHandlers } = require('playwright-core/lib/server/frames');3const { toHandlers } = require('playwright-core/lib/server/frames');4const { toHandlers } = require('playwright-core/lib/server/frames');5const { toHandlers } = require('playwright-core/lib/server/frames');6const { toHandlers } = require('playwright-core/lib/server/frames');7const { toHandlers } = require('playwright-core/lib/server/frames');8const { toHandlers } = require('playwright-core/lib/server/frames');9const { toHandlers } = require('playwright-core/lib/server/frames');10const { toHandlers } = require('playwright-core/lib/server/frames');11const { toHandlers } = require('playwright-core/lib/server/frames');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const { toHandlers } = require('@playwright/test/lib/server/frames');3const { expect } = require('@playwright/test');4(async () => {5 const browser = await chromium.launch();6 const context = await browser.newContext();7 const page = await context.newPage();8 await page.waitForSelector('text=Docs');9 const handlers = toHandlers(page);10 const [frame] = await handlers.waitForSelector('text=Docs');11 expect(await frame.textContent()).toContain('Docs');12 await browser.close();13})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toHandlers } = require('@playwright/test/lib/server/frames');2const { toHandlers } = require('@playwright/test');3const { toHandlers } = require('playwright');4const { toHandlers } = require('playwright-core');5const { toHandlers } = require('playwright-chromium');6const { toHandlers } = require('playwright-firefox');7const { toHandlers } = require('playwright-webkit');8const { toHandlers } = require('playwright-experimental');9const { toHandlers } = require('playwright-experimental-chromium');10const { toHandlers } = require('playwright-experimental-firefox');11const { toHandlers } = require('playwright-experimental-webkit');12const { toHandlers } = require('playwright-experimental-webkit');13const { test, expect } = require('@playwright/test');14const { toHandlers } = require('@playwright/test');15test('toHandlers method', async ({ page }) => {16 const handlers = toHandlers({17 async click(selector) {18 await page.click(selector);19 },20 async fill(selector, text) {21 await page.fill(selector, text);22 },23 });24 await handlers.click('text=Get started');25 await handlers.fill('input[placeholder="Search"]', 'api');26 await handlers.click('text=API');27 await expect(page.locator('text=API').first()).toBeVisible();28});29const { webkit } = require('playwright-core');30const { toHandlers

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toHandlers } = require('@playwright/test');2const { test } = require('@playwright/test');3const { expect } = require('@playwright/test');4const { test as base } = require('@playwright/test');5const { expect as baseExpect } = require('@playwright/test');6const { toHandlers } = require('@playwright/test');7const { test } = require('@playwright/test');8const { expect } = require('@playwright/test');9const { test as base } = require('@playwright/test');10const { expect as baseExpect } = require('@playwright/test');11test.describe('Test', () => {12 test.beforeEach(async ({ page }) => {13 });14 test('Test', async ({ page }) => {15 await page.fill('input[name="q"]', 'Hello World');16 });17});18const { toHandlers } = require('@playwright/test');19const { test } = require('@playwright/test');20const { expect } = require('@playwright/test');21const { test as base } = require('@playwright/test');22const { expect as baseExpect } = require('@playwright/test');23const { toHandlers } = require('@playwright/test');24const { test } = require('@playwright/test');25const { expect } = require('@playwright/test');26const { test as base } = require('@playwright/test');27const { expect as baseExpect } = require('@playwright/test');28const { toHandlers } = require('@playwright/test');29const { test } = require('@playwright/test');30const { expect } = require('@playwright/test');31const { test as base } = require('@playwright/test');32const { expect as baseExpect } = require('@playwright/test');33const { toHandlers } = require('@playwright/test');34const { test } = require('@playwright/test');35const { expect } = require('@playwright/test');36const { test as base } = require('@playwright/test');37const { expect as baseExpect } = require('@playwright/test');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toHandlers } = require('playwright/lib/server/frames');2const { chromium } = require('playwright');3const { createServer } = require('http');4(async () => {5 const server = createServer((req, res) => {6 res.end('Hello World!');7 });8 const port = await new Promise(resolve => {9 server.listen(0, () => resolve(server.address().port));10 });11 const browser = await chromium.launch();12 const context = await browser.newContext();13 const page = await context.newPage();14 const [request] = await Promise.all([15 new Promise(resolve => server.once('request', resolve)),16 ]);17 console.log('Request headers:', request.headers);18 console.log('Response status:', request.response.statusCode);19 console.log('Response headers:', request.response.headers);20 await browser.close();21 await server.close();22})();23const { toHandlers } = require('playwright/lib/server/frames');24const { chromium } = require('playwright');25const { createServer } = require('http');26(async () => {27 const server = createServer((req, res) => {28 res.end('Hello World!');29 });30 const port = await new Promise(resolve => {31 server.listen(0, () => resolve(server.address().port));32 });33 const browser = await chromium.launch();34 const context = await browser.newContext();35 const page = await context.newPage();36 const [request] = await Promise.all([37 new Promise(resolve => server.once('request', resolve)),38 ]);39 console.log('Request headers:', request.headers);40 console.log('Response status:', request.response.statusCode);41 console.log('Response headers:', request.response.headers);42 await browser.close();43 await server.close();44})();45const { toHandlers } = require('playwright/lib/server/frames');46const { chromium } = require('playwright');47const { createServer } = require('http');48(async () => {49 const server = createServer((req, res) => {50 res.end('Hello World!');51 });52 const port = await new Promise(resolve => {53 server.listen(0, () => resolve(server.address().port));54 });

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toHandlers } = require('playwright/lib/client/transport');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 const handler = toHandlers(page);7 console.log(handler);8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toHandlers } = require('@playwright/test/lib/server/transport');2const handlers = toHandlers([3 {4 async handler(params, metadata) {5 console.log(params, metadata);6 return {7 };8 },9 },10]);11const { toServer } = require('@playwright/test/lib/server/transport');12const server = toServer(handlers);13server.listen(0);14console.log('Listening on ' + server.address().port);15const { toClient } = require('@playwright/test/lib/server/transport');16client.on('close', () => process.exit(0));17client.on('message', message => console.log(message));18client.on('error', error => console.log(error));19client.send({ id: 42, method: 'getCookies' });20const { toTransport } = require('@playwright/test/lib/server/transport');21transport.onmessage = message => console.log(message);22transport.onclose = () => process.exit(0);23transport.send({ id: 42, method: 'getCookies' });24const { test } = require('@playwright/test');25test('example test', async ({ page }) => {26 const title = page.locator('text=Get started');27 await title.click();28});29{30 "scripts": {31 },32 "devDependencies": {33 }34}35import { PlaywrightTestConfig } from '@playwright/test';36const config: PlaywrightTestConfig = {37 use: {38 viewport: { width: 1280, height: 720 },

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