Best Python code snippet using playwright-python
scam.js
Source:scam.js
1const Asena = require('../events');2const {MessageType, MessageOptions, Mimetype, Presence} = require('@adiwajshing/baileys');3const Language = require('../language');4const Lang = Language.getString('scam');5Asena.addCommand({pattern: 'scam ?(.*)', fromMe: true, desc: Lang.SCAM_DESC}, (async (message, match) => {6 if (match[1] === '') {7 return await message.sendMessage(Lang.SCAM_NOTFOUND);8 } else if (match[1] === 'typing') {9 await message.client.updatePresence(message.jid,Presence.composing)10 await new Promise(r => setTimeout(r, 10000));11 await message.client.updatePresence(message.jid,Presence.composing)12 await new Promise(r => setTimeout(r, 10000));13 await message.client.updatePresence(message.jid,Presence.composing)14 await new Promise(r => setTimeout(r, 10000));15 await message.client.updatePresence(message.jid,Presence.composing)16 await new Promise(r => setTimeout(r, 10000));17 await message.client.updatePresence(message.jid,Presence.composing)18 await new Promise(r => setTimeout(r, 10000));19 await message.client.updatePresence(message.jid,Presence.composing)20 await new Promise(r => setTimeout(r, 10000));21 await message.client.updatePresence(message.jid,Presence.composing)22 await new Promise(r => setTimeout(r, 10000));23 await message.client.updatePresence(message.jid,Presence.composing)24 await new Promise(r => setTimeout(r, 10000));25 await message.client.updatePresence(message.jid,Presence.composing)26 await new Promise(r => setTimeout(r, 10000));27 await message.client.updatePresence(message.jid,Presence.composing)28 await new Promise(r => setTimeout(r, 10000));29 await message.client.updatePresence(message.jid,Presence.composing)30 await new Promise(r => setTimeout(r, 10000));31 await message.client.updatePresence(message.jid,Presence.composing)32 await new Promise(r => setTimeout(r, 10000));33 await message.client.updatePresence(message.jid,Presence.composing)34 await new Promise(r => setTimeout(r, 10000));35 await message.client.updatePresence(message.jid,Presence.composing)36 await new Promise(r => setTimeout(r, 10000));37 await message.client.updatePresence(message.jid,Presence.composing)38 await new Promise(r => setTimeout(r, 10000));39 await message.client.updatePresence(message.jid,Presence.composing)40 await new Promise(r => setTimeout(r, 10000));41 await message.client.updatePresence(message.jid,Presence.composing)42 await new Promise(r => setTimeout(r, 10000));43 await message.client.updatePresence(message.jid,Presence.composing)44 await new Promise(r => setTimeout(r, 10000));45 await message.client.updatePresence(message.jid,Presence.composing)46 await new Promise(r => setTimeout(r, 10000));47 await message.client.updatePresence(message.jid,Presence.composing)48 await new Promise(r => setTimeout(r, 10000));49 await message.client.updatePresence(message.jid,Presence.composing)50 await new Promise(r => setTimeout(r, 10000));51 await message.client.updatePresence(message.jid,Presence.composing)52 await new Promise(r => setTimeout(r, 10000));53 await message.client.updatePresence(message.jid,Presence.composing)54 await new Promise(r => setTimeout(r, 10000));55 await message.client.updatePresence(message.jid,Presence.composing)56 await new Promise(r => setTimeout(r, 10000));57 await message.client.updatePresence(message.jid,Presence.composing)58 await new Promise(r => setTimeout(r, 10000));59 await message.client.updatePresence(message.jid,Presence.composing)60 await message.client.updatePresence(message.jid,Presence.composing)61 await new Promise(r => setTimeout(r, 10000));62 await message.client.updatePresence(message.jid,Presence.composing)63 await new Promise(r => setTimeout(r, 10000));64 await message.client.updatePresence(message.jid,Presence.composing)65 await new Promise(r => setTimeout(r, 10000));66 await message.client.updatePresence(message.jid,Presence.composing)67 await new Promise(r => setTimeout(r, 10000));68 await message.client.updatePresence(message.jid,Presence.composing)69 await new Promise(r => setTimeout(r, 10000));70 await message.client.updatePresence(message.jid,Presence.composing)71 await new Promise(r => setTimeout(r, 10000));72 await message.client.updatePresence(message.jid,Presence.composing)73 await new Promise(r => setTimeout(r, 10000));74 await message.client.updatePresence(message.jid,Presence.composing)75 await new Promise(r => setTimeout(r, 10000));76 await message.client.updatePresence(message.jid,Presence.composing)77 await new Promise(r => setTimeout(r, 10000));78 await message.client.updatePresence(message.jid,Presence.composing)79 await new Promise(r => setTimeout(r, 10000));80 await message.client.updatePresence(message.jid,Presence.composing)81 await new Promise(r => setTimeout(r, 10000));82 await message.client.updatePresence(message.jid,Presence.composing)83 await new Promise(r => setTimeout(r, 10000));84 await message.client.updatePresence(message.jid,Presence.composing)85 await new Promise(r => setTimeout(r, 10000));86 await message.client.updatePresence(message.jid,Presence.composing)87 await new Promise(r => setTimeout(r, 10000));88 await message.client.updatePresence(message.jid,Presence.composing)89 await new Promise(r => setTimeout(r, 10000));90 await message.client.updatePresence(message.jid,Presence.composing)91 await new Promise(r => setTimeout(r, 10000));92 await message.client.updatePresence(message.jid,Presence.composing)93 await new Promise(r => setTimeout(r, 10000));94 await message.client.updatePresence(message.jid,Presence.composing)95 await new Promise(r => setTimeout(r, 10000));96 await message.client.updatePresence(message.jid,Presence.composing)97 await new Promise(r => setTimeout(r, 10000));98 await message.client.updatePresence(message.jid,Presence.composing)99 await new Promise(r => setTimeout(r, 10000));100 await message.client.updatePresence(message.jid,Presence.composing)101 await new Promise(r => setTimeout(r, 10000));102 await message.client.updatePresence(message.jid,Presence.composing)103 await new Promise(r => setTimeout(r, 10000));104 await message.client.updatePresence(message.jid,Presence.composing)105 await new Promise(r => setTimeout(r, 10000));106 await message.client.updatePresence(message.jid,Presence.composing)107 await new Promise(r => setTimeout(r, 10000));108 await message.client.updatePresence(message.jid,Presence.composing)109 await new Promise(r => setTimeout(r, 10000));110 await message.client.updatePresence(message.jid,Presence.composing)111 } else if (match[1] === 'online') {112 await message.client.updatePresence(message.jid,Presence.available)113 await new Promise(r => setTimeout(r, 10000));114 await message.client.updatePresence(message.jid,Presence.available)115 await new Promise(r => setTimeout(r, 10000));116 await message.client.updatePresence(message.jid,Presence.available)117 await new Promise(r => setTimeout(r, 10000));118 await message.client.updatePresence(message.jid,Presence.available)119 await new Promise(r => setTimeout(r, 10000));120 await message.client.updatePresence(message.jid,Presence.available)121 await new Promise(r => setTimeout(r, 10000));122 await message.client.updatePresence(message.jid,Presence.available)123 await new Promise(r => setTimeout(r, 10000));124 await message.client.updatePresence(message.jid,Presence.available)125 await new Promise(r => setTimeout(r, 10000));126 await message.client.updatePresence(message.jid,Presence.available)127 await new Promise(r => setTimeout(r, 10000));128 await message.client.updatePresence(message.jid,Presence.available)129 await new Promise(r => setTimeout(r, 10000));130 await message.client.updatePresence(message.jid,Presence.available)131 await new Promise(r => setTimeout(r, 10000));132 await message.client.updatePresence(message.jid,Presence.available)133 await new Promise(r => setTimeout(r, 10000));134 await message.client.updatePresence(message.jid,Presence.available)135 await new Promise(r => setTimeout(r, 10000));136 await message.client.updatePresence(message.jid,Presence.available)137 await new Promise(r => setTimeout(r, 10000));138 await message.client.updatePresence(message.jid,Presence.available)139 await new Promise(r => setTimeout(r, 10000));140 await message.client.updatePresence(message.jid,Presence.available)141 await new Promise(r => setTimeout(r, 10000));142 await message.client.updatePresence(message.jid,Presence.available)143 await new Promise(r => setTimeout(r, 10000));144 await message.client.updatePresence(message.jid,Presence.available)145 await new Promise(r => setTimeout(r, 10000));146 await message.client.updatePresence(message.jid,Presence.available)147 await new Promise(r => setTimeout(r, 10000));148 await message.client.updatePresence(message.jid,Presence.available)149 await new Promise(r => setTimeout(r, 10000));150 await message.client.updatePresence(message.jid,Presence.available)151 await new Promise(r => setTimeout(r, 10000));152 await message.client.updatePresence(message.jid,Presence.available)153 await new Promise(r => setTimeout(r, 10000));154 await message.client.updatePresence(message.jid,Presence.available)155 await new Promise(r => setTimeout(r, 10000));156 await message.client.updatePresence(message.jid,Presence.available)157 await new Promise(r => setTimeout(r, 10000));158 await message.client.updatePresence(message.jid,Presence.available)159 await new Promise(r => setTimeout(r, 10000));160 await message.client.updatePresence(message.jid,Presence.available)161 await new Promise(r => setTimeout(r, 10000));162 await message.client.updatePresence(message.jid,Presence.available)163 await message.client.updatePresence(message.jid,Presence.available)164 await new Promise(r => setTimeout(r, 10000));165 await message.client.updatePresence(message.jid,Presence.available)166 await new Promise(r => setTimeout(r, 10000));167 await message.client.updatePresence(message.jid,Presence.available)168 await new Promise(r => setTimeout(r, 10000));169 await message.client.updatePresence(message.jid,Presence.available)170 await new Promise(r => setTimeout(r, 10000));171 await message.client.updatePresence(message.jid,Presence.available)172 await new Promise(r => setTimeout(r, 10000));173 await message.client.updatePresence(message.jid,Presence.available)174 await new Promise(r => setTimeout(r, 10000));175 await message.client.updatePresence(message.jid,Presence.available)176 await new Promise(r => setTimeout(r, 10000));177 await message.client.updatePresence(message.jid,Presence.available)178 await new Promise(r => setTimeout(r, 10000));179 await message.client.updatePresence(message.jid,Presence.available)180 await new Promise(r => setTimeout(r, 10000));181 await message.client.updatePresence(message.jid,Presence.available)182 await new Promise(r => setTimeout(r, 10000));183 await message.client.updatePresence(message.jid,Presence.available)184 await new Promise(r => setTimeout(r, 10000));185 await message.client.updatePresence(message.jid,Presence.available)186 await new Promise(r => setTimeout(r, 10000));187 await message.client.updatePresence(message.jid,Presence.available)188 await new Promise(r => setTimeout(r, 10000));189 await message.client.updatePresence(message.jid,Presence.available)190 await new Promise(r => setTimeout(r, 10000));191 await message.client.updatePresence(message.jid,Presence.available)192 await new Promise(r => setTimeout(r, 10000));193 await message.client.updatePresence(message.jid,Presence.available)194 await new Promise(r => setTimeout(r, 10000));195 await message.client.updatePresence(message.jid,Presence.available)196 await new Promise(r => setTimeout(r, 10000));197 await message.client.updatePresence(message.jid,Presence.available)198 await new Promise(r => setTimeout(r, 10000));199 await message.client.updatePresence(message.jid,Presence.available)200 await new Promise(r => setTimeout(r, 10000));201 await message.client.updatePresence(message.jid,Presence.available)202 await new Promise(r => setTimeout(r, 10000));203 await message.client.updatePresence(message.jid,Presence.available)204 await new Promise(r => setTimeout(r, 10000));205 await message.client.updatePresence(message.jid,Presence.available)206 await new Promise(r => setTimeout(r, 10000));207 await message.client.updatePresence(message.jid,Presence.available)208 await new Promise(r => setTimeout(r, 10000));209 await message.client.updatePresence(message.jid,Presence.available)210 await new Promise(r => setTimeout(r, 10000));211 await message.client.updatePresence(message.jid,Presence.available)212 await new Promise(r => setTimeout(r, 10000));213 await message.client.updatePresence(message.jid,Presence.available)214 } else if (match[1] === 'recording') {215 await message.client.updatePresence(message.jid,Presence.recording)216 await new Promise(r => setTimeout(r, 10000));217 await message.client.updatePresence(message.jid,Presence.recording)218 await new Promise(r => setTimeout(r, 10000));219 await message.client.updatePresence(message.jid,Presence.recording)220 await new Promise(r => setTimeout(r, 10000));221 await message.client.updatePresence(message.jid,Presence.recording)222 await new Promise(r => setTimeout(r, 10000));223 await message.client.updatePresence(message.jid,Presence.recording)224 await new Promise(r => setTimeout(r, 10000));225 await message.client.updatePresence(message.jid,Presence.recording)226 await new Promise(r => setTimeout(r, 10000));227 await message.client.updatePresence(message.jid,Presence.recording)228 await new Promise(r => setTimeout(r, 10000));229 await message.client.updatePresence(message.jid,Presence.recording)230 await new Promise(r => setTimeout(r, 10000));231 await message.client.updatePresence(message.jid,Presence.recording)232 await new Promise(r => setTimeout(r, 10000));233 await message.client.updatePresence(message.jid,Presence.recording)234 await new Promise(r => setTimeout(r, 10000));235 await message.client.updatePresence(message.jid,Presence.recording)236 await new Promise(r => setTimeout(r, 10000));237 await message.client.updatePresence(message.jid,Presence.recording)238 await new Promise(r => setTimeout(r, 10000));239 await message.client.updatePresence(message.jid,Presence.recording)240 await new Promise(r => setTimeout(r, 10000));241 await message.client.updatePresence(message.jid,Presence.recording)242 await new Promise(r => setTimeout(r, 10000));243 await message.client.updatePresence(message.jid,Presence.recording)244 await new Promise(r => setTimeout(r, 10000));245 await message.client.updatePresence(message.jid,Presence.recording)246 await new Promise(r => setTimeout(r, 10000));247 await message.client.updatePresence(message.jid,Presence.recording)248 await new Promise(r => setTimeout(r, 10000));249 await message.client.updatePresence(message.jid,Presence.recording)250 await new Promise(r => setTimeout(r, 10000));251 await message.client.updatePresence(message.jid,Presence.recording)252 await new Promise(r => setTimeout(r, 10000));253 await message.client.updatePresence(message.jid,Presence.recording)254 await new Promise(r => setTimeout(r, 10000));255 await message.client.updatePresence(message.jid,Presence.recording)256 await new Promise(r => setTimeout(r, 10000));257 await message.client.updatePresence(message.jid,Presence.recording)258 await new Promise(r => setTimeout(r, 10000));259 await message.client.updatePresence(message.jid,Presence.recording)260 await new Promise(r => setTimeout(r, 10000));261 await message.client.updatePresence(message.jid,Presence.recording)262 await new Promise(r => setTimeout(r, 10000));263 await message.client.updatePresence(message.jid,Presence.recording)264 await new Promise(r => setTimeout(r, 10000));265 await message.client.updatePresence(message.jid,Presence.recording)266 await message.client.updatePresence(message.jid,Presence.recording)267 await new Promise(r => setTimeout(r, 10000));268 await message.client.updatePresence(message.jid,Presence.recording)269 await new Promise(r => setTimeout(r, 10000));270 await message.client.updatePresence(message.jid,Presence.recording)271 await new Promise(r => setTimeout(r, 10000));272 await message.client.updatePresence(message.jid,Presence.recording)273 await new Promise(r => setTimeout(r, 10000));274 await message.client.updatePresence(message.jid,Presence.recording)275 await new Promise(r => setTimeout(r, 10000));276 await message.client.updatePresence(message.jid,Presence.recording)277 await new Promise(r => setTimeout(r, 10000));278 await message.client.updatePresence(message.jid,Presence.recording)279 await new Promise(r => setTimeout(r, 10000));280 await message.client.updatePresence(message.jid,Presence.recording)281 await new Promise(r => setTimeout(r, 10000));282 await message.client.updatePresence(message.jid,Presence.recording)283 await new Promise(r => setTimeout(r, 10000));284 await message.client.updatePresence(message.jid,Presence.recording)285 await new Promise(r => setTimeout(r, 10000));286 await message.client.updatePresence(message.jid,Presence.recording)287 await new Promise(r => setTimeout(r, 10000));288 await message.client.updatePresence(message.jid,Presence.recording)289 await new Promise(r => setTimeout(r, 10000));290 await message.client.updatePresence(message.jid,Presence.recording)291 await new Promise(r => setTimeout(r, 10000));292 await message.client.updatePresence(message.jid,Presence.recording)293 await new Promise(r => setTimeout(r, 10000));294 await message.client.updatePresence(message.jid,Presence.recording)295 await new Promise(r => setTimeout(r, 10000));296 await message.client.updatePresence(message.jid,Presence.recording)297 await new Promise(r => setTimeout(r, 10000));298 await message.client.updatePresence(message.jid,Presence.recording)299 await new Promise(r => setTimeout(r, 10000));300 await message.client.updatePresence(message.jid,Presence.recording)301 await new Promise(r => setTimeout(r, 10000));302 await message.client.updatePresence(message.jid,Presence.recording)303 await new Promise(r => setTimeout(r, 10000));304 await message.client.updatePresence(message.jid,Presence.recording)305 await new Promise(r => setTimeout(r, 10000));306 await message.client.updatePresence(message.jid,Presence.recording)307 await new Promise(r => setTimeout(r, 10000));308 await message.client.updatePresence(message.jid,Presence.recording)309 await new Promise(r => setTimeout(r, 10000));310 await message.client.updatePresence(message.jid,Presence.recording)311 await new Promise(r => setTimeout(r, 10000));312 await message.client.updatePresence(message.jid,Presence.recording)313 await new Promise(r => setTimeout(r, 10000));314 await message.client.updatePresence(message.jid,Presence.recording)315 await new Promise(r => setTimeout(r, 10000));316 await message.client.updatePresence(message.jid,Presence.recording)317 } else if (match[1] === 'stop') {318 return await message.client.updatePresence(message.jid,Presence.paused)319 } else {320 await message.sendMessage(Lang.SCAM_NULL);321 }...
Timeout.js
Source:Timeout.js
1import React from 'react'2import $ from 'jquery'3import { Swiper , SwiperSlide } from 'swiper/react'4import SwiperCode,{ Navigation , Pagination , Autoplay } from 'swiper'5import 'swiper/swiper-bundle.css'6SwiperCode.use([Navigation , Pagination ,Autoplay])7class SectionTimeout extends React.Component{8 componentDidMount(){9 var timeHr = document.querySelector('.time-hr')10 var timeMin = document.querySelector('.time-min')11 var timeSec = document.querySelector('.time-sec')12 setInterval(function (){13 var time = new Date()14 var nowtime = time.getTime();15 time.setMonth(11)16 time.setDate(31)17 time.setHours(24)18 time.setMinutes(0)19 time.setSeconds(0)20 var endtime = time.getTime();21 var offsetTime = (endtime - nowtime) /1000;22 var hr = parseInt(offsetTime / 60 / 60);23 var min = parseInt((offsetTime / 60) % 60);24 var sec = parseInt(offsetTime % 60);25 timeHr.textContent = hr26 timeMin.textContent = min27 timeSec.textContent = sec28 },1000)29 }30 31 render(){32 // $(".swiper-slider-box").mouseenter(function(){33 // Swiper.stopAutoPlay();34 // });35 // $(".swiper-slider-box").mouseleave(function(){36 // Swiper.startAutoPlay();37 // });38 return(39 <>40 <div className="timeout">41 <div className="timeout-header">42 <div className="timeout-sales">43 <div className="saletime-text">éæç¹è³£</div>44 <div className="saletime-box">45 <div className="time-hr"></div>:46 <div className="time-min"></div>:47 <div className="time-sec"></div>48 </div>49 </div>50 <a href="#">æ¥çå
¨é¨ ></a>51 </div>52 <Swiper53 slidesPerView={6}54 navigation55 autoplay={{56 delay:3000,57 disableOnInteraction:false58 }}59 speed={1000}60 className="timeout-items"61 width={1200}62 height={240}63 64 >65 <SwiperSlide className="swiper-slider-box">66 <a href="#" className="timeout-product">67 <div className="timeout-img">68 <img src=""></img>69 </div>70 <div className="timeout-price">$600</div>71 <button className="timeout-saled">å·²å®åº0</button>72 </a>73 </SwiperSlide>74 <SwiperSlide className="swiper-slider-box">75 <a href="#" className="timeout-product">76 <div className="timeout-img">77 <img src=""></img>78 </div>79 <div className="timeout-price">$600</div>80 <button className="timeout-saled">å·²å®åº0</button>81 </a>82 </SwiperSlide>83 <SwiperSlide className="swiper-slider-box">84 <a href="#" className="timeout-product">85 <div className="timeout-img">86 <img src=""></img>87 </div>88 <div className="timeout-price">$600</div>89 <button className="timeout-saled">å·²å®åº0</button>90 </a>91 </SwiperSlide>92 <SwiperSlide className="swiper-slider-box">93 <a href="#" className="timeout-product">94 <div className="timeout-img">95 <img src=""></img>96 </div>97 <div className="timeout-price">$600</div>98 <button className="timeout-saled">å·²å®åº0</button>99 </a>100 </SwiperSlide>101 <SwiperSlide className="swiper-slider-box">102 <a href="#" className="timeout-product">103 <div className="timeout-img">104 <img src=""></img>105 </div>106 <div className="timeout-price">$600</div>107 <button className="timeout-saled">å·²å®åº0</button>108 </a>109 </SwiperSlide>110 <SwiperSlide className="swiper-slider-box">111 <a href="#" className="timeout-product">112 <div className="timeout-img">113 <img src=""></img>114 </div>115 <div className="timeout-price">$600</div>116 <button className="timeout-saled">å·²å®åº0</button>117 </a>118 </SwiperSlide>119 <SwiperSlide className="swiper-slider-box">120 <a href="#" className="timeout-product">121 <div className="timeout-img">122 <img src=""></img>123 </div>124 <div className="timeout-price">$600</div>125 <button className="timeout-saled">å·²å®åº0</button>126 </a>127 </SwiperSlide>128 <SwiperSlide className="swiper-slider-box">129 <a href="#" className="timeout-product">130 <div className="timeout-img">131 <img src=""></img>132 </div>133 <div className="timeout-price">$600</div>134 <button className="timeout-saled">å·²å®åº0</button>135 </a>136 </SwiperSlide>137 <SwiperSlide className="swiper-slider-box">138 <a href="#" className="timeout-product">139 <div className="timeout-img">140 <img src=""></img>141 </div>142 <div className="timeout-price">$600</div>143 <button className="timeout-saled">å·²å®åº0</button>144 </a>145 </SwiperSlide>146 </Swiper>147 </div>148 </>149 )150 }151}...
_timeoutWaiter.js
Source:_timeoutWaiter.js
1/*global QUnit, sinon */2sap.ui.define([3 "jquery.sap.global",4 "../utils/loggerInterceptor",5 "sap/ui/test/autowaiter/_timeoutWaiter"6], function ($, loggerInterceptor,timeoutWaiter) {7 "use strict";8 var fnSetTimeout = window["setTimeout"];9 var fnClearTimeout = window["clearTimeout"];10 ["Timeout", "Immediate"].forEach(function (sFunctionUnderTest) {11 var fnSetFunction = window["set" + sFunctionUnderTest];12 var fnClearFunction = window["clear" + sFunctionUnderTest];13 if (!fnSetFunction) {14 $.sap.log.debug("Skipped tests because" + sFunctionUnderTest + " is not defined in this browser");15 return;16 }17 QUnit.module("timeoutWaiter - no " + sFunctionUnderTest);18 QUnit.test("Should make sure there is no pending timeout before starting these tests", function (assert) {19 var fnDone = assert.async();20 function noTimeout () {21 var bHasTimeout = timeoutWaiter.hasPending();22 if (!bHasTimeout) {23 assert.ok(true, "no timeout present");24 fnDone();25 } else {26 setTimeout(noTimeout, 50);27 }28 return bHasTimeout;29 }30 noTimeout();31 });32 QUnit.test("Should return that there are no pending timeouts", function (assert) {33 assert.ok(!timeoutWaiter.hasPending(), "there are no pending timeouts");34 });35 QUnit.test("Should return that there are no pending Timeouts if a timeout has finished", function (assert) {36 var fnDone = assert.async();37 fnSetFunction(function () {38 assert.ok(!timeoutWaiter.hasPending(), "there are no pending timeouts");39 fnDone();40 }, 100);41 });42 QUnit.test("Should ignore long runners", function (assert) {43 var iID = fnSetFunction(function () {}, 1001);44 assert.ok(!timeoutWaiter.hasPending(), "there are no pending timeouts");45 fnClearFunction(iID);46 });47 QUnit.test("Should have configurable max timeout delay", function (assert) {48 timeoutWaiter.extendConfig({timeoutWaiter: {maxDelay: 3000}});49 var iID = fnSetFunction(function () {}, 1001);50 var iIDIgnored = fnSetFunction(function () {}, 3001);51 assert.ok(timeoutWaiter.hasPending(), "there is 1 pending timeout");52 fnClearFunction(iID);53 fnClearFunction(iIDIgnored);54 // reset to default value55 timeoutWaiter.extendConfig({timeoutWaiter: {maxDelay: 1000}});56 });57 QUnit.module("timeoutWaiter - single " + sFunctionUnderTest);58 QUnit.test("Should respect the this pointer", function (assert) {59 var oThis = {},60 fnDone = assert.async(),61 fnSpy = sinon.spy(function () {62 sinon.assert.calledOn(fnSpy, oThis);63 fnDone();64 });65 fnSetFunction($.proxy(fnSpy, oThis));66 });67 QUnit.test("Should handle a single timeout", function (assert) {68 var fnDone = assert.async();69 fnSetFunction(function () {70 fnDone();71 });72 assert.ok(timeoutWaiter.hasPending(), "There was a timeout");73 });74 QUnit.module("timeoutWaiter - multiple " + sFunctionUnderTest);75 QUnit.test("Should handle 2 timeouts", function (assert) {76 var fnFirstTimeoutDone = assert.async();77 var fnSecondTimeoutDone = assert.async();78 fnSetFunction(function () {79 assert.ok(timeoutWaiter.hasPending(), "First timeout has compled");80 fnFirstTimeoutDone();81 });82 fnSetFunction(function () {83 assert.ok(!timeoutWaiter.hasPending(), "Both timeouts have completed");84 fnSecondTimeoutDone();85 }, 20);86 assert.ok(timeoutWaiter.hasPending(), "Both timeouts are scheduled");87 });88 QUnit.test("Should handle a timeout that adds a timeout", function (assert) {89 var fnDone = assert.async();90 fnSetFunction(function () {91 assert.ok(!timeoutWaiter.hasPending(), "First timeout has completed");92 fnSetFunction(function () {93 assert.ok(!timeoutWaiter.hasPending(), "Second timeout has completed");94 fnDone();95 });96 assert.ok(timeoutWaiter.hasPending(), "Second timeout is scheduled");97 });98 assert.ok(timeoutWaiter.hasPending(), "First timeout is scheduled");99 });100 QUnit.module("timeoutWaiter - clear " + sFunctionUnderTest);101 QUnit.test("Should clear a timeout", function (assert) {102 var iId = fnSetFunction(function () {});103 fnClearFunction(iId);104 assert.ok(!timeoutWaiter.hasPending(), "there are no pending timeouts");105 });106 QUnit.test("Should clear 1 of 2 timeouts", function (assert) {107 var fnDone = assert.async();108 fnSetFunction(function () {109 assert.ok(!timeoutWaiter.hasPending(), "there are no pending timeouts");110 sinon.assert.notCalled(fnSecondTimeoutSpy);111 fnDone();112 },20);113 var fnSecondTimeoutSpy = sinon.spy();114 var iId = fnSetFunction(fnSecondTimeoutSpy);115 fnClearFunction(iId);116 assert.ok(timeoutWaiter.hasPending(), "There was a timeout");117 });118 });119 QUnit.module("timeoutWaiter - infinite timeout loops");120 QUnit.test("Should detect a infinite timeout loop", function (assert) {121 var fnDone = assert.async();122 var aTimeouts = [];123 function addTimeout () {124 aTimeouts.push(fnSetTimeout(addTimeout, 30));125 }126 fnSetTimeout(function () {127 assert.ok(!timeoutWaiter.hasPending(), "there are no pending timeouts - spawned " + aTimeouts.length + " timeouts");128 aTimeouts.forEach(function (iID) {129 fnClearTimeout(iID);130 });131 fnDone();132 }, 600);133 addTimeout();134 });135 QUnit.test("Should detect a infinite timeout loop with 2 timeouts added per loop", function (assert) {136 var fnDone = assert.async();137 var aTimeouts = [];138 function addTimeout () {139 aTimeouts.push(fnSetTimeout(addTimeout, 40));140 aTimeouts.push(fnSetTimeout(addTimeout, 40));141 }142 fnSetTimeout(function () {143 assert.ok(!timeoutWaiter.hasPending(), "there are no pending timeouts - spawned " + aTimeouts.length + " timeouts");144 aTimeouts.forEach(function (iID) {145 fnClearTimeout(iID);146 });147 fnDone();148 }, 600);149 addTimeout();150 });...
browser.js
Source:browser.js
1// shim for using process in browser2var process = module.exports = {};3// cached from whatever global is present so that test runners that stub it4// don't break things. But we need to wrap it in a try catch in case it is5// wrapped in strict mode code which doesn't define any globals. It's inside a6// function because try/catches deoptimize in certain engines.7var cachedSetTimeout;8var cachedClearTimeout;9function defaultSetTimout() {10 throw new Error('setTimeout has not been defined');11}12function defaultClearTimeout () {13 throw new Error('clearTimeout has not been defined');14}15(function () {16 try {17 if (typeof setTimeout === 'function') {18 cachedSetTimeout = setTimeout;19 } else {20 cachedSetTimeout = defaultSetTimout;21 }22 } catch (e) {23 cachedSetTimeout = defaultSetTimout;24 }25 try {26 if (typeof clearTimeout === 'function') {27 cachedClearTimeout = clearTimeout;28 } else {29 cachedClearTimeout = defaultClearTimeout;30 }31 } catch (e) {32 cachedClearTimeout = defaultClearTimeout;33 }34} ())35function runTimeout(fun) {36 if (cachedSetTimeout === setTimeout) {37 //normal enviroments in sane situations38 return setTimeout(fun, 0);39 }40 // if setTimeout wasn't available but was latter defined41 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {42 cachedSetTimeout = setTimeout;43 return setTimeout(fun, 0);44 }45 try {46 // when when somebody has screwed with setTimeout but no I.E. maddness47 return cachedSetTimeout(fun, 0);48 } catch(e){49 try {50 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally51 return cachedSetTimeout.call(null, fun, 0);52 } catch(e){53 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error54 return cachedSetTimeout.call(this, fun, 0);55 }56 }57}58function runClearTimeout(marker) {59 if (cachedClearTimeout === clearTimeout) {60 //normal enviroments in sane situations61 return clearTimeout(marker);62 }63 // if clearTimeout wasn't available but was latter defined64 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {65 cachedClearTimeout = clearTimeout;66 return clearTimeout(marker);67 }68 try {69 // when when somebody has screwed with setTimeout but no I.E. maddness70 return cachedClearTimeout(marker);71 } catch (e){72 try {73 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally74 return cachedClearTimeout.call(null, marker);75 } catch (e){76 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.77 // Some versions of I.E. have different rules for clearTimeout vs setTimeout78 return cachedClearTimeout.call(this, marker);79 }80 }81}82var queue = [];83var draining = false;84var currentQueue;85var queueIndex = -1;86function cleanUpNextTick() {87 if (!draining || !currentQueue) {88 return;89 }90 draining = false;91 if (currentQueue.length) {92 queue = currentQueue.concat(queue);93 } else {94 queueIndex = -1;95 }96 if (queue.length) {97 drainQueue();98 }99}100function drainQueue() {101 if (draining) {102 return;103 }104 var timeout = runTimeout(cleanUpNextTick);105 draining = true;106 var len = queue.length;107 while(len) {108 currentQueue = queue;109 queue = [];110 while (++queueIndex < len) {111 if (currentQueue) {112 currentQueue[queueIndex].run();113 }114 }115 queueIndex = -1;116 len = queue.length;117 }118 currentQueue = null;119 draining = false;120 runClearTimeout(timeout);121}122process.nextTick = function (fun) {123 var args = new Array(arguments.length - 1);124 if (arguments.length > 1) {125 for (var i = 1; i < arguments.length; i++) {126 args[i - 1] = arguments[i];127 }128 }129 queue.push(new Item(fun, args));130 if (queue.length === 1 && !draining) {131 runTimeout(drainQueue);132 }133};134// v8 likes predictible objects135function Item(fun, array) {136 this.fun = fun;137 this.array = array;138}139Item.prototype.run = function () {140 this.fun.apply(null, this.array);141};142process.title = 'browser';143process.browser = true;144process.env = {};145process.argv = [];146process.version = ''; // empty string to avoid regexp issues147process.versions = {};148function noop() {}149process.on = noop;150process.addListener = noop;151process.once = noop;152process.off = noop;153process.removeListener = noop;154process.removeAllListeners = noop;155process.emit = noop;156process.prependListener = noop;157process.prependOnceListener = noop;158process.listeners = function (name) { return [] }159process.binding = function (name) {160 throw new Error('process.binding is not supported');161};162process.cwd = function () { return '/' };163process.chdir = function (dir) {164 throw new Error('process.chdir is not supported');165};...
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.
Get 100 minutes of automation test minutes FREE!!