How to use unref method in Playwright Internal

Best JavaScript code snippet using playwright-internal

timers.js

Source:timers.js Github

copy

Full Screen

...254 this.owner.close();255}256Timeout.prototype.unref = function() {257 if (this._handle) {258 this._handle.unref();259 } else if (typeof this._onTimeout === 'function') {260 var now = Timer.now();261 if (!this._idleStart) this._idleStart = now;262 var delay = this._idleStart + this._idleTimeout - now;263 if (delay < 0) delay = 0;264 // Prevent running cb again when unref() is called during the same cb265 if (this._called && !this._repeat) {266 exports.unenroll(this);267 return;268 }269 var handle = reuse(this);270 this._handle = handle || new Timer();271 this._handle.owner = this;272 this._handle[kOnTimeout] = unrefdHandle;273 this._handle.start(delay, 0);274 this._handle.domain = this.domain;275 this._handle.unref();276 }277 return this;278};279Timeout.prototype.ref = function() {280 if (this._handle)281 this._handle.ref();282 return this;283};284Timeout.prototype.close = function() {285 this._onTimeout = null;286 if (this._handle) {287 this._handle[kOnTimeout] = null;288 this._handle.close();289 } else {290 exports.unenroll(this);291 }292 return this;293};294var immediateQueue = {};295L.init(immediateQueue);296function processImmediate() {297 var queue = immediateQueue;298 var domain, immediate;299 immediateQueue = {};300 L.init(immediateQueue);301 while (L.isEmpty(queue) === false) {302 immediate = L.shift(queue);303 domain = immediate.domain;304 if (domain)305 domain.enter();306 var threw = true;307 try {308 immediate._onImmediate();309 threw = false;310 } finally {311 if (threw) {312 if (!L.isEmpty(queue)) {313 // Handle any remaining on next tick, assuming we're still314 // alive to do so.315 while (!L.isEmpty(immediateQueue)) {316 L.append(queue, L.shift(immediateQueue));317 }318 immediateQueue = queue;319 process.nextTick(processImmediate);320 }321 }322 }323 if (domain)324 domain.exit();325 }326 // Only round-trip to C++ land if we have to. Calling clearImmediate() on an327 // immediate that's in |queue| is okay. Worst case is we make a superfluous328 // call to NeedImmediateCallbackSetter().329 if (L.isEmpty(immediateQueue)) {330 process._needImmediateCallback = false;331 }332}333function Immediate() { }334Immediate.prototype.domain = undefined;335Immediate.prototype._onImmediate = undefined;336Immediate.prototype._idleNext = undefined;337Immediate.prototype._idlePrev = undefined;338exports.setImmediate = function(callback, arg1, arg2, arg3) {339 var i, args;340 var len = arguments.length;341 var immediate = new Immediate();342 L.init(immediate);343 switch (len) {344 // fast cases345 case 0:346 case 1:347 immediate._onImmediate = callback;348 break;349 case 2:350 immediate._onImmediate = function() {351 callback.call(immediate, arg1);352 };353 break;354 case 3:355 immediate._onImmediate = function() {356 callback.call(immediate, arg1, arg2);357 };358 break;359 case 4:360 immediate._onImmediate = function() {361 callback.call(immediate, arg1, arg2, arg3);362 };363 break;364 // slow case365 default:366 args = new Array(len - 1);367 for (i = 1; i < len; i++)368 args[i - 1] = arguments[i];369 immediate._onImmediate = function() {370 callback.apply(immediate, args);371 };372 break;373 }374 if (!process._needImmediateCallback) {375 process._needImmediateCallback = true;376 process._immediateCallback = processImmediate;377 }378 if (process.domain)379 immediate.domain = process.domain;380 L.append(immediateQueue, immediate);381 return immediate;382};383exports.clearImmediate = function(immediate) {384 if (!immediate) return;385 immediate._onImmediate = undefined;386 L.remove(immediate);387 if (L.isEmpty(immediateQueue)) {388 process._needImmediateCallback = false;389 }390};391// Internal APIs that need timeouts should use timers._unrefActive instead of392// timers.active as internal timeouts shouldn't hold the loop open393var unrefList, unrefTimer;394function _makeTimerTimeout(timer) {395 var domain = timer.domain;396 var msecs = timer._idleTimeout;397 L.remove(timer);398 // Timer has been unenrolled by another timer that fired at the same time,399 // so don't make it timeout.400 if (msecs <= 0)401 return;402 if (!timer._onTimeout)403 return;404 if (domain) {405 if (domain._disposed)406 return;407 domain.enter();408 }409 debug('unreftimer firing timeout');410 timer._called = true;411 _runOnTimeout(timer);412 if (domain)413 domain.exit();414}415function _runOnTimeout(timer) {416 var threw = true;417 try {418 timer._onTimeout();419 threw = false;420 } finally {421 if (threw) process.nextTick(unrefTimeout);422 }423}424function unrefTimeout() {425 var now = Timer.now();426 debug('unrefTimer fired');427 var timeSinceLastActive;428 var nextTimeoutTime;429 var nextTimeoutDuration;430 var minNextTimeoutTime = TIMEOUT_MAX;431 var timersToTimeout = [];432 // The actual timer fired and has not yet been rearmed,433 // let's consider its next firing time is invalid for now.434 // It may be set to a relevant time in the future once435 // we scanned through the whole list of timeouts and if436 // we find a timeout that needs to expire.437 unrefTimer.when = -1;438 // Iterate over the list of timeouts,439 // call the onTimeout callback for those expired,440 // and rearm the actual timer if the next timeout to expire441 // will expire before the current actual timer.442 var cur = unrefList._idlePrev;443 while (cur !== unrefList) {444 timeSinceLastActive = now - cur._idleStart;445 if (timeSinceLastActive < cur._idleTimeout) {446 // This timer hasn't expired yet, but check if its expiring time is447 // earlier than the actual timer's expiring time448 nextTimeoutDuration = cur._idleTimeout - timeSinceLastActive;449 nextTimeoutTime = now + nextTimeoutDuration;450 if (minNextTimeoutTime === TIMEOUT_MAX ||451 (nextTimeoutTime < minNextTimeoutTime)) {452 // We found a timeout that will expire earlier,453 // store its next timeout time now so that we454 // can rearm the actual timer accordingly when455 // we scanned through the whole list.456 minNextTimeoutTime = nextTimeoutTime;457 }458 } else {459 // We found a timer that expired. Do not call its _onTimeout callback460 // right now, as it could mutate any item of the list (including itself).461 // Instead, add it to another list that will be processed once the list462 // of current timers has been fully traversed.463 timersToTimeout.push(cur);464 }465 cur = cur._idlePrev;466 }467 var nbTimersToTimeout = timersToTimeout.length;468 for (var timerIdx = 0; timerIdx < nbTimersToTimeout; ++timerIdx)469 _makeTimerTimeout(timersToTimeout[timerIdx]);470 // Rearm the actual timer with the timeout delay471 // of the earliest timeout found.472 if (minNextTimeoutTime !== TIMEOUT_MAX) {473 unrefTimer.start(minNextTimeoutTime - now, 0);474 unrefTimer.when = minNextTimeoutTime;475 debug('unrefTimer rescheduled');476 } else if (L.isEmpty(unrefList)) {477 debug('unrefList is empty');478 }479}480exports._unrefActive = function(item) {481 var msecs = item._idleTimeout;482 if (!msecs || msecs < 0) return;483 assert(msecs >= 0);484 L.remove(item);485 if (!unrefList) {486 debug('unrefList initialized');487 unrefList = {};488 L.init(unrefList);489 debug('unrefTimer initialized');490 unrefTimer = new Timer();491 unrefTimer.unref();492 unrefTimer.when = -1;493 unrefTimer[kOnTimeout] = unrefTimeout;494 }495 var now = Timer.now();496 item._idleStart = now;497 var when = now + msecs;498 // If the actual timer is set to fire too late, or not set to fire at all,499 // we need to make it fire earlier500 if (unrefTimer.when === -1 || unrefTimer.when > when) {501 unrefTimer.start(msecs, 0);502 unrefTimer.when = when;503 debug('unrefTimer scheduled');504 }505 debug('unrefList append to end');...

Full Screen

Full Screen

use.js

Source:use.js Github

copy

Full Screen

...28 const sliderSize = ref(0)29 const Form = inject('Form', {})30 const sSize = computed(() => { // 这个sSize指代的是,框体规格大小31 return (32 unref(size) === 'normal' && !!unref(Form.size) ? unref(Form.size) : unref(size)33 )34 })35 const isOk = computed(() => {36 return unref(validateState) === 'success'37 })38 const isVerifySlider = computed(() => {39 return unref(type) === 'verify'40 })41 const sliderDisabled = computed(() => {42 return (43 unref(disabled) || (44 unref(Form.disabled) ? unref(Form.disabled) : false45 ) || (unref(isOk) && unref(isVerifySlider))46 )47 })48 const rangeSize = computed(() => {49 return unref(max) - unref(min)50 })51 const barSize = computed(() => {52 if (unref(isVerifySlider)) {53 return `${(100 * (unref(value) - unref(min) + 100 * (32 / unref(sliderSize)))) / (unref(max) - unref(min) + 100 * (32 / unref(sliderSize)))}%`54 }55 return `${(100 * (unref(value) - unref(min))) / (unref(max) - unref(min))}%`56 })57 const barStart = computed(() => {58 return '0%'59 })60 const passStyle = computed(() => {61 return unref(vertical)62 ? {63 height: unref(barSize),64 bottom: unref(barStart)65 }66 : {67 width: unref(barSize),68 left: unref(barStart)69 }70 })71 const precision = computed(() => { // 根据用户提供的数据值,决定结果的精度与之匹配符合72 const precision = [unref(max), unref(min), unref(step)].map(item => {73 const decimal = ('' + item).split('.')[1] // 获取小数点后74 return decimal ? decimal.length : 075 })76 return Math.max.apply(null, precision) // 在调用数组时,用到apply,Math.max.apply(null, ['1','2','3.1','3.2'])77 })78 const markList = computed(() => {79 if (!unref(showStops) || unref(isVerifySlider)) return []80 if (unref(step) > unref(rangeSize) || unref(step)) return []81 if (unref(isVerifySlider)) return [] // 验证不允许有过程点82 if (typeof unref(step) === 'string') console.error('[Element Error][step]step type must be number')83 const res = []84 for (let i = unref(step); i < unref(rangeSize); i += unref(step)) {85 res.push(`${(i / unref(rangeSize)) * 100}%`)86 }87 return res88 })89 const showClass = computed(() => {90 return [91 'slider',92 unref(isVerifySlider) ? 'slider-verify' : 'slider-number',93 `slider-${unref(sSize)}`,94 unref(sliderDisabled) ? 'isDisabled' : ''95 ]96 })97 const getStopStyle = val => {98 return unref(vertical)99 ? { bottom: unref(val) }100 : { left: unref(val) }101 }102 return {103 passStyle,104 slider,105 precision,106 value,107 oldValue,108 sliderSize,109 markList,110 getStopStyle,111 showClass,112 isVerifySlider,113 sliderDisabled,114 dragging,115 btnSlider,116 isOk117 }118}119export const useInteractive = (120 slider,121 vertical,122 min,123 max,124 value,125 oldValue,126 modelValue,127 dispatch,128 emit,129 sliderSize,130 sliderDisabled,131 dragging,132 btnSlider,133 isVerifySlider,134 validateState,135 resetValue,136 type137) => {138 const getSlider = () => {139 return unref(slider)140 }141 const getBtn = () => {142 return unref(btnSlider)143 }144 const getResize = val => { // 监听宽高的回调函数,防止v-show问题145 sliderSize.value = unref(vertical) ? val.height : val.width146 }147 const valueChanged = () => { // 判断值是否发生改变148 return unref(value) !== unref(oldValue)149 }150 const emitChange = () => {151 nextTick(() => {152 emit('change', unref(value))153 })154 }155 const handleBlur = () => {156 dispatch('FormItem', 'form-blur', unref(modelValue))157 }158 const sliderChange = () => {159 dispatch('FormItem', 'form-change', unref(modelValue))160 }161 const onSliderClick = () => { // 当鼠标点击时,直接定位到位置162 const slider = getSlider()163 if (unref(sliderDisabled) || unref(dragging) || unref(isVerifySlider)) return null164 if (unref(vertical)) {165 const sliderOffsetBottom = slider.getBoundingClientRect().bottom166 setPosition(167 ((sliderOffsetBottom - event.clientY) / unref(sliderSize)) * 100168 )169 } else {170 const sliderOffsetLeft = slider.getBoundingClientRect().left171 setPosition(172 ((event.clientX - sliderOffsetLeft) / unref(sliderSize)) * 100173 )174 }175 emitChange()176 }177 const setValue = () => { // 建立和绑定初值,并且当值改变时,向Form派发验证178 if (unref(min) > unref(max)) {179 console.error('[Element Error][Slider]min should not be greater than max.')180 return null181 }182 if (unref(modelValue) < unref(min)) emit('update:modelValue', unref(min))183 else if (unref(modelValue) > unref(max)) emit('update:modelValue', unref(max))184 else {185 value.value = unref(modelValue)186 if (valueChanged()) {187 sliderChange()188 oldValue.value = unref(value)189 }190 }191 }192 const setPosition = (percent) => {193 const btn = getBtn()194 btn.setPosition(percent)195 }196 watch(modelValue, (newVal, oldVal) => {197 if (newVal === oldVal) return null198 setValue()199 })200 watch(value, value => {201 emit('update:modelValue', unref(value))202 })203 watch(dragging, val => {204 !val && setValue()205 })206 watch(validateState, val => {207 if (val === 'error' && unref(type) === 'verify') {208 resetValue()209 }210 })211 return {212 sliderSize,213 setValue,214 emitChange,215 onSliderClick,216 getResize,217 handleBlur218 }219}220export const useValidate = () => {221 const FormItem = inject('FormItem', '')222 const validateState = computed(() => {223 return FormItem ? FormItem.validateResult : ''224 })225 const resetValue = () => {226 if (FormItem) {227 FormItem.resetField()228 }229 }230 return { validateState, resetValue }231}232/**233 * 以下为滑动按钮组件的相关函数234 * */235export const useButtonSlider = (236 Slider,237 modelValue,238 vertical239) => {240 const btnSize = ref(0) // 用于记录拖动按钮宽度,默认为0,不影响计算241 const disabled = computed(() => {242 return Slider.sliderDisabled243 })244 const max = computed(() => {245 return Slider.max246 })247 const slidersize = computed(() => {248 return Slider.sliderSize249 })250 const totalDistance = computed(() => {251 if (Slider.type === 'verify') {252 return unref(slidersize) - unref(btnSize)253 }254 return unref(slidersize)255 })256 const min = computed(() => {257 return Slider.min258 })259 const isVerify = computed(() => {260 return Slider.isVerifySlider261 })262 const currentPosition = computed(() => {263 if (unref(isVerify)) {264 /**265 * / unref(slidersize) * unref(totalDistance)266 * 这一步骤主要处理类型为verify时,拖动框距离需要减去一个拖动按钮大小,所产生的变动267 * */268 return `${((unref(modelValue) - unref(min)) / (unref(max) - unref(min))) * 100 / unref(slidersize) * unref(totalDistance)}%`269 }270 return `${((unref(modelValue) - unref(min)) / (unref(max) - unref(min))) * 100}%`271 })272 const step = computed(() => {273 return Slider.step274 })275 const precision = computed(() => {276 return Slider.precision277 })278 const btnIcon = computed(() => {279 const arr = {280 success: 'fa-check',281 error: 'fa-arrow-right',282 validating: 'fa-arrow-right',283 default: 'fa-arrow-right'284 }285 return arr[unref(Slider.validateState)] || arr.default286 })287 const wrapperStyle = computed(() => {288 return unref(vertical)289 ? { bottom: unref(currentPosition) }290 : { left: unref(currentPosition) }291 })292 return {293 disabled,294 max,295 slidersize,296 min,297 currentPosition,298 step,299 precision,300 wrapperStyle,301 btnSize,302 isVerify,303 totalDistance,304 btnIcon305 }306}307export const useMouseEvent = (308 disabled,309 vertical,310 currentPosition,311 slidersize,312 step,313 max,314 min,315 precision,316 emit,317 Slider,318 btnSize,319 totalDistance320) => {321 const hovering = ref(false) // 是否接触到按钮322 const dragging = ref(false) // 是否正在拖动该按钮323 const isClick = ref(false) // 按钮是否被点击324 const startY = ref(0) // y轴滑动距离325 const currentY = ref(0) // y轴滑动距离326 const currentX = ref(0) // y轴滑动距离327 const startX = ref(0) // x轴滑动距离328 const startPosition = ref(0.0) // 用于记录开始位置329 const newPosition = ref(null) // 用于记录新的位置330 const getBtnSize = val => { // 用来获取当前滑动按钮的宽度或长度331 btnSize.value = unref(vertical) ? val.height : val.width332 }333 const handleMouseEnter = () => {334 hovering.value = true335 }336 const handleMouseLeave = () => {337 hovering.value = false338 }339 const onButtonDown = event => {340 if (unref(disabled)) return null // 如果被静止,触发事件取消341 event.preventDefault() // 取消事件的默认的动作, 可以防止屏幕滚动等342 onDragStart(event)343 window.addEventListener('mousemove', onDragging) // 添加事件监听344 window.addEventListener('touchmove', onDragging)345 window.addEventListener('mouseup', onDragEnd)346 window.addEventListener('touchend', onDragEnd)347 window.addEventListener('contextmenu', onDragEnd)348 }349 const onDragStart = event => { // 用于初始化拖动前的数值350 dragging.value = true351 isClick.value = true352 if (event.type === 'touchstart') { // 非鼠标操作,即手机端触摸开始时353 event.clientY = event.touches[0].clientY354 event.clientX = event.touches[0].clientX355 }356 if (vertical) {357 startY.value = event.clientY358 } else {359 startX.value = event.clientX360 }361 // 这里运用 * unref(slidersize) / unref(totalDistance) 还原verify类型下的数值362 startPosition.value = parseFloat(unref(currentPosition)) * unref(slidersize) / unref(totalDistance) // 获得当前位置,去除%363 newPosition.value = unref(startPosition)364 }365 const onDragging = event => {366 if (unref(dragging)) {367 isClick.value = false // 拖动时,点击为false368 let diff = 0369 if (event.type === 'touchmove') { // 触摸移动时,记录移动370 event.clientY = event.touches[0].clientY371 event.clientX = event.touches[0].clientX372 }373 if (vertical) {374 currentY.value = event.clientY375 diff = ((unref(startY) - unref(currentY)) / unref(totalDistance)) * 100 // 得出当前百分比值对应位置376 } else {377 currentX.value = event.clientX378 diff = ((unref(currentX) - unref(startX)) / unref(totalDistance)) * 100379 }380 newPosition.value = unref(startPosition) + diff381 setPosition(newPosition) // 更新拖动按钮相对位置382 }383 }384 const onDragEnd = () => {385 if (unref(dragging)) {386 // 用来防止mouseup后触发click,导致滑块有机率继续位移一段387 setTimeout(() => {388 dragging.value = false389 if (!unref(isClick)) {390 Slider.handleBlur()391 setPosition(newPosition)392 }393 }, 0)394 window.removeEventListener('mousemove', onDragging) // 移除监听事件395 window.removeEventListener('touchmove', onDragging)396 window.removeEventListener('mouseup', onDragEnd)397 window.removeEventListener('touchend', onDragEnd)398 window.removeEventListener('contextmenu', onDragEnd)399 }400 }401 const setPosition = newPosition => {402 const val = unref(newPosition)403 if (val !== null && !isNaN(val)) {404 // 限定拖动范围405 if (val < 0) newPosition.value = 0406 else if (val > 100) newPosition.value = 100407 const lengthPerStep = 100 / ((unref(max) - unref(min)) / unref(step))408 const steps = Math.round(unref(newPosition) / lengthPerStep)409 let value = steps * lengthPerStep * (unref(max) - unref(min)) * 0.01 + unref(min)410 value = parseFloat(value.toFixed(unref(precision))) // 根据精度,得到值一定小数点后几位的浮点数值411 emit('update:modelValue', value) // 传值412 }413 }414 watch(dragging, newVal => {415 Slider.dragging = unref(newVal)416 })417 return {418 hovering,419 dragging,420 handleMouseEnter,421 handleMouseLeave,422 onButtonDown,423 getBtnSize,424 setPosition425 }...

Full Screen

Full Screen

timers-ctx.js

Source:timers-ctx.js Github

copy

Full Screen

...221 this._handle = new Timer();222 this._handle[kOnTimeout] = this._onTimeout;223 this._handle.start(delay, 0);224 this._handle.domain = this.domain;225 this._handle.unref();226 } else {227 this._handle.unref();228 }229};230Timeout.prototype.ref = function() {231 if (this._handle)232 this._handle.ref();233};234Timeout.prototype.close = function() {235 this._onTimeout = this._ctx = null;236 if (this._handle) {237 this._handle[kOnTimeout] = null;238 this._handle.close();239 } else {240 exports.unenroll(this);241 }242};243var immediateQueue = {};244L.init(immediateQueue);245function processImmediate() {246 var queue = immediateQueue;247 immediateQueue = {};248 L.init(immediateQueue);249 while (L.isEmpty(queue) === false) {250 var immediate = L.shift(queue);251 var domain = immediate.domain;252 if (domain) domain.enter();253 immediate._onImmediate();254 if (domain) domain.exit();255 }256 // Only round-trip to C++ land if we have to. Calling clearImmediate() on an257 // immediate that's in |queue| is okay. Worst case is we make a superfluous258 // call to NeedImmediateCallbackSetter().259 if (L.isEmpty(immediateQueue)) {260 process._needImmediateCallback = false;261 }262}263exports.setImmediate = function(callback) {264 var immediate = {}, args;265 L.init(immediate);266 immediate._onImmediate = callback;267 if (arguments.length > 1) {268 args = Array.prototype.slice.call(arguments, 1);269 immediate._onImmediate = function() {270 callback.apply(immediate, args);271 };272 }273 if (!process._needImmediateCallback) {274 process._needImmediateCallback = true;275 process._immediateCallback = processImmediate;276 }277 if (process.domain) immediate.domain = process.domain;278 L.append(immediateQueue, immediate);279 return immediate;280};281exports.clearImmediate = function(immediate) {282 if (!immediate) return;283 immediate._onImmediate = undefined;284 L.remove(immediate);285 if (L.isEmpty(immediateQueue)) {286 process._needImmediateCallback = false;287 }288};289// Internal APIs that need timeouts should use timers._unrefActive isntead of290// timers.active as internal timeouts shouldn't hold the loop open291var unrefList, unrefTimer;292function unrefTimeout() {293 var now = Timer.now();294 debug('unrefTimer fired');295 var first;296 while (first = L.peek(unrefList)) {297 var diff = now - first._idleStart;298 if (diff < first._idleTimeout) {299 diff = first._idleTimeout - diff;300 unrefTimer.start(diff, 0);301 unrefTimer.when = now + diff;302 debug('unrefTimer rescheudling for later');303 return;304 }305 L.remove(first);306 var domain = first.domain;307 if (!first._onTimeout) continue;308 if (domain && domain._disposed) continue;309 try {310 if (domain) domain.enter();311 var threw = true;312 debug('unreftimer firing timeout');313 if (!first._ctx || first._ctx === first)314 first._onTimeout(); 315 else316 first._onTimeout.call(first._ctx);317 threw = false;318 if (domain) domain.exit();319 } finally {320 if (threw) process.nextTick(unrefTimeout);321 }322 }323 debug('unrefList is empty');324 unrefTimer.when = -1;325}326exports._unrefActive = function(item) {327 var msecs = item._idleTimeout;328 if (!msecs || msecs < 0) return;329 assert(msecs >= 0);330 L.remove(item);331 if (!unrefList) {332 debug('unrefList initialized');333 unrefList = {};334 L.init(unrefList);335 debug('unrefTimer initialized');336 unrefTimer = new Timer();337 unrefTimer.unref();338 unrefTimer.when = -1;339 unrefTimer[kOnTimeout] = unrefTimeout;340 }341 var now = Timer.now();342 item._idleStart = now;343 if (L.isEmpty(unrefList)) {344 debug('unrefList empty');345 L.append(unrefList, item);346 unrefTimer.start(msecs, 0);347 unrefTimer.when = now + msecs;348 debug('unrefTimer scheduled');349 return;350 }351 var when = now + msecs;...

Full Screen

Full Screen

SettingDrawer.jsx

Source:SettingDrawer.jsx Github

copy

Full Screen

...22 const { getIsHorizontal, getShowMenu, getMenuType, getTrigger, getCollapsedShowTitle, getMenuFixed, getCollapsed, getCanDrag, getTopMenuAlign, getAccordion, getMenuWidth, getMenuBgColor, getIsTopMenu, getSplit, getIsMixSidebar, getCloseMixSidebarOnChange, getMixSideTrigger, getMixSideFixed, } = useMenuSetting();23 const { getShowHeader, getFixed: getHeaderFixed, getHeaderBgColor, getShowSearch, } = useHeaderSetting();24 const { getShowMultipleTab, getShowQuick, getShowRedo, getShowFold } = useMultipleTabSetting();25 const getShowMenuRef = computed(() => {26 return unref(getShowMenu) && !unref(getIsHorizontal);27 });28 function renderSidebar() {29 return (<>30 <TypePicker menuTypeList={menuTypeList} handler={(item) => {31 baseHandler(HandlerEnum.CHANGE_LAYOUT, {32 mode: item.mode,33 type: item.type,34 split: unref(getIsHorizontal) ? false : undefined,35 });36 }} def={unref(getMenuType)}/>37 </>);38 }39 function renderHeaderTheme() {40 return (<ThemeColorPicker colorList={HEADER_PRESET_BG_COLOR_LIST} def={unref(getHeaderBgColor)} event={HandlerEnum.HEADER_THEME}/>);41 }42 function renderSiderTheme() {43 return (<ThemeColorPicker colorList={SIDE_BAR_BG_COLOR_LIST} def={unref(getMenuBgColor)} event={HandlerEnum.MENU_THEME}/>);44 }45 function renderMainTheme() {46 return (<ThemeColorPicker colorList={APP_PRESET_COLOR_LIST} def={unref(getThemeColor)} event={HandlerEnum.CHANGE_THEME_COLOR}/>);47 }48 /**49 * @description:50 */51 function renderFeatures() {52 let triggerDef = unref(getTrigger);53 const triggerOptions = getMenuTriggerOptions(unref(getSplit));54 const some = triggerOptions.some((item) => item.value === triggerDef);55 if (!some) {56 triggerDef = TriggerEnum.FOOTER;57 }58 return (<>59 <SwitchItem title={t('layout.setting.splitMenu')} event={HandlerEnum.MENU_SPLIT} def={unref(getSplit)} disabled={!unref(getShowMenuRef) || unref(getMenuType) !== MenuTypeEnum.MIX}/>60 <SwitchItem title={t('layout.setting.mixSidebarFixed')} event={HandlerEnum.MENU_FIXED_MIX_SIDEBAR} def={unref(getMixSideFixed)} disabled={!unref(getIsMixSidebar)}/>61 <SwitchItem title={t('layout.setting.closeMixSidebarOnChange')} event={HandlerEnum.MENU_CLOSE_MIX_SIDEBAR_ON_CHANGE} def={unref(getCloseMixSidebarOnChange)} disabled={!unref(getIsMixSidebar)}/>62 <SwitchItem title={t('layout.setting.menuCollapse')} event={HandlerEnum.MENU_COLLAPSED} def={unref(getCollapsed)} disabled={!unref(getShowMenuRef)}/>63 <SwitchItem title={t('layout.setting.menuDrag')} event={HandlerEnum.MENU_HAS_DRAG} def={unref(getCanDrag)} disabled={!unref(getShowMenuRef)}/>64 <SwitchItem title={t('layout.setting.menuSearch')} event={HandlerEnum.HEADER_SEARCH} def={unref(getShowSearch)} disabled={!unref(getShowHeader)}/>65 <SwitchItem title={t('layout.setting.menuAccordion')} event={HandlerEnum.MENU_ACCORDION} def={unref(getAccordion)} disabled={!unref(getShowMenuRef)}/>66 <SwitchItem title={t('layout.setting.collapseMenuDisplayName')} event={HandlerEnum.MENU_COLLAPSED_SHOW_TITLE} def={unref(getCollapsedShowTitle)} disabled={!unref(getShowMenuRef) || !unref(getCollapsed) || unref(getIsMixSidebar)}/>67 <SwitchItem title={t('layout.setting.fixedHeader')} event={HandlerEnum.HEADER_FIXED} def={unref(getHeaderFixed)} disabled={!unref(getShowHeader)}/>68 <SwitchItem title={t('layout.setting.fixedSideBar')} event={HandlerEnum.MENU_FIXED} def={unref(getMenuFixed)} disabled={!unref(getShowMenuRef) || unref(getIsMixSidebar)}/>69 <SelectItem title={t('layout.setting.mixSidebarTrigger')} event={HandlerEnum.MENU_TRIGGER_MIX_SIDEBAR} def={unref(getMixSideTrigger)} options={mixSidebarTriggerOptions} disabled={!unref(getIsMixSidebar)}/>70 <SelectItem title={t('layout.setting.topMenuLayout')} event={HandlerEnum.MENU_TOP_ALIGN} def={unref(getTopMenuAlign)} options={topMenuAlignOptions} disabled={!unref(getShowHeader) ||71 unref(getSplit) ||72 (!unref(getIsTopMenu) && !unref(getSplit)) ||73 unref(getIsMixSidebar)}/>74 <SelectItem title={t('layout.setting.menuCollapseButton')} event={HandlerEnum.MENU_TRIGGER} def={triggerDef} options={triggerOptions} disabled={!unref(getShowMenuRef) || unref(getIsMixSidebar)}/>75 <SelectItem title={t('layout.setting.contentMode')} event={HandlerEnum.CONTENT_MODE} def={unref(getContentMode)} options={contentModeOptions}/>76 <InputNumberItem title={t('layout.setting.autoScreenLock')} min={0} event={HandlerEnum.LOCK_TIME} defaultValue={unref(getLockTime)} formatter={(value) => {77 return parseInt(value) === 078 ? `0(${t('layout.setting.notAutoScreenLock')})`79 : `${value}${t('layout.setting.minute')}`;80 }}/>81 <InputNumberItem title={t('layout.setting.expandedMenuWidth')} max={600} min={100} step={10} event={HandlerEnum.MENU_WIDTH} disabled={!unref(getShowMenuRef)} defaultValue={unref(getMenuWidth)} formatter={(value) => `${parseInt(value)}px`}/>82 </>);83 }84 function renderContent() {85 return (<>86 <SwitchItem title={t('layout.setting.breadcrumb')} event={HandlerEnum.SHOW_BREADCRUMB} def={unref(getShowBreadCrumb)} disabled={!unref(getShowHeader)}/>87 <SwitchItem title={t('layout.setting.breadcrumbIcon')} event={HandlerEnum.SHOW_BREADCRUMB_ICON} def={unref(getShowBreadCrumbIcon)} disabled={!unref(getShowHeader)}/>88 <SwitchItem title={t('layout.setting.tabs')} event={HandlerEnum.TABS_SHOW} def={unref(getShowMultipleTab)}/>89 <SwitchItem title={t('layout.setting.tabsRedoBtn')} event={HandlerEnum.TABS_SHOW_REDO} def={unref(getShowRedo)} disabled={!unref(getShowMultipleTab)}/>90 <SwitchItem title={t('layout.setting.tabsQuickBtn')} event={HandlerEnum.TABS_SHOW_QUICK} def={unref(getShowQuick)} disabled={!unref(getShowMultipleTab)}/>91 <SwitchItem title={t('layout.setting.tabsFoldBtn')} event={HandlerEnum.TABS_SHOW_FOLD} def={unref(getShowFold)} disabled={!unref(getShowMultipleTab)}/>92 <SwitchItem title={t('layout.setting.sidebar')} event={HandlerEnum.MENU_SHOW_SIDEBAR} def={unref(getShowMenu)} disabled={unref(getIsHorizontal)}/>93 <SwitchItem title={t('layout.setting.header')} event={HandlerEnum.HEADER_SHOW} def={unref(getShowHeader)}/>94 <SwitchItem title="Logo" event={HandlerEnum.SHOW_LOGO} def={unref(getShowLogo)} disabled={unref(getIsMixSidebar)}/>95 <SwitchItem title={t('layout.setting.footer')} event={HandlerEnum.SHOW_FOOTER} def={unref(getShowFooter)}/>96 <SwitchItem title={t('layout.setting.fullContent')} event={HandlerEnum.FULL_CONTENT} def={unref(getFullContent)}/>97 <SwitchItem title={t('layout.setting.grayMode')} event={HandlerEnum.GRAY_MODE} def={unref(getGrayMode)}/>98 <SwitchItem title={t('layout.setting.colorWeak')} event={HandlerEnum.COLOR_WEAK} def={unref(getColorWeak)}/>99 </>);100 }101 function renderTransition() {102 return (<>103 <SwitchItem title={t('layout.setting.progress')} event={HandlerEnum.OPEN_PROGRESS} def={unref(getOpenNProgress)}/>104 <SwitchItem title={t('layout.setting.switchLoading')} event={HandlerEnum.OPEN_PAGE_LOADING} def={unref(getOpenPageLoading)}/>105 <SwitchItem title={t('layout.setting.switchAnimation')} event={HandlerEnum.OPEN_ROUTE_TRANSITION} def={unref(getEnableTransition)}/>106 <SelectItem title={t('layout.setting.animationType')} event={HandlerEnum.ROUTER_TRANSITION} def={unref(getBasicTransition)} options={routerTransitionOptions} disabled={!unref(getEnableTransition)}/>107 </>);108 }109 return () => (<BasicDrawer {...attrs} title={t('layout.setting.drawerTitle')} width={330} wrapClassName="setting-drawer">110 {unref(getShowDarkModeToggle) && <Divider>{() => t('layout.setting.darkMode')}</Divider>}111 {unref(getShowDarkModeToggle) && <AppDarkModeToggle class="mx-auto"/>}112 <Divider>{() => t('layout.setting.navMode')}</Divider>113 {renderSidebar()}114 <Divider>{() => t('layout.setting.sysTheme')}</Divider>115 {renderMainTheme()}116 <Divider>{() => t('layout.setting.headerTheme')}</Divider>117 {renderHeaderTheme()}118 <Divider>{() => t('layout.setting.sidebarTheme')}</Divider>119 {renderSiderTheme()}120 <Divider>{() => t('layout.setting.interfaceFunction')}</Divider>121 {renderFeatures()}122 <Divider>{() => t('layout.setting.interfaceDisplay')}</Divider>123 {renderContent()}124 <Divider>{() => t('layout.setting.animation')}</Divider>125 {renderTransition()}...

Full Screen

Full Screen

test-handle-wrap-isrefed.js

Source:test-handle-wrap-isrefed.js Github

copy

Full Screen

...9 strictEqual(Object.getPrototypeOf(cp._handle).hasOwnProperty('hasRef'),10 true, 'process_wrap: hasRef() missing');11 strictEqual(cp._handle.hasRef(),12 true, 'process_wrap: not initially refed');13 cp.unref();14 strictEqual(cp._handle.hasRef(),15 false, 'process_wrap: unref() ineffective');16 cp.ref();17 strictEqual(cp._handle.hasRef(),18 true, 'process_wrap: ref() ineffective');19 cp._handle.close(common.mustCall(() =>20 strictEqual(cp._handle.hasRef(),21 false, 'process_wrap: not unrefed on close')));22}23const dgram = require('dgram');24// dgram ipv425{26 const sock4 = dgram.createSocket('udp4');27 strictEqual(Object.getPrototypeOf(sock4._handle).hasOwnProperty('hasRef'),28 true, 'udp_wrap: ipv4: hasRef() missing');29 strictEqual(sock4._handle.hasRef(),30 true, 'udp_wrap: ipv4: not initially refed');31 sock4.unref();32 strictEqual(sock4._handle.hasRef(),33 false, 'udp_wrap: ipv4: unref() ineffective');34 sock4.ref();35 strictEqual(sock4._handle.hasRef(),36 true, 'udp_wrap: ipv4: ref() ineffective');37 sock4._handle.close(common.mustCall(() =>38 strictEqual(sock4._handle.hasRef(),39 false, 'udp_wrap: ipv4: not unrefed on close')));40}41// dgram ipv642{43 const sock6 = dgram.createSocket('udp6');44 strictEqual(Object.getPrototypeOf(sock6._handle).hasOwnProperty('hasRef'),45 true, 'udp_wrap: ipv6: hasRef() missing');46 strictEqual(sock6._handle.hasRef(),47 true, 'udp_wrap: ipv6: not initially refed');48 sock6.unref();49 strictEqual(sock6._handle.hasRef(),50 false, 'udp_wrap: ipv6: unref() ineffective');51 sock6.ref();52 strictEqual(sock6._handle.hasRef(),53 true, 'udp_wrap: ipv6: ref() ineffective');54 sock6._handle.close(common.mustCall(() =>55 strictEqual(sock6._handle.hasRef(),56 false, 'udp_wrap: ipv6: not unrefed on close')));57}58// pipe59{60 const Pipe = process.binding('pipe_wrap').Pipe;61 const handle = new Pipe();62 strictEqual(Object.getPrototypeOf(handle).hasOwnProperty('hasRef'),63 true, 'pipe_wrap: hasRef() missing');64 strictEqual(handle.hasRef(),65 true, 'pipe_wrap: not initially refed');66 handle.unref();67 strictEqual(handle.hasRef(),68 false, 'pipe_wrap: unref() ineffective');69 handle.ref();70 strictEqual(handle.hasRef(),71 true, 'pipe_wrap: ref() ineffective');72 handle.close(common.mustCall(() =>73 strictEqual(handle.hasRef(),74 false, 'pipe_wrap: not unrefed on close')));75}76// tcp77{78 const net = require('net');79 const server = net.createServer(() => {}).listen(0);80 strictEqual(Object.getPrototypeOf(server._handle).hasOwnProperty('hasRef'),81 true, 'tcp_wrap: hasRef() missing');82 strictEqual(server._handle.hasRef(),83 true, 'tcp_wrap: not initially refed');84 strictEqual(server._unref,85 false, 'tcp_wrap: _unref initially incorrect');86 server.unref();87 strictEqual(server._handle.hasRef(),88 false, 'tcp_wrap: unref() ineffective');89 strictEqual(server._unref,90 true, 'tcp_wrap: _unref not updated on unref()');91 server.ref();92 strictEqual(server._handle.hasRef(),93 true, 'tcp_wrap: ref() ineffective');94 strictEqual(server._unref,95 false, 'tcp_wrap: _unref not updated on ref()');96 server._handle.close(common.mustCall(() =>97 strictEqual(server._handle.hasRef(),98 false, 'tcp_wrap: not unrefed on close')));99}100// timers101{102 const timer = setTimeout(() => {}, 500);103 timer.unref();104 strictEqual(Object.getPrototypeOf(timer._handle).hasOwnProperty('hasRef'),105 true, 'timer_wrap: hasRef() missing');106 strictEqual(timer._handle.hasRef(),107 false, 'timer_wrap: unref() ineffective');108 timer.ref();109 strictEqual(timer._handle.hasRef(),110 true, 'timer_wrap: ref() ineffective');111 timer._handle.close(common.mustCall(() =>112 strictEqual(timer._handle.hasRef(),113 false, 'timer_wrap: not unrefed on close')));114}...

Full Screen

Full Screen

test-timers-unref.js

Source:test-timers-unref.js Github

copy

Full Screen

...9let checks = 0;10var LONG_TIME = 10 * 1000;11var SHORT_TIME = 100;12assert.doesNotThrow(function() {13 setTimeout(function() {}, 10).unref().ref().unref();14}, 'ref and unref are chainable');15assert.doesNotThrow(function() {16 setInterval(function() {}, 10).unref().ref().unref();17}, 'ref and unref are chainable');18setInterval(function() {19 interval_fired = true;20}, LONG_TIME).unref();21setTimeout(function() {22 timeout_fired = true;23}, LONG_TIME).unref();24const interval = setInterval(function() {25 unref_interval = true;26 clearInterval(interval);27}, SHORT_TIME);28interval.unref();29setTimeout(function() {30 unref_timer = true;31}, SHORT_TIME).unref();32const check_unref = setInterval(function() {33 if (checks > 5 || (unref_interval && unref_timer))34 clearInterval(check_unref);35 checks += 1;36}, 100);37setTimeout(function() {38 unref_callbacks++;39 this.unref();40}, SHORT_TIME);41// Should not timeout the test42setInterval(function() {43 this.unref();44}, SHORT_TIME);45// Should not assert on args.Holder()->InternalFieldCount() > 0. See #4261.46(function() {47 var t = setInterval(function() {}, 1);48 process.nextTick(t.unref.bind({}));49 process.nextTick(t.unref.bind(t));50})();51process.on('exit', function() {52 assert.strictEqual(interval_fired, false,53 'Interval should not fire');54 assert.strictEqual(timeout_fired, false,55 'Timeout should not fire');56 assert.strictEqual(unref_timer, true,57 'An unrefd timeout should still fire');...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.screenshot({ path: 'example.png' });7 await browser.close();8})();9const { chromium } = require('playwright');10(async () => {11 const browser = await chromium.launch();12 const context = await browser.newContext();13 const page = await context.newPage();14 await page.screenshot({ path: 'example.png' });15 await browser.close();16})();17const { chromium } = require('playwright');18(async () => {19 const browser = await chromium.launch();20 const context = await browser.newContext();21 const page = await context.newPage();22 await page.screenshot({ path: 'example.png' });23 await browser.close();24})();25const { chromium } = require('playwright');26(async () => {27 const browser = await chromium.launch();28 const context = await browser.newContext();29 const page = await context.newPage();30 await page.screenshot({ path: 'example.png' });31 await browser.close();32})();33const { chromium } = require('playwright');34(async () => {35 const browser = await chromium.launch();36 const context = await browser.newContext();37 const page = await context.newPage();38 await page.screenshot({ path: 'example.png' });39 await browser.close();40})();41const { chromium } = require('playwright');42(async () => {43 const browser = await chromium.launch();44 const context = await browser.newContext();45 const page = await context.newPage();46 await page.screenshot({ path

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.screenshot({ path: 'example.png' });7 await browser.close();8})();9const { chromium } = require('playwright');10(async () => {11 const browser = await chromium.launch({ headless: false });12 const context = await browser.newContext();13 const page = await context.newPage();14 await page.screenshot({ path: 'example.png' });15 await browser.close();16})();17const { chromium } = require('playwright');18(async () => {19 const browser = await chromium.launch({ headless: false });20 const context = await browser.newContext();21 const page = await context.newPage();22 await page.screenshot({ path: 'example.png' });23 await browser.close();24})();25const { chromium } = require('playwright');26(async () => {27 const browser = await chromium.launch({ headless: false });28 const context = await browser.newContext();29 const page = await context.newPage();30 await page.screenshot({ path: 'example.png' });31 await browser.close();32})();33const { chromium } = require('playwright');34(async () => {35 const browser = await chromium.launch({ headless: false });36 const context = await browser.newContext();37 const page = await context.newPage();38 await page.screenshot({ path: 'example.png' });39 await browser.close();40})();41const { chromium } = require('playwright');42(async () => {43 const browser = await chromium.launch({ headless: false });

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.screenshot({ path: 'google.png' });7 await browser.close();8})();9const { chromium } = require('playwright');10(async () => {11 const browser = await chromium.launch();12 const context = await browser.newContext();13 const page = await context.newPage();14 await page.screenshot({ path: 'google.png' });15 await browser.close();16})();17const { chromium } = require('playwright');18(async () => {19 const browser = await chromium.launch();20 const context = await browser.newContext();21 const page = await context.newPage();22 await page.screenshot({ path: 'google.png' });23 await browser.close();24})();25const { chromium } = require('playwright');26(async () => {27 const browser = await chromium.launch();28 const context = await browser.newContext();29 const page = await context.newPage();30 await page.screenshot({ path: 'google.png' });31 await browser.close();32})();33const { chromium } = require('playwright');34(async () => {35 const browser = await chromium.launch();36 const context = await browser.newContext();37 const page = await context.newPage();38 await page.screenshot({ path: 'google.png' });39 await browser.close();40})();41const { chromium } = require('playwright');42(async () => {43 const browser = await chromium.launch();44 const context = await browser.newContext();45 const page = await context.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.screenshot({ path: `example.png` });7 await browser.close();8})();9const { chromium } = require('playwright');10(async () => {11 const browser = await chromium.launch({ headless: false });12 const context = await browser.newContext();13 const page = await context.newPage();14 await page.screenshot({ path: `example.png` });15 await browser.close();16})();17const { chromium } = require('playwright');18(async () => {19 const browser = await chromium.launch({ headless: false });20 const context = await browser.newContext();21 const page = await context.newPage();22 await page.screenshot({ path: `example.png` });23 await browser.close();24})();25const { chromium } = require('playwright');26(async () => {27 const browser = await chromium.launch({ headless: false });28 const context = await browser.newContext();29 const page = await context.newPage();30 await page.screenshot({ path: `example.png` });31 await browser.close();32})();33const { chromium } = require('playwright');34(async () => {35 const browser = await chromium.launch({ headless: false });36 const context = await browser.newContext();37 const page = await context.newPage();38 await page.screenshot({ path: `example.png` });39 await browser.close();40})();41const { chromium } = require('playwright');42(async () => {43 const browser = await chromium.launch({ headless: false });

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2(async () => {3 const browser = await playwright.webkit.launch({ headless: false });4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.waitForTimeout(5000);7 await browser.close();8})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.screenshot({ path: `example.png` });6 browser.close();7})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.screenshot({ path: 'example.png' });7 await browser.close();8})();9const { chromium } = require('playwright');10(async () => {11 const browser = await chromium.launch();12 const context = await browser.newContext();13 const page = await context.newPage();14 await page.screenshot({ path: 'example.png' });15 await browser.close();16})();17const { chromium } = require('playwright');18(async () => {19 const browser = await chromium.launch();20 const context = await browser.newContext();21 const page = await context.newPage();22 await page.screenshot({ path: 'example.png' });23 await browser.close();24})();25const { chromium } = require('playwright');26(async () => {27 const browser = await chromium.launch();28 const context = await browser.newContext();29 const page = await context.newPage();30 await page.screenshot({ path: 'example.png' });31 await browser.close();32})();33const { chromium } = require('playwright');34(async () => {35 const browser = await chromium.launch();36 const context = await browser.newContext();37 const page = await context.newPage();38 await page.screenshot({ path: 'example.png' });39 await browser.close();40})();41const { chromium }

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Playwright } = require('playwright-core');2const playwright = new Playwright({3});4const browser = await playwright.chromium.launch({ headless: false });5const context = await browser.newContext();6const page = await context.newPage();7await page.waitForTimeout(1000);8await browser.close();9await browser._cleanup();10await browser._exit();11process.exit(1);12const { Playwright } = require('playwright-core');13const playwright = new Playwright({14});15const browser = await playwright.chromium.launch({ headless: false });16const context = await browser.newContext();17const page = await context.newPage();18await page.waitForTimeout(1000);19await browser.close();20await browser._cleanup();21await browser._exit();22process.exit(1);23const { Playwright } = require('playwright-core');24const playwright = new Playwright({25});26const browser = await playwright.chromium.launch({ headless: false });27const context = await browser.newContext();28const page = await context.newPage();29await page.waitForTimeout(1000);30await browser.close();31await browser._cleanup();32await browser._exit();33process.exit(1);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright-chromium');2const { unref } = require('playwright-core/lib/server/browserType');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.screenshot({ path: `example.png` });8 await browser.close();9 unref();10})();11const { chromium } = require('playwright-chromium');12const { unref } = require('playwright-core/lib/server/browserType');13(async () => {14 const browser = await chromium.launch();15 const context = await browser.newContext();16 const page = await context.newPage();17 await page.screenshot({ path: `example.png` });18 await browser.close();19 unref();20})();21const { chromium } = require('playwright-chromium');22const { unref } = require('playwright-core/lib/server/browserType');23(async () => {24 const browser = await chromium.launch();25 const context = await browser.newContext();26 const page = await context.newPage();27 await page.screenshot({ path: `example.png` });28 await browser.close();29 unref();30})();31const { chromium } = require('playwright-chromium');32const { unref } = require('playwright-core/lib/server/browserType');33(async () => {34 const browser = await chromium.launch();35 const context = await browser.newContext();36 const page = await context.newPage();37 await page.screenshot({ path: `example.png` });38 await browser.close();39 unref();40})();

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