How to use pad method in Playwright Internal

Best JavaScript code snippet using playwright-internal

app.js

Source:app.js Github

copy

Full Screen

1// modern Navigation bar code start here2const navSlide = () => {3 const burger = document.querySelector(".burger");4 const nav = document.querySelector(".nav-links");5 const navLinks = document.querySelectorAll(".nav-links li");6 //toggle nav7 burger.addEventListener("click", () => {8 nav.classList.toggle("nav-active");9 //animate links10 navLinks.forEach((link, index) => {11 if (link.style.animation) {12 link.style.animation = "";13 } else {14 link.style.animation = `navLinkFade 0.5s ease forwards ${15 index / 7 + 0.616 }s`;17 }18 });19 //burger animation20 burger.classList.toggle("toggle");21 });22 document.addEventListener("click", (e) => {23 if (e.target.matches(".navigation")) return;24 nav.classList.remove("nav-active");25 burger.classList.remove("toggle");26 navLinks.forEach((link) => {27 link.style.animation = "";28 });29 });30};31navSlide();32// modern Navigation bar code stop here33// modal form for saving start here34const modal = document.querySelector(".main-modal");35const modalCloseBtn = document.querySelector(".modal-close");36//closing modal37function modalClose() {38 modal.classList.remove("fadeIn");39 modal.classList.add("fadeOut");40 setTimeout(() => {41 modal.style.display = "none";42 }, 800);43}44//openning modal45document.querySelector(".save").addEventListener("click", function () {46 modal.classList.remove("fadeOut");47 modal.classList.add("fadeIn");48 modal.style.display = "flex";49});50modalCloseBtn.addEventListener("click", function (e) {51 modalClose();52});53// /// © 2021 dev-aly3n ///54window.addEventListener("click", function (e) {55 if (e.target == modal) {56 modalClose();57 }58});59// modal form for saving finish here60// modal form for loading start here61const modalLoad = document.querySelector(".main-modal-load");62const modalLoadCloseBtn = document.querySelector(".modal-close-load");63function modalCloseLoad() {64 modalLoad.classList.remove("fadeIn");65 modalLoad.classList.add("fadeOut");66 setTimeout(() => {67 modalLoad.style.display = "none";68 }, 800);69}70document.querySelector(".load").addEventListener("click", function () {71 modalLoad.classList.remove("fadeOut");72 modalLoad.classList.add("fadeIn");73 modalLoad.style.display = "flex";74});75modalLoadCloseBtn.addEventListener("click", function (e) {76 modalCloseLoad();77});78window.addEventListener("click", function (e) {79 if (e.target == modalLoad) {80 modalCloseLoad();81 }82});83// modal form for loading finish here84// modal for confirm clearing start here85const modalConfirm = document.querySelector(".main-modal-confirm");86const modalConfirmCloseBtn = document.querySelector(".modal-close-confirm");87function modalConfirmClose() {88 modalConfirm.classList.remove("fadeIn");89 modalConfirm.classList.add("fadeOut");90 setTimeout(() => {91 modalConfirm.style.display = "none";92 }, 800);93}94document.querySelector(".clear-all").addEventListener("click", function () {95 modalConfirm.classList.remove("fadeOut");96 modalConfirm.classList.add("fadeIn");97 modalConfirm.style.display = "flex";98});99modalConfirmCloseBtn.addEventListener("click", function (e) {100 modalConfirmClose();101});102window.addEventListener("click", function (e) {103 if (e.target == modalConfirm) {104 modalConfirmClose();105 }106});107// modal for confirm clearing finish here108//drum app start here109class Drum {110 constructor() {111 this.pads = document.querySelectorAll(".pad");112 this.kickAudio = document.querySelector(".kick-sound");113 this.snareAudio = document.querySelector(".snare-sound");114 this.hihatAudio = document.querySelector(".hihat-sound");115 this.clapAudio = document.querySelector(".clap-sound");116 this.effectAudio = document.querySelector(".effect-sound");117 this.currentKick = "./sounds/kick8.mp3";118 this.currentSnare = "./sounds/snare9.mp3";119 this.currentHihat = "./sounds/hihat4.mp3";120 this.currentClap = "./sounds/clap1.mp3";121 this.currentEffect = "./sounds/effect7.mp3";122 this.selectS = document.querySelectorAll("select");123 this.playBtn = document.querySelector(".play");124 this.index = 0;125 this.bpm = 200;126 this.play = null;127 this.volumeBtnS = document.querySelectorAll(".volume");128 this.tempoSlider = document.querySelector(".tempo-slider");129 this.randomizeBtnS = document.querySelectorAll(".randomize");130 this.randomizeAllBtn = document.querySelector(".randomize-all");131 this.increaseBtn = document.querySelector(".increase");132 this.decreaseBtn = document.querySelector(".decrease");133 this.saveBtn = document.querySelector("#save-btn-form");134 this.clearBtn = document.querySelector("#confirm-clear");135 }136 // return true/false doe to the random number is odd or not137 random(x) {138 return Math.random() < x;139 // return (Math.random()*1000000000).toFixed(0) %2 ===0;140 }141 // repeating the pads in a loop. reminder of 10 will make the step start from 0 to 9142 //and active bars will show the column of bars that they currently active143 // this keyword reffer to this object here144 repeat() {145 const padNum = document.querySelectorAll(".kick-pad").length;146 let step = this.index % padNum;147 const activeBars = document.querySelectorAll(`.b${step}`);148 // appending an animation style to the current pads and then remove them after finishing animation by an eventlistener to repeat again149 activeBars.forEach((pad) => {150 pad.style.animation = `boomBoom 0.25s alternate ease-in-out 2`;151 // fixing the issue with repeating the song in every pad152 if (pad.classList.contains("active")) {153 if (pad.classList.contains("kick-pad")) {154 this.kickAudio.currentTime = 0;155 this.kickAudio.play();156 }157 if (pad.classList.contains("snare-pad")) {158 this.snareAudio.currentTime = 0;159 this.snareAudio.play();160 }161 if (pad.classList.contains("hihat-pad")) {162 this.hihatAudio.currentTime = 0;163 this.hihatAudio.play();164 }165 if (pad.classList.contains("clap-pad")) {166 this.clapAudio.currentTime = 0;167 this.clapAudio.play();168 }169 if (pad.classList.contains("effect-pad")) {170 this.effectAudio.currentTime = 0;171 this.effectAudio.play();172 }173 }174 });175 this.index++;176 }177 // start the loop by an interval. bpm will handle the speed of the loop178 // the arrow function here allow us to use this keyword reffering to the current object179 // this.index will reffer to the times of the loop running. so by deviding to 10 the reminder will looping between 0 - 9180 start() {181 const interval = (60 / this.bpm) * 1000;182 //check if the track now is playing or not to avoid running multiple intervals by clicking on the start btn183 //adding class active that can be usefull in when we want to check if the tracks are playing or not184 if (!this.play) {185 this.playBtn.innerText = "Stop";186 this.playBtn.classList.add("active");187 this.play = setInterval(() => {188 this.repeat();189 }, interval);190 } else {191 this.playBtn.innerText = "Play";192 this.playBtn.classList.remove("active");193 clearInterval(this.play);194 this.play = null;195 }196 }197 // toggle the class active to the pads after clicking on them198 activePad() {199 this.classList.toggle("active");200 }201 //add an eventLisener to the selects and change the songs src202 changeSound(e) {203 const selectionName = e.target.name;204 const selectionValue = e.target.value;205 switch (selectionName) {206 case "kick-select":207 this.kickAudio.src = selectionValue;208 break;209 case "snare-select":210 this.snareAudio.src = selectionValue;211 break;212 case "hihat-select":213 this.hihatAudio.src = selectionValue;214 break;215 case "clap-select":216 this.clapAudio.src = selectionValue;217 break;218 case "effect-select":219 this.effectAudio.src = selectionValue;220 break;221 }222 }223 //hovering sound icon will showing a tooltip that will open a range slider for volume224 //we take the volume by input listener and change it via this method225 volume(e) {226 const dataTrack = e.target.getAttribute("data-track");227 //we have to make it a number between 0 to 1 to assign it to the volume228 const volume = e.target.value / 100;229 switch (dataTrack) {230 case "kick":231 this.kickAudio.volume = volume;232 break;233 case "snare":234 this.snareAudio.volume = volume;235 break;236 case "hihat":237 this.hihatAudio.volume = volume;238 break;239 case "clap":240 this.clapAudio.volume = volume;241 break;242 case "effect":243 this.effectAudio.volume = volume;244 break;245 }246 }247 //changing the text of span to show input value oninput248 volumeNum(e) {249 let volumeNum = e.target.nextElementSibling;250 volumeNum.innerText = e.target.value;251 }252 //change the bpm of the track by a slider253 //change the text parameter of the tempo in the same time254 changeTempo(e) {255 document.querySelector(".tempo-num").innerText = e;256 }257 // change the actual bpm after that user changed the slider258 // we reset all the parameter and then check if the song is now playing? if yes then we start it with new bpm and else we do nothing259 updateTempo(e) {260 this.bpm = e;261 clearInterval(this.play);262 this.play = null;263 const playBtn = document.querySelector(".play");264 if (playBtn.classList.contains("active")) {265 this.start();266 }267 }268 // by cliking the randomize btn at first we have to undrstand which track randomized that we can know it by data-track269 //then we will get all pads of thath track and make it randomize270 randomizer(e) {271 const randomName = e.target.getAttribute("data-track");272 const randomPad = document.querySelectorAll(`.${randomName}-pad`);273 //at first we have to remove all the active classes from the track or no after 2 or 3 times all of pads will be active274 randomPad.forEach((pad) => pad.classList.remove("active"));275 //then we can randomize our pads by a very ugly way. when a pad is active, the next pad have a less chance to be active276 //by this approach we can handle over-active pads277 randomPad.forEach((el, index) => {278 if (index >= 1) {279 if (randomPad[index - 1].classList.contains("active")) {280 if (this.random(0.2)) {281 el.classList.add("active");282 }283 } else {284 if (this.random(0.5)) {285 el.classList.add("active");286 }287 }288 } else {289 if (this.random()) {290 el.classList.add("active");291 }292 }293 });294 }295 // randomize all pads. just like the randomizer()296 randomizeAll() {297 const randomPad = document.querySelectorAll(".pad");298 //at first we have to remove all the active classes from the track or no after 2 or 3 times all of pads will be active299 randomPad.forEach((pad) => pad.classList.remove("active"));300 //then we can randomize our pads by a very ugly way. when a pad is active, the next pad have a less chance to be active301 //by this approach we can handle over-active pads302 randomPad.forEach((el, index) => {303 if (index >= 1) {304 if (randomPad[index - 1].classList.contains("active")) {305 if (this.random(0.2)) {306 el.classList.add("active");307 }308 } else {309 if (this.random(0.5)) {310 el.classList.add("active");311 }312 }313 } else {314 if (this.random()) {315 el.classList.add("active");316 }317 }318 });319 }320 //increasing pads one by one . at first we get number of pads in each row and then append a new pad to them321 //to the point the new pad could toggle the active class, we have to call the active method in this method again322 increasePad() {323 let padNumber = document.querySelectorAll(".kick-pad").length;324 let trackNumber = document.querySelectorAll(".track");325 if (padNumber <= 15) {326 trackNumber.forEach((track) => {327 let dataTrack = track.getAttribute("data-track");328 let newPads = document.createElement("div");329 newPads.classList = `pad ${dataTrack}-pad b${padNumber}`;330 document.querySelector(`.${dataTrack}`).appendChild(newPads);331 });332 }333 }334 //just like the increasePad() method but we remove the last Pad every time335 decreasePad() {336 let padNumber = document.querySelectorAll(".kick-pad").length;337 let trackNumber = document.querySelectorAll(".track");338 if (padNumber >= 5) {339 trackNumber.forEach((track) => {340 track.children[padNumber - 1].remove();341 });342 }343 }344 //saving the current track345 //BCS of complication of this method we add comment to every section346 save(trackName) {347 // we get all the pad when the method execute348 const currentPads = document.querySelectorAll(".pad");349 //we cant push a nodeList into Local storage . so we have to change it to an array by this mehtod first350 //we push the outer html to an array351 //we added new-save class to add the new saved track to add an eventListener to them352 const newArr = [];353 currentPads.forEach((el) => {354 el.classList.remove("new-save");355 newArr.push(el.outerHTML);356 });357 //then we push volume and tracknumbers to end of the array and then we push tempo358 newArr.push(document.querySelector(".effect-volume").value / 100);359 newArr.push(document.querySelector(".clap-volume").value / 100);360 newArr.push(document.querySelector(".hihat-volume").value / 100);361 newArr.push(document.querySelector(".snare-volume").value / 100);362 newArr.push(document.querySelector(".kick-volume").value / 100);363 newArr.push(document.querySelector("#kick-select").value);364 newArr.push(document.querySelector("#snare-select").value);365 newArr.push(document.querySelector("#hihat-select").value);366 newArr.push(document.querySelector("#clap-select").value);367 newArr.push(document.querySelector("#effect-select").value);368 let tempo = document.querySelector(".tempo-num").textContent;369 tempo = Number(tempo);370 newArr.push(tempo);371 //after pushing all value we need. then we save it to local storage by the chosen name372 localStorage.setItem(`${trackName}`, JSON.stringify(newArr));373 //showing the saved track in loading page374 //after loading the page all saved track will be shown in the load page but if we want to show the new saved track too, then we need to add it here375 const item = document.createElement("div");376 item.innerText = trackName;377 item.classList.add("track-load-style");378 item.classList.add("new-save");379 document.querySelector(".your-tracks-content").appendChild(item);380 //add the event listener to the new saved track381 const loadContent = document.querySelectorAll(".new-save");382 loadContent.forEach((el) => {383 el.addEventListener("click", (track) => {384 const loadTrack = track.target.textContent;385 //then we call the load method if user click on the track name386 this.load(loadTrack);387 });388 });389 }390 //loading a track391 //this is a complicated method so we will add comment in every section392 load(trackName) {393 //we get all current pads to prepare the stage for loading394 let pads = document.querySelectorAll(".pad");395 //we will remove all the current activated pad to prepare the stage for loading396 pads.forEach((pad) => {397 pad.classList.remove("active");398 });399 //then we get the clicked track from local storage and make it an array again400 let trackArray = JSON.parse(localStorage.getItem(trackName));401 //removing the last element and assign it to a varible402 let tempo = trackArray.pop();403 let effectSrc = trackArray.pop();404 this.effectAudio.src = effectSrc;405 let clapSrc = trackArray.pop();406 this.clapAudio.src = clapSrc;407 let hihatSrc = trackArray.pop();408 this.hihatAudio.src = hihatSrc;409 let snareSrc = trackArray.pop();410 this.snareAudio.src = snareSrc;411 let kickSrc = trackArray.pop();412 this.kickAudio.src = kickSrc;413 //changing the sound volume by loaded value and then changing the number that showing in the span414 let kickVolume = trackArray.pop();415 this.kickAudio.volume = kickVolume;416 document.querySelector(".kick-volume").value = kickVolume * 100;417 document.querySelector(".kick-volume").nextElementSibling.innerText =418 kickVolume * 100;419 let snareVolume = trackArray.pop();420 this.snareAudio.volume = snareVolume;421 document.querySelector(".snare-volume").value = snareVolume * 100;422 document.querySelector(".snare-volume").nextElementSibling.innerText =423 snareVolume * 100;424 let hihatVolume = trackArray.pop();425 this.hihatAudio.volume = hihatVolume;426 document.querySelector(".hihat-volume").value = hihatVolume * 100;427 document.querySelector(".hihat-volume").nextElementSibling.innerText =428 hihatVolume * 100;429 let clapVolume = trackArray.pop();430 this.clapAudio.volume = clapVolume;431 document.querySelector(".clap-volume").value = clapVolume * 100;432 document.querySelector(".clap-volume").nextElementSibling.innerText =433 clapVolume * 100;434 let effectVolume = trackArray.pop();435 this.effectAudio.volume = effectVolume;436 document.querySelector(".effect-volume").value = effectVolume * 100;437 document.querySelector(".effect-volume").nextElementSibling.innerText =438 effectVolume * 100;439 // change what the select input showing to us440 document.querySelectorAll("select").forEach((select) => {441 //taking number of options442 let optionLength = select.options.length;443 //evaluate every options and if the option src was equal to the loaded one then we assign the i to the input selectedIndex444 for (let i = 0; i < optionLength; i++) {445 if (select.options[i].value == kickSrc) {446 select.options.selectedIndex = i;447 } else if (select.options[i].value == snareSrc) {448 select.options.selectedIndex = i;449 } else if (select.options[i].value == hihatSrc) {450 select.options.selectedIndex = i;451 } else if (select.options[i].value == clapSrc) {452 select.options.selectedIndex = i;453 } else if (select.options[i].value == effectSrc) {454 select.options.selectedIndex = i;455 }456 }457 });458 //we want to make number of pads as number of the loaded track to activate them459 //so first we calculate the number of pad in every row460 let loadLength = trackArray.length;461 let lengthDiffrence = (loadLength - pads.length) / 5;462 //then we check if the pads are more than the loaded one we call the increasePad() method by a for loop and same for less pad than loaded one463 if (lengthDiffrence > 0) {464 for (let i = lengthDiffrence; i > 0; i--) {465 this.increasePad();466 }467 } else {468 for (let i = lengthDiffrence; i < 0; i++) {469 this.decreasePad();470 }471 }472 //after increasing or decreasing pads then we have to get current pads again473 pads = document.querySelectorAll(".pad");474 //then for every element in trackArray that have active class we add active class to the same index pad in pads nodeList475 //BCS if the element not contain the active class will return a negative value (-1) so we put this if statement to get active pads476 trackArray.forEach((el, index) => {477 if (el.indexOf("active") >= 0) {478 pads[index].classList.add("active");479 }480 });481 //change the tempo value by the value of the loaded track482 this.changeTempo(tempo);483 this.updateTempo(tempo);484 this.tempoSlider.value = tempo;485 //we will close the modal after user clicking on a track name486 modalCloseLoad();487 //update drum.pads and call the activePad eventLisener again488 //BCS the new pads that added by increasePad() method have not the click listener so we have to add this event listener again (and the animation listener too)489 drum.pads = document.querySelectorAll(".pad");490 drum.pads.forEach((pad) => {491 pad.addEventListener("click", drum.activePad);492 pad.addEventListener("animationend", function () {493 this.style.animation = "";494 });495 });496 }497 //remove the active class from all pads498 clearActive() {499 let pads = document.querySelectorAll(".pad");500 pads.forEach((pad) => {501 pad.classList.remove("active");502 });503 }504 //this method is same as the load() method. so we just add comment to new option here505 loadSamples(trackName) {506 //we add some song for example507 const weWillRockYou = [508 "pad kick-pad b0 active",509 "pad kick-pad b1 active",510 "pad kick-pad b2",511 "pad kick-pad b3",512 "pad kick-pad b4 active",513 "pad kick-pad b5 active",514 "pad kick-pad b6",515 "pad kick-pad b7",516 "pad snare-pad b0",517 "pad snare-pad b1",518 "pad snare-pad b2 active",519 "pad snare-pad b3",520 "pad snare-pad b4",521 "pad snare-pad b5",522 "pad snare-pad b6 active",523 "pad snare-pad b7",524 "pad hihat-pad b0",525 "pad hihat-pad b1",526 "pad hihat-pad b2",527 "pad hihat-pad b3 active",528 "pad hihat-pad b4",529 "pad hihat-pad b5",530 "pad hihat-pad b6",531 "pad hihat-pad b7",532 "pad clap-pad b0",533 "pad clap-pad b1",534 "pad clap-pad b2 active",535 "pad clap-pad b3",536 "pad clap-pad b4",537 "pad clap-pad b5",538 "pad clap-pad b6 active",539 "pad clap-pad b7",540 "pad effect-pad b0",541 "pad effect-pad b1",542 "pad effect-pad b2",543 "pad effect-pad b3 active",544 "pad effect-pad b4",545 "pad effect-pad b5",546 "pad effect-pad b6",547 "pad effect-pad b7",548 1,549 1,550 1,551 1,552 1,553 "./sounds/kick8.mp3",554 "./sounds/snare5.mp3",555 "./sounds/hihat4.mp3",556 "./sounds/clap1.mp3",557 "./sounds/effect7.mp3",558 170,559 ];560 const hipHop68 = [561 "pad kick-pad b0",562 "pad kick-pad b1 active",563 "pad kick-pad b2",564 "pad kick-pad b3",565 "pad kick-pad b4 active",566 "pad kick-pad b5",567 "pad kick-pad b6",568 "pad kick-pad b7 active",569 "pad snare-pad b0",570 "pad snare-pad b1 active",571 "pad snare-pad b2",572 "pad snare-pad b3",573 "pad snare-pad b4",574 "pad snare-pad b5 active",575 "pad snare-pad b6",576 "pad snare-pad b7",577 "pad hihat-pad b0",578 "pad hihat-pad b1 active",579 "pad hihat-pad b2",580 "pad hihat-pad b3",581 "pad hihat-pad b4",582 "pad hihat-pad b5 active",583 "pad hihat-pad b6",584 "pad hihat-pad b7",585 "pad clap-pad b0",586 "pad clap-pad b1",587 "pad clap-pad b2",588 "pad clap-pad b3",589 "pad clap-pad b4",590 "pad clap-pad b5",591 "pad clap-pad b6",592 "pad clap-pad b7",593 "pad effect-pad b0",594 "pad effect-pad b1",595 "pad effect-pad b2",596 "pad effect-pad b3",597 "pad effect-pad b4",598 "pad effect-pad b5",599 "pad effect-pad b6",600 "pad effect-pad b7",601 1,602 1,603 1,604 1,605 1,606 "./sounds/kick1.mp3",607 "./sounds/snare4.mp3",608 "./sounds/hihat7.mp3",609 "./sounds/clap1.mp3",610 "./sounds/effect7.mp3",611 300,612 ];613 // Atefeh is my girlfriend and all of these sample songs created by her. she is a good musician. her musical instrument is Daf.614 const heartOfAtefeh = [615 "pad kick-pad b0 active",616 "pad kick-pad b1",617 "pad kick-pad b2",618 "pad kick-pad b3 active",619 "pad kick-pad b4",620 "pad kick-pad b5",621 "pad kick-pad b6",622 "pad kick-pad b7",623 "pad kick-pad b8 active",624 "pad kick-pad b9",625 "pad kick-pad b10",626 "pad kick-pad b11 active",627 "pad kick-pad b12",628 "pad kick-pad b13",629 "pad kick-pad b14",630 "pad kick-pad b15",631 "pad snare-pad b0",632 "pad snare-pad b1 active",633 "pad snare-pad b2",634 "pad snare-pad b3",635 "pad snare-pad b4",636 "pad snare-pad b5",637 "pad snare-pad b6 active",638 "pad snare-pad b7",639 "pad snare-pad b8",640 "pad snare-pad b9 active",641 "pad snare-pad b10",642 "pad snare-pad b11",643 "pad snare-pad b12 active",644 "pad snare-pad b13",645 "pad snare-pad b14",646 "pad snare-pad b15",647 "pad hihat-pad b0",648 "pad hihat-pad b1",649 "pad hihat-pad b2 active",650 "pad hihat-pad b3",651 "pad hihat-pad b4 active",652 "pad hihat-pad b5 active",653 "pad hihat-pad b6",654 "pad hihat-pad b7",655 "pad hihat-pad b8",656 "pad hihat-pad b9",657 "pad hihat-pad b10 active",658 "pad hihat-pad b11",659 "pad hihat-pad b12",660 "pad hihat-pad b13",661 "pad hihat-pad b14",662 "pad hihat-pad b15",663 "pad clap-pad b0",664 "pad clap-pad b1",665 "pad clap-pad b2",666 "pad clap-pad b3",667 "pad clap-pad b4 active",668 "pad clap-pad b5",669 "pad clap-pad b6",670 "pad clap-pad b7",671 "pad clap-pad b8",672 "pad clap-pad b9",673 "pad clap-pad b10",674 "pad clap-pad b11",675 "pad clap-pad b12",676 "pad clap-pad b13",677 "pad clap-pad b14",678 "pad clap-pad b15",679 "pad effect-pad b0",680 "pad effect-pad b1",681 "pad effect-pad b2",682 "pad effect-pad b3",683 "pad effect-pad b4",684 "pad effect-pad b5",685 "pad effect-pad b6 active",686 "pad effect-pad b7",687 "pad effect-pad b8",688 "pad effect-pad b9",689 "pad effect-pad b10",690 "pad effect-pad b11",691 "pad effect-pad b12",692 "pad effect-pad b13",693 "pad effect-pad b14",694 "pad effect-pad b15",695 1,696 1,697 1,698 1,699 1,700 "./sounds/kick2.mp3",701 "./sounds/snare3.mp3",702 "./sounds/hihat2.mp3",703 "./sounds/clap2.mp3",704 "./sounds/effect7.mp3",705 300,706 ];707 const tryAgain = [708 "pad kick-pad b0",709 "pad kick-pad b1",710 "pad kick-pad b2",711 "pad kick-pad b3 active",712 "pad kick-pad b4",713 "pad kick-pad b5",714 "pad kick-pad b6",715 "pad kick-pad b7",716 "pad snare-pad b0",717 "pad snare-pad b1 active",718 "pad snare-pad b2",719 "pad snare-pad b3",720 "pad snare-pad b4",721 "pad snare-pad b5",722 "pad snare-pad b6",723 "pad snare-pad b7",724 "pad hihat-pad b0 active",725 "pad hihat-pad b1",726 "pad hihat-pad b2 active",727 "pad hihat-pad b3",728 "pad hihat-pad b4 active",729 "pad hihat-pad b5",730 "pad hihat-pad b6",731 "pad hihat-pad b7",732 "pad clap-pad b0",733 "pad clap-pad b1",734 "pad clap-pad b2",735 "pad clap-pad b3",736 "pad clap-pad b4 active",737 "pad clap-pad b5",738 "pad clap-pad b6",739 "pad clap-pad b7",740 "pad effect-pad b0",741 "pad effect-pad b1",742 "pad effect-pad b2",743 "pad effect-pad b3",744 "pad effect-pad b4",745 "pad effect-pad b5",746 "pad effect-pad b6 active",747 "pad effect-pad b7",748 1,749 1,750 1,751 1,752 1,753 "./sounds/kick1.mp3",754 "./sounds/snare7.mp3",755 "./sounds/hihat6.mp3",756 "./sounds/clap5.mp3",757 "./sounds/effect1.mp3",758 200,759 ];760 const crazyDeveloper = [761 "pad kick-pad b0 active",762 "pad kick-pad b1",763 "pad kick-pad b2",764 "pad kick-pad b3",765 "pad kick-pad b4 active",766 "pad kick-pad b5",767 "pad kick-pad b6",768 "pad kick-pad b7",769 "pad kick-pad b8 active",770 "pad kick-pad b9",771 "pad kick-pad b10",772 "pad kick-pad b11",773 "pad kick-pad b12 active",774 "pad kick-pad b13",775 "pad kick-pad b14",776 "pad kick-pad b15",777 "pad snare-pad b0",778 "pad snare-pad b1",779 "pad snare-pad b2 active",780 "pad snare-pad b3",781 "pad snare-pad b4",782 "pad snare-pad b5",783 "pad snare-pad b6 active",784 "pad snare-pad b7",785 "pad snare-pad b8",786 "pad snare-pad b9",787 "pad snare-pad b10 active",788 "pad snare-pad b11",789 "pad snare-pad b12",790 "pad snare-pad b13",791 "pad snare-pad b14 active",792 "pad snare-pad b15",793 "pad hihat-pad b0",794 "pad hihat-pad b1",795 "pad hihat-pad b2",796 "pad hihat-pad b3 active",797 "pad hihat-pad b4",798 "pad hihat-pad b5",799 "pad hihat-pad b6",800 "pad hihat-pad b7 active",801 "pad hihat-pad b8",802 "pad hihat-pad b9",803 "pad hihat-pad b10",804 "pad hihat-pad b11 active",805 "pad hihat-pad b12",806 "pad hihat-pad b13",807 "pad hihat-pad b14",808 "pad hihat-pad b15",809 "pad clap-pad b0",810 "pad clap-pad b1",811 "pad clap-pad b2",812 "pad clap-pad b3",813 "pad clap-pad b4",814 "pad clap-pad b5 active",815 "pad clap-pad b6",816 "pad clap-pad b7",817 "pad clap-pad b8",818 "pad clap-pad b9 active",819 "pad clap-pad b10",820 "pad clap-pad b11",821 "pad clap-pad b12",822 "pad clap-pad b13",823 "pad clap-pad b14",824 "pad clap-pad b15",825 "pad effect-pad b0",826 "pad effect-pad b1",827 "pad effect-pad b2",828 "pad effect-pad b3",829 "pad effect-pad b4",830 "pad effect-pad b5",831 "pad effect-pad b6",832 "pad effect-pad b7 active",833 "pad effect-pad b8",834 "pad effect-pad b9",835 "pad effect-pad b10",836 "pad effect-pad b11 active",837 "pad effect-pad b12",838 "pad effect-pad b13",839 "pad effect-pad b14",840 "pad effect-pad b15",841 1,842 1,843 1,844 1,845 1,846 "./sounds/kick2.mp3",847 "./sounds/snare6.mp3",848 "./sounds/hihat9.mp3",849 "./sounds/clap5.mp3",850 "./sounds/effect7.mp3",851 200,852 ];853 const mayasWedding = [854 "pad kick-pad b0 active",855 "pad kick-pad b1",856 "pad kick-pad b2",857 "pad kick-pad b3 active",858 "pad kick-pad b4",859 "pad kick-pad b5",860 "pad kick-pad b6 active",861 "pad kick-pad b7",862 "pad snare-pad b0",863 "pad snare-pad b1 active",864 "pad snare-pad b2",865 "pad snare-pad b3",866 "pad snare-pad b4 active",867 "pad snare-pad b5 active",868 "pad snare-pad b6",869 "pad snare-pad b7 active",870 "pad hihat-pad b0",871 "pad hihat-pad b1",872 "pad hihat-pad b2",873 "pad hihat-pad b3",874 "pad hihat-pad b4",875 "pad hihat-pad b5",876 "pad hihat-pad b6",877 "pad hihat-pad b7",878 "pad clap-pad b0",879 "pad clap-pad b1",880 "pad clap-pad b2",881 "pad clap-pad b3",882 "pad clap-pad b4",883 "pad clap-pad b5",884 "pad clap-pad b6",885 "pad clap-pad b7",886 "pad effect-pad b0",887 "pad effect-pad b1",888 "pad effect-pad b2 active",889 "pad effect-pad b3",890 "pad effect-pad b4",891 "pad effect-pad b5",892 "pad effect-pad b6",893 "pad effect-pad b7",894 1,895 1,896 1,897 1,898 1,899 "./sounds/kick4.mp3",900 "./sounds/snare4.mp3",901 "./sounds/hihat1.mp3",902 "./sounds/clap5.mp3",903 "./sounds/effect7.mp3",904 200,905 ];906 const danceOfLovers = [907 "pad kick-pad b0",908 "pad kick-pad b1",909 "pad kick-pad b2 active",910 "pad kick-pad b3 active",911 "pad kick-pad b4",912 "pad kick-pad b5 active",913 "pad kick-pad b6",914 "pad kick-pad b7",915 "pad kick-pad b8",916 "pad kick-pad b9",917 "pad kick-pad b10",918 "pad kick-pad b11",919 "pad kick-pad b12",920 "pad kick-pad b13",921 "pad kick-pad b14",922 "pad kick-pad b15",923 "pad snare-pad b0",924 "pad snare-pad b1 active",925 "pad snare-pad b2",926 "pad snare-pad b3",927 "pad snare-pad b4",928 "pad snare-pad b5",929 "pad snare-pad b6 active",930 "pad snare-pad b7",931 "pad snare-pad b8",932 "pad snare-pad b9",933 "pad snare-pad b10",934 "pad snare-pad b11",935 "pad snare-pad b12",936 "pad snare-pad b13",937 "pad snare-pad b14",938 "pad snare-pad b15",939 "pad hihat-pad b0 active",940 "pad hihat-pad b1",941 "pad hihat-pad b2",942 "pad hihat-pad b3",943 "pad hihat-pad b4",944 "pad hihat-pad b5",945 "pad hihat-pad b6",946 "pad hihat-pad b7",947 "pad hihat-pad b8 active",948 "pad hihat-pad b9",949 "pad hihat-pad b10",950 "pad hihat-pad b11",951 "pad hihat-pad b12",952 "pad hihat-pad b13",953 "pad hihat-pad b14",954 "pad hihat-pad b15 active",955 "pad clap-pad b0",956 "pad clap-pad b1",957 "pad clap-pad b2",958 "pad clap-pad b3 active",959 "pad clap-pad b4",960 "pad clap-pad b5",961 "pad clap-pad b6",962 "pad clap-pad b7",963 "pad clap-pad b8",964 "pad clap-pad b9 active",965 "pad clap-pad b10",966 "pad clap-pad b11 active",967 "pad clap-pad b12",968 "pad clap-pad b13",969 "pad clap-pad b14 active",970 "pad clap-pad b15",971 "pad effect-pad b0",972 "pad effect-pad b1",973 "pad effect-pad b2",974 "pad effect-pad b3",975 "pad effect-pad b4",976 "pad effect-pad b5",977 "pad effect-pad b6",978 "pad effect-pad b7",979 "pad effect-pad b8",980 "pad effect-pad b9",981 "pad effect-pad b10 active",982 "pad effect-pad b11",983 "pad effect-pad b12",984 "pad effect-pad b13 active",985 "pad effect-pad b14",986 "pad effect-pad b15",987 1,988 1,989 1,990 1,991 1,992 "./sounds/kick3.mp3",993 "./sounds/snare5.mp3",994 "./sounds/hihat2.mp3",995 "./sounds/clap5.mp3",996 "./sounds/effect7.mp3",997 300,998 ];999 let pads = document.querySelectorAll(".pad");1000 pads.forEach((pad) => {1001 pad.classList.remove("active");1002 });1003 //one of deffrence between this method and load method1004 //we get clicked name and evaluate by a Switch then we assign the right sample to trackArray and the rest of things are same as load method1005 let trackArray;1006 switch (trackName) {1007 case "we will rock you":1008 trackArray = weWillRockYou;1009 break;1010 case "hip hop 6&8":1011 trackArray = hipHop68;1012 break;1013 case "heart of Atefeh":1014 trackArray = heartOfAtefeh;1015 break;1016 case "try again":1017 trackArray = tryAgain;1018 break;1019 case "crazy developer":1020 trackArray = crazyDeveloper;1021 break;1022 case "maya's wedding":1023 trackArray = mayasWedding;1024 break;1025 case "dance of lovers":1026 trackArray = danceOfLovers;1027 break;1028 }1029 //removing the last element and assign it to a varible1030 //changing the sound by loaded value1031 let tempo = trackArray.pop();1032 let effectSrc = trackArray.pop();1033 this.effectAudio.src = effectSrc;1034 let clapSrc = trackArray.pop();1035 this.clapAudio.src = clapSrc;1036 let hihatSrc = trackArray.pop();1037 this.hihatAudio.src = hihatSrc;1038 let snareSrc = trackArray.pop();1039 this.snareAudio.src = snareSrc;1040 let kickSrc = trackArray.pop();1041 this.kickAudio.src = kickSrc;1042 //changing the volume of the every row by loaded value1043 let kickVolume = trackArray.pop();1044 this.kickAudio.volume = kickVolume;1045 document.querySelector(".kick-volume").value = kickVolume * 100;1046 document.querySelector(".kick-volume").nextElementSibling.innerText =1047 kickVolume * 100;1048 let snareVolume = trackArray.pop();1049 this.snareAudio.volume = snareVolume;1050 document.querySelector(".snare-volume").value = snareVolume * 100;1051 document.querySelector(".snare-volume").nextElementSibling.innerText =1052 snareVolume * 100;1053 let hihatVolume = trackArray.pop();1054 this.hihatAudio.volume = hihatVolume;1055 document.querySelector(".hihat-volume").value = hihatVolume * 100;1056 document.querySelector(".hihat-volume").nextElementSibling.innerText =1057 hihatVolume * 100;1058 let clapVolume = trackArray.pop();1059 this.clapAudio.volume = clapVolume;1060 document.querySelector(".clap-volume").value = clapVolume * 100;1061 document.querySelector(".clap-volume").nextElementSibling.innerText =1062 clapVolume * 100;1063 let effectVolume = trackArray.pop();1064 this.effectAudio.volume = effectVolume;1065 document.querySelector(".effect-volume").value = effectVolume * 100;1066 document.querySelector(".effect-volume").nextElementSibling.innerText =1067 effectVolume * 100;1068 // change what the select input showing to us1069 document.querySelectorAll("select").forEach((select) => {1070 let optionLength = select.options.length;1071 for (let i = 0; i < optionLength; i++) {1072 if (select.options[i].value == kickSrc) {1073 select.options.selectedIndex = i;1074 } else if (select.options[i].value == snareSrc) {1075 select.options.selectedIndex = i;1076 } else if (select.options[i].value == hihatSrc) {1077 select.options.selectedIndex = i;1078 } else if (select.options[i].value == clapSrc) {1079 select.options.selectedIndex = i;1080 } else if (select.options[i].value == effectSrc) {1081 select.options.selectedIndex = i;1082 }1083 }1084 });1085 //we want to make number of pads as number of the loaded track to activate them1086 let loadLength = trackArray.length;1087 let lengthDiffrence = (loadLength - pads.length) / 5;1088 if (lengthDiffrence > 0) {1089 for (let i = lengthDiffrence; i > 0; i--) {1090 this.increasePad();1091 }1092 } else {1093 for (let i = lengthDiffrence; i < 0; i++) {1094 this.decreasePad();1095 }1096 }1097 pads = document.querySelectorAll(".pad");1098 trackArray.forEach((el, index) => {1099 if (el.indexOf("active") >= 0) {1100 pads[index].classList.add("active");1101 }1102 });1103 //change the tempo value by the value of the loaded track1104 this.changeTempo(tempo);1105 this.updateTempo(tempo);1106 this.tempoSlider.value = tempo;1107 modalCloseLoad();1108 //update drum.pads and call the activePad eventLisener again1109 drum.pads = document.querySelectorAll(".pad");1110 drum.pads.forEach((pad) => {1111 pad.addEventListener("click", drum.activePad);1112 pad.addEventListener("animationend", function () {1113 this.style.animation = "";1114 });1115 });1116 }1117}1118//////////////////////////////////////////////1119////////////////////////////////////////1120///////////////////////////////////1121//////////////////////////////1122/////////////////////////1123////////////////////1124//EventListeners1125// making a new object of the class Drum1126const drum = new Drum();1127//increasing the pads by click1128drum.increaseBtn.addEventListener("click", function () {1129 drum.increasePad();1130 //update drum.pads and call the activePad eventLisener again1131 drum.pads = document.querySelectorAll(".pad");1132 drum.pads.forEach((pad) => {1133 pad.addEventListener("click", drum.activePad);1134 pad.addEventListener("animationend", function () {1135 this.style.animation = "";1136 });1137 });1138});1139// just like the increase btn1140drum.decreaseBtn.addEventListener("click", function () {1141 drum.decreasePad();1142});1143//add event listener to every pad that had been clicked and make them active1144drum.pads.forEach((pad) => {1145 pad.addEventListener("click", drum.activePad);1146 pad.addEventListener("animationend", function () {1147 this.style.animation = "";1148 });1149});1150// start the loop by clicking on the play button1151// we use a normal function BCS the if we just use drum.start here, the this keyword will reffer to the button in the ...1152// ... start() method1153drum.playBtn.addEventListener("click", function () {1154 drum.start();1155});1156//changing the sounds when the user change it through the select options1157drum.selectS.forEach((select) => {1158 select.addEventListener("change", function (e) {1159 drum.changeSound(e);1160 });1161});1162//change the volume of every row by range input1163drum.volumeBtnS.forEach((btn) => {1164 btn.addEventListener("input", function (e) {1165 drum.volume(e);1166 });1167 //change the volume number that showed in the span1168 btn.addEventListener("input", function (e) {1169 drum.volumeNum(e);1170 });1171});1172//changing the text of tempo slider in every moment1173drum.tempoSlider.addEventListener("input", function (e) {1174 drum.changeTempo(e.target.value);1175});1176//changing the bpm when the user changed the tempo slider1177drum.tempoSlider.addEventListener("change", function (e) {1178 drum.updateTempo(e.target.value);1179});1180//randomize every track that had been clicked on the randomize btn1181drum.randomizeBtnS.forEach((btn) => {1182 btn.addEventListener("click", function (e) {1183 drum.randomizer(e);1184 });1185});1186//randomize all pads1187drum.randomizeAllBtn.addEventListener("click", function () {1188 drum.randomizeAll();1189});1190// /// © 2021 dev-aly3n ///1191//saving a track1192//at first we pop-up a form to get a name from user1193//then we evaluate the name (for empty ones) and then close the modal then we sed this name to the save() method1194//in the (else if) statement we check if the chosen name is already exist in the LS or not1195drum.saveBtn.addEventListener("click", function (e) {1196 e.preventDefault();1197 const savingError = document.querySelector(".saving-error");1198 const duplicateError = document.querySelector(".duplicate");1199 let trackName = document.querySelector("#saved-name");1200 let duplicate = false;1201 for (let i = 0; i < localStorage.length; i++) {1202 const trackFromLS = localStorage.key(i);1203 if (trackName.value == trackFromLS) {1204 duplicate = true;1205 }1206 }1207 if (trackName.value !== "" && !duplicate) {1208 modalClose();1209 drum.save(trackName.value);1210 trackName.value = "";1211 } else if (duplicate) {1212 duplicateError.style.display = "block";1213 setTimeout(() => {1214 duplicateError.style.display = "none";1215 }, 4000);1216 } else {1217 savingError.style.display = "block";1218 setTimeout(() => {1219 savingError.style.display = "none";1220 }, 4000);1221 }1222});1223//load contents in the load page from localstorage1224{1225 // get the track names that saved in LS and show them in the load page1226 for (let i = 0; i < localStorage.length; i++) {1227 const trackName = localStorage.key(i);1228 const item = document.createElement("div");1229 item.innerText = trackName;1230 item.classList.add("track-load-style");1231 document.querySelector(".your-tracks-content").appendChild(item);1232 }1233 //add click listener to the element and then call the load method if user click1234 const loadContentS = document.querySelectorAll(".track-load-style");1235 loadContentS.forEach((item) => {1236 item.classList.remove("new-save");1237 item.addEventListener("click", function (track) {1238 const loadTrack = track.target.textContent;1239 drum.load(loadTrack);1240 });1241 });1242 // load the samples and add click listener, if user clicked1243 const sampleContentS = document.querySelectorAll(".sample-load-style");1244 sampleContentS.forEach((item) => {1245 item.addEventListener("click", function (track) {1246 // use trim() method to avoid white space in html element1247 const loadTrack = track.target.textContent.trim();1248 drum.loadSamples(loadTrack);1249 });1250 });1251}1252//add a confirm form by modal for clearing the stage1253drum.clearBtn.addEventListener("click", function (e) {1254 e.preventDefault();1255 drum.clearActive();1256 modalConfirmClose();1257});1258// add event listener if user clicked on cancel in clear confirmation1259document.querySelector("#cancel-clear").addEventListener("click", function (e) {1260 e.preventDefault();1261 modalConfirmClose();...

Full Screen

Full Screen

NotableToken.js

Source:NotableToken.js Github

copy

Full Screen

1const { expect } = require("chai");2function tokens(n) {3 return ethers.utils.parseEther(n);4}5const AddressZero = ethers.constants.AddressZero;6const deployWithoutLGE = deployments.createFixture(async ({ deployments, ethers }, options) => {7 await deployments.fixture();8 const [deployer, holder5, holder10, holder20, holder40, treasury, pairAddress, newOwner] = await ethers.getSigners();9 const pad = await ethers.getContract("NotableToken");10 hre.network.provider.request({11 method: "hardhat_impersonateAccount",12 params: [AddressZero]13 });14 const ZeroAddress = await ethers.provider.getSigner(AddressZero);15 return {16 pad,17 deployer,18 holder5,19 holder10,20 holder20,21 holder40,22 pairAddress,23 ZeroAddress24 };25});26const deployWithLGE = deployments.createFixture(async ({ deployments, ethers }, options) => {27 await deployments.fixture();28 const [deployer, holder5, holder10, holder20, holder40, treasury, pairAddress, newOwner] = await ethers.getSigners();29 const pad = await ethers.getContract("NotableToken");30 const durations = [1200];31 const amountsMax = [tokens("10000")];32 await pad.createLGEWhitelist(pairAddress.address, durations, amountsMax);33 return {34 pad,35 deployer,36 holder5,37 pairAddress38 };39});40const deployWithTokenHolders = deployments.createFixture(async ({ deployments, ethers }, options) => {41 await deployments.fixture();42 const [deployer, holder5, holder10, holder20, holder40, treasury, pairAddress, newOwner] = await ethers.getSigners();43 const pad = await ethers.getContract("NotableToken");44 const durations = [1200];45 const amountsMax = [tokens("10000")];46 await pad.createLGEWhitelist(pairAddress.address, durations, amountsMax);47 await pad.transfer(pairAddress.address, tokens("10000"));48 await pad.transfer(holder5.address, tokens("5"));49 await pad.transfer(holder10.address, tokens("10"));50 await pad.transfer(holder20.address, tokens("20"));51 await pad.transfer(holder40.address, tokens("40"));52 hre.network.provider.request({53 method: "hardhat_impersonateAccount",54 params: [AddressZero]55 });56 const ZeroAddress = await ethers.provider.getSigner(AddressZero);57 return {58 pad,59 deployer,60 holder5,61 holder10,62 holder20,63 holder40,64 pairAddress,65 ZeroAddress66 };67});68async function increaseTime(n) {69 await hre.network.provider.request({70 method: "evm_increaseTime",71 params: [n]72 });73 await hre.network.provider.request({74 method: "evm_mine",75 params: []76 });77}78describe("NotableToken", () => {79 describe("Deployment", () => {80 it("name should be Notable", async () => {81 const { pad } = await deployWithLGE();82 expect(await pad.name()).to.be.equal("Notable");83 });84 it("symbol should be NBL", async () => {85 const { pad } = await deployWithLGE();86 expect(await pad.symbol()).to.be.equal("NBL");87 });88 it("deployer should be the owner", async () => {89 const { pad, deployer } = await deployWithLGE();90 expect(await pad.getOwner()).to.be.equal(deployer.address)91 });92 it("should have 18 decimals", async () => {93 const { pad } = await deployWithLGE();94 expect(await pad.decimals()).to.be.equal(18);95 });96 it("total supply should be 100 000 000 tokens", async () => {97 const { pad } = await deployWithLGE();98 expect(await pad.totalSupply()).to.be.equal(tokens("100000000"));99 });100 it("deployer should have the total initial supply", async () => {101 const { pad, deployer } = await deployWithLGE();102 expect(await pad.balanceOf(deployer.address)).to.be.equal(tokens("100000000"));103 });104 });105 describe("allowance", () => {106 it("allowance works as expected", async () => {107 const { pad, deployer, holder5 } = await deployWithTokenHolders();108 expect(await pad.allowance(deployer.address, holder5.address)).to.equal(tokens("0"));109 await pad.approve(holder5.address, tokens("5"));110 expect(await pad.allowance(deployer.address, holder5.address)).to.equal(tokens("5"));111 await pad.increaseAllowance(holder5.address, tokens("3"));112 expect(await pad.allowance(deployer.address, holder5.address)).to.equal(tokens("8"));113 await pad.decreaseAllowance(holder5.address, tokens("4"));114 expect(await pad.allowance(deployer.address, holder5.address)).to.equal(tokens("4"));115 await expect(pad.decreaseAllowance(holder5.address, tokens("5"))).to.be.revertedWith("BEP20: decreased allowance below zero");116 expect(await pad.allowance(deployer.address, holder5.address)).to.equal(tokens("4"));117 });118 });119 describe("approve", () => {120 it("cannot approve the zero address to move your tokens", async () => {121 const { pad, holder5 } = await deployWithTokenHolders();122 await expect(pad.connect(holder5).approve(AddressZero, tokens("5"))).to.be.reverted;123 });124 });125 describe("transferFrom", () => {126 it("allows you transfer an address' tokens to another address", async () => {127 const { pad, holder5, holder10, holder20 } = await deployWithTokenHolders();128 await pad.connect(holder5).approve(holder10.address, tokens("5"));129 await pad.connect(holder10).transferFrom(holder5.address, holder20.address, tokens("5"));130 });131 });132 describe("Ownership", () => {133 it("only the owner can transfer ownership to another address", async () => {134 const { pad, holder5 } = await deployWithLGE();135 await expect(pad.connect(holder5).transferOwnership(holder5.address)).to.be.reverted;136 await pad.transferOwnership(holder5.address);137 expect(await pad.getOwner()).to.be.equal(holder5.address);138 });139 it("owner cannot transfer ownership to the zero address", async () => {140 const { pad } = await deployWithLGE();141 await expect(pad.transferOwnership(AddressZero)).to.be.reverted;142 });143 it("the owner can renounce ownership of the contract", async () => {144 const { pad } = await deployWithLGE();145 await pad.renounceOwnership();146 expect(await pad.getOwner()).to.be.equal(AddressZero);147 });148 });149 describe("Whitelist", () => {150 it("creating the LGE whitelist requires duration and amountsMax of equal length", async () => {151 const { pad, holder5 } = await deployWithoutLGE();152 let durations = [1200];153 let amountsMax = [tokens("10000"), tokens("10")];154 await expect(pad.createLGEWhitelist(AddressZero, durations, amountsMax)).to.be.reverted;155 durations = [];156 amountsMax = [];157 await pad.createLGEWhitelist(AddressZero, durations, amountsMax);158 });159 it("transferring tokens to the pair address begins the LGE", async () => {160 const { pad, holder5, pairAddress } = await deployWithLGE();161 await pad.transfer(pairAddress.address, tokens("10000"));162 await expect(pad.connect(pairAddress).transfer(holder5.address, tokens("10"))).to.be.reverted;163 });164 it("transferring tokens reverts if you're not on the whitelist", async () => {165 const { pad, holder5, pairAddress } = await deployWithTokenHolders();166 await expect(pad.connect(pairAddress).transfer(holder5.address, tokens("10"))).to.be.reverted;167 });168 it("whitelisters cannot buy more than the specified amount max", async () => {169 const { pad, holder5, holder10, holder20, holder40, pairAddress, deployer } = await deployWithTokenHolders();170 const addresses = [pairAddress.address, deployer.address, holder5.address, holder10.address, holder20.address, holder40.address];171 await pad.modifyLGEWhitelist(0, 1200, tokens("5000"), addresses, true);172 await expect(pad.connect(pairAddress).transfer(holder5.address, tokens("10001"))).to.be.reverted;173 });174 it("whitelisted addresses can buy up to the specified max", async () => {175 const { pad, holder5, holder10, holder20, holder40, pairAddress, deployer } = await deployWithTokenHolders();176 const addresses = [pairAddress.address, deployer.address, holder5.address, holder10.address, holder20.address, holder40.address];177 await pad.modifyLGEWhitelist(0, 1200, tokens("5000"), addresses, true);178 await pad.connect(pairAddress).transfer(holder5.address, tokens("5000"));179 await expect(pad.connect(pairAddress).transfer(holder5.address, tokens("1"))).to.be.reverted;180 });181 it("whitelist admin can add whitelist addresses using modifyLGEWhitelist", async () => {182 const { pad, holder5, holder10, holder20, holder40, pairAddress, deployer } = await deployWithTokenHolders();183 const addresses = [pairAddress.address, deployer.address, holder5.address, holder10.address, holder20.address, holder40.address];184 await expect(pad.connect(pairAddress).transfer(holder5.address, tokens("10"))).to.be.reverted;185 await pad.modifyLGEWhitelist(0, 1200, tokens("5000"), addresses, true);186 await pad.connect(pairAddress).transfer(holder5.address, tokens("10"));187 expect(await pad.balanceOf(holder5.address)).to.be.equal(tokens("15"));188 });189 it("whitelist admin can modify the whitelist duration", async () => {190 const { pad, holder5, holder10, holder20, holder40, pairAddress, deployer } = await deployWithTokenHolders();191 const addresses = [pairAddress.address, deployer.address, holder5.address, holder10.address, holder20.address, holder40.address];192 await pad.modifyLGEWhitelist(0, 1201, tokens("5000"), addresses, true);193 });194 it("whitelist admin can modify the max tokens that can be bought during the whitelist", async () => {195 const { pad, holder5, holder10, holder20, holder40, pairAddress, deployer } = await deployWithTokenHolders();196 const addresses = [pairAddress.address, deployer.address, holder5.address, holder10.address, holder20.address, holder40.address];197 await pad.modifyLGEWhitelist(0, 1200, tokens("5000"), addresses, true);198 });199 it("whitelist admin can call the modifyLGEWhitelist and not change anything", async () => {200 const { pad, holder5, holder10, holder20, holder40, pairAddress, deployer } = await deployWithTokenHolders();201 const addresses = [pairAddress.address, deployer.address, holder5.address, holder10.address, holder20.address, holder40.address];202 await pad.modifyLGEWhitelist(0, 1200, tokens("10000"), addresses, true);203 });204 it("when the whitelist round is over, getLGEWhitelistRound returns 0", async () => {205 const { pad } = await deployWithTokenHolders();206 let data = await pad.getLGEWhitelistRound();207 expect(data[0]).to.be.equal(1);208 increaseTime(1500);209 data = await pad.getLGEWhitelistRound();210 expect(data[0]).to.be.equal(0);211 });212 it("whitelist admin cannot modify a whitelist that doesn't exist", async () => {213 const { pad, holder5, holder10, holder20, holder40, pairAddress, deployer } = await deployWithTokenHolders();214 const addresses = [pairAddress.address, deployer.address, holder5.address, holder10.address, holder20.address, holder40.address];215 await expect(pad.modifyLGEWhitelist(1, 1201, tokens("5000"), addresses, true)).to.be.reverted;216 });217 it("whitelist admin cannot set amountMax less than zero", async () => {218 const { pad, holder5, holder10, holder20, holder40, pairAddress, deployer } = await deployWithTokenHolders();219 const addresses = [pairAddress.address, deployer.address, holder5.address, holder10.address, holder20.address, holder40.address];220 // SVM function call fails before require statement reverts221 await expect(pad.modifyLGEWhitelist(0, 1200, -1, addresses, true)).to.be.reverted;222 });223 it("whitelist admin can renounce their whitelister permissions", async () => {224 const { pad } = await deployWithoutLGE();225 await pad.renounceWhitelister();226 expect(await pad._whitelister()).to.be.equal(AddressZero);227 });228 it("whitelist admin can tranfer their whitelisting permission to another address", async () => {229 const { pad, holder5 } = await deployWithoutLGE();230 await expect(pad.connect(holder5).transferWhitelister(holder5.address)).to.be.reverted;231 await pad.transferWhitelister(holder5.address);232 expect(await pad._whitelister()).to.be.equal(holder5.address);233 });234 it("whitelist admin cannot transfer their whitelisting permission to the zero address", async () => {235 const { pad, deployer } = await deployWithoutLGE();236 await expect(pad.transferWhitelister(AddressZero)).to.be.reverted;237 expect(await pad._whitelister()).to.be.equal(deployer.address);238 });239 });...

Full Screen

Full Screen

mainFunction.js

Source:mainFunction.js Github

copy

Full Screen

1$(function() {2 var taWidth = $("#textArea").width();3 var taHeight = $("#textArea").height();4 var screenObj = $("#screen").offset();5 var screenLeft = screenObj.left;6 var screenTop = screenObj.top;7 var screenWidth = ($("#screen").width()+15); // border 값 등 고려8 var screenHeight = ($("#screen").height()+15);9 10 var cmHeight = $("#rClick_ContextMenu").height();11 var cmWidth = $("#rClick_ContextMenu").width(); // 양 쪽 border 및 margin12 13 var widthValue;14 var heightValue;15 16 $(document).on({17 "mousedown" : function(e) {18 var eTarget = e.target;19 if((eTarget.id=="topBar") || (eTarget.id=="textArea")) {20 $("#"+eTarget.parentNode.id).css({21 "z-index" : 122 });23 $("#"+eTarget.parentNode.id).siblings().css({24 "z-index" : "auto"25 })26 } else if(eTarget.id=="resizingCursor"){27 console.log(eTarget.parentNode.id);28 $("#"+eTarget.parentNode.id).parent().css({29 "z-index" : 130 });31 $("#"+eTarget.parentNode.id).parent().siblings().css({32 "z-index" : "auto"33 })34 }35 },36 "contextmenu" : function(e) {37 var eTarget = e.target;38 console.log(eTarget.id);39 if(eTarget.id=="textArea") {40 e.preventDefault();41 toggleOnOff(1, eTarget.parentNode.id);42 getXY(e);43 }44 }45 })46 47 // topBar dragging48 $(document).on("mousedown", "#topBar", function() {49 // 버튼 클릭시 요소의 left값50 var memoPadObj = $(this).parent();51 $(this).parent().css({52 "z-index" : 153 });54 $(this).parent().siblings().css({55 "z-index" : "auto"56 });57 var temp_OffsetLeft = memoPadObj.offset().left;58 var temp_OffsetTop = memoPadObj.offset().top;59 // mousedown 때 X 좌표60 var firstClick_X = event.clientX;61 var firstClick_Y = event.clientY;62 var draggingX; // 드래그이벤트 발생시 X 좌표63 var draggingY; // 드래그이벤트 발생시 Y 좌표64 $("#screen").on({65 "mousemove" : function() {66 draggingX = event.clientX;67 draggingY = event.clientY;68 // memopad의 기준 요소와 이벤트 발생 위치와의 거리69 var width_Left2point = (firstClick_X - temp_OffsetLeft);70 var height_top2point = (firstClick_Y - temp_OffsetTop);71 // screen 내부에서 드래깅 완료 위치72 var offsetLeft = (11 + (draggingX - width_Left2point));73 var offsetTop = (11 + (draggingY - height_top2point));74 // screen 외부로 나가지 않게 하기 위한 조건문(각 부분 screen값 + border(3px))75 if (offsetLeft < 1) {76 offsetLeft = (1 + (screenLeft + 3));77 }78 if (offsetTop < 1) {79 offsetTop = (1 + (screenTop + 3));80 }81 82 var positionLeft = memoPadObj.position().left;83 var memoPadWidth = memoPadObj.width();84 var maxLeft = (screenWidth-memoPadWidth);85 if((positionLeft+memoPadWidth) > screenWidth) {86 if(positionLeft > maxLeft) {87 offsetLeft=(screenWidth-memoPadWidth);88 }89 }90 91 var positionTop = memoPadObj.position().top;92 var memoPadHeight = memoPadObj.height();93 var maxTop = (screenHeight-memoPadHeight);94 95 if((positionTop+memoPadHeight) > screenHeight) {96 if(positionTop > maxTop) {97 offsetTop=(screenHeight-memoPadHeight);98 }99 }100 101 memoPadObj.offset({102 "left" : offsetLeft,103 "top" : offsetTop104 });105 },106 "mouseup" : function() {107 $("#screen").off();108 },109 "mouseleave" : function() {110 $("#screen").off();111 }112 });113 });114 // Resizing115 $(document).on("mousedown", "#resizingCursor", function() {116 var memoPadObj = $(this).parent();117 var padId = memoPadObj[0].id;118 console.log(memoPadObj);119 var positionLeft = memoPadObj.position().left;120 var positionTop = memoPadObj.position().top;121 $("#screen").on({122 "mousemove" : function() {123 widthValue = (event.clientX - positionLeft); // position.left 값을 뺴줌124 heightValue = (event.clientY - positionTop); // position.top 값을 빼줌125 // 최대 크기 width126 if (widthValue >= $("#screen").width()) {127 widthValue = $("#screen").width();128 }129 // 최대 크기 height130 if (heightValue >= $("#screen").height()) {131 heightValue = $("#screen").height();132 }133 // 최소 크기 width134 if (widthValue < 250) {135 widthValue = 250;136 }137 // 최소 크기 height138 if (heightValue < $("#"+padId).children("#topBar").height() + 15) {139 heightValue = $("#"+padId).children("#topBar").height() + 15;140 }141 $("#"+padId).children("#textArea").css({142 "width" : widthValue,143 "height" : (heightValue - $("#"+padId).children("#topBar").height() - 1)144 });145 $("#"+padId).css({146 "width" : widthValue,147 "height" : heightValue148 });149 $("#"+padId).children("#topBar").css({150 "width" : widthValue151 });152 },153 "mouseup" : function() {154 $("#screen").off();155 }156 }).on("mouseleave", function() {157 $("#screen").off();158 })159 });160 // memoPad의 중복을 확인 하고 오름 차순으로 첫번째 비어있는 숫자를 넣음161 function checkNumber() {162 var memoPadArr = $("#screen").children();163 var tempArr = [];164 if(memoPadArr.length == 0) {165 return "memoPad0"166 } else {167 // memoPad 문자열 제거168 for(var i=0; i<memoPadArr.length; i++) {169 tempArr.push(parseInt((memoPadArr[i].id).replace(/[^0-9]/gi, "")));170 }171 tempArr.sort();172 if(tempArr.length > 9) {173 alert("memoPad는 최대 10개 까지만 생성 할 수 있습니다");174 } else {175 for(var i=0; i<=tempArr.length; i++) {176 if(tempArr[i]!=i) {177 return "memoPad"+i;178 }179 }180 }181 }182 }183 184 185 /* addBtn (+) 버튼 */186 $(document).on("mousedown", "#addBtn", function(e) {187 e.stopPropagation();188 });189 $(document).on("click", "#addBtn", function() {190 var padName = checkNumber();191 checkCreatePad($(this).parent(), padName);192 });193 194 $(document).on("click", "#out_ddBtn", function() {195 var padName = checkNumber();196 createPad(padName);197 });198 199 function checkCreatePad(obj, padName) {200 if(padName==undefined){201 return;202 } else {203 $("#screen").append("<div id='"+padName+"' class='memoPad'><div id='topBar'><div id='addBtn' class='leftBtns' ></div><div id='deleteBtn' class='rightBtns'></div></div><div id='textArea' contenteditable='true'>&nbsp</div>;<div id='resizingCursor' class='resizingCursor' contenteditable='false'> </div></div>");204 var objLeft, objTop;205 206 if(obj.offset().left>628) {207 objLeft = 660;208 } else {209 objLeft = obj.offset().left+30;210 }211 212 if(obj.offset().top>363) {213 objTop = 394214 } else {215 objTop = obj.offset().top+30;216 }217 $("#"+padName).offset({218 "left" : objLeft,219 "top": objTop220 });221 $("#"+padName).css({222 "z-index" : 1223 })224 $("#"+padName).siblings().css({225 "z-index" : "auto"226 });227 228 }229 }230 231 // localStorage에서 불러올때 memoPad 생성메소드232 function createPad(padName) {233 if(padName==undefined) {234 return;235 } else {236 $("#screen").append("<div id='"+padName+"' class='memoPad'><div id='topBar'><div id='addBtn' class='leftBtns' ></div><div id='deleteBtn' class='rightBtns'></div></div><div id='textArea' contenteditable='true'>&nbsp;</div><div id='resizingCursor' class='resizingCursor' contenteditable='false'> </div></div>");237 }238 };239 /* contextMenuBtn 톱니바퀴 버튼 */240 $(document).on("mousedown", "#contextMenuBtn", function(e) {241 e.stopPropagation();242 });243 $(document).on("mousedown", "#deleteBtn", function(e) {244 e.stopPropagation();245 });246 247 /* deleteBtn 삭제 버튼 */248 $(document).on("click", "#deleteBtn", function() {249 var memoPadObj = $(this).parent().parent();250 var padId = memoPadObj[0].id;251 var pl = $("#"+padId).position().left;252 var pt = $("#"+padId).position().top;253 var mh_rh = $("#"+padId).height()-$("#rClick_ContextMenu").height();254 var ml_rl = $("#"+padId).width()-$("#rClick_ContextMenu").width();255 toggleOnOff(1, padId);256 $("#rClick_ContextMenu").css({257 "top" : ((pt+(mh_rh)/2)-7), // 7px는 border값 때문258 "left" : ((pl+(ml_rl)/2)-7)259 });260 });261 262 /* 삭제 메뉴 생성 */263 var delPadName;264 function toggleOnOff(num, padName) {265 if(num==0) {266 $("#rClick_ContextMenu").removeClass("active");267 } else if(num==1) {268 $("#rClick_ContextMenu").addClass("active");269 $("#rClick_ContextMenu").css({270 "z-index" : 2271 });272 delPadName = padName;273 }274 }275 276 function getXY(e) {277 var cmTop = e.clientY;278 var cmLeft = e.clientX;279 280 // screenMargin 16px & cm 16px281 if(((cmLeft)+(cmWidth-16))>screenWidth-32) {282 cmLeft = screenWidth-(cmWidth+16);283 }284 285 if((cmTop)+(cmHeight-16)>screenHeight-32) {286 cmTop = screenHeight-(cmHeight+16);287 }288 289 $("#rClick_ContextMenu").css({290 "top" : cmTop,291 "left" : cmLeft292 });293 }294 295 $("#deleteBtnCM").on("mousedown", function(e) {296 $("#"+delPadName).remove();297 toggleOnOff(0);298 e.stopPropagation();299 });300 301 $("#cancelBtnCM").on("click", function(e) {302 toggleOnOff(0);303 e.stopPropagation();304 });305 306 307 document.addEventListener("mousedown", function(e) {308 toggleOnOff(0);309 });310 311 // 페이지에서 새로고침 및 종료할때 발생하는 이벤트312 $(window).on('beforeunload', function() {313 return saveInfo();314 });315 316 // localstorage 경로 : C:\Users\chaey\AppData\Local\Google\Chrome\User Data\Default\Local Storage317 function saveInfo() {318 var padObj = $("#screen").children();319 320 var contentObj = {};321 var contentArr =[];322 323 for(var i=0; i<padObj.length; i++) {324 contentObj = {};325 contentObj.id = padObj[i].id;326 contentObj.clientWidth = padObj[i].clientWidth;327 contentObj.clientHeight = padObj[i].clientHeight;328 contentObj.offsetLeft = padObj[i].offsetLeft;329 contentObj.offsetTop = padObj[i].offsetTop;330 contentObj.innerText = padObj[i].innerText;331 contentArr.push(contentObj);332 }333 334 localStorage.setItem("savingInfo", JSON.stringify(contentArr));335 }336 337 (function launchingPage() {338 var parsingObj = localStorage.getItem("savingInfo");339 var pd = JSON.parse(parsingObj);340 for(var i=0; i<pd.length; i++) {341 createPad(pd[i].id);342 $("#"+pd[i].id).css({343 "width" : pd[i].clientWidth,344 "height" : pd[i].clientHeight,345 });346 $("#"+pd[i].id).offset({347 "top" : pd[i].offsetTop,348 "left" : pd[i].offsetLeft349 });350 $("#"+pd[i].id).children("#textArea").text(pd[i].innerText);351 $("#"+pd[i].id).children("#textArea").css({352 height : pd[i].clientHeight-31353 });354 //$("#"+pd[i].id).children("#textArea").append("<div id='resizingCursor1' class='resizingCursor' contenteditable='false'> </div>");355 }356 } ());357 358 $("#removeAllBtn").on("click", function(){359 $("#screen").children().remove();360 console.log("memoPad 전체 삭제");361 });362 363 /* F5 , ctrl + R 입력시 refresh364 jquery keydown event(using Key Code List) */365 /* $(window).on("keydown", function(e) {366 if(e.which==116) {367 console.log("F5 입력");368 }369 if(e.ctrlKey && e.which==82) {370 console.log("ctrl + R");371 }372 });*/373 /* // addButton 374 $("#addTest").on("click", function() {375 var addDiv = document.createElement("div");376 addDiv.innerHTML = document.getElementById("memoPad").innerHTML;377 document.getElementById("screen").appendChild(addDiv);378 });*/...

Full Screen

Full Screen

string-pad.js

Source:string-pad.js Github

copy

Full Screen

1// Copyright 2018 the V8 project authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4class MyError {};5const throwing = {toString() {throw new MyError}};6const empties = ['', {toString() {return ''}}];7{8 const s = '';9 assertThrows(_ => s.padStart(Symbol(), throwing), TypeError);10 assertEquals(s, s.padStart(NaN, throwing));11 assertEquals(s, s.padStart(-Infinity, throwing));12 assertEquals(s, s.padStart(-9, throwing));13 assertEquals(s, s.padStart(-1, throwing));14 assertEquals(s, s.padStart(-0, throwing));15 assertEquals(s, s.padStart(0, throwing));16 assertThrows(_ => s.padStart(3, throwing), MyError);17 assertThrows(_ => s.padStart(9, throwing), MyError);18 assertThrows(_ => s.padStart(2**31-1, throwing), MyError);19 assertThrows(_ => s.padStart(2**31, throwing), MyError);20 assertThrows(_ => s.padStart(2**32-1, throwing), MyError);21 assertThrows(_ => s.padStart(2**32, throwing), MyError);22 assertThrows(_ => s.padStart(2**53-1, throwing), MyError);23 assertThrows(_ => s.padStart(2**53, throwing), MyError);24 assertThrows(_ => s.padStart(Infinity, throwing), MyError);25 assertThrows(_ => s.padEnd(Symbol(), throwing), TypeError);26 assertEquals(s, s.padEnd(NaN, throwing));27 assertEquals(s, s.padEnd(-Infinity, throwing));28 assertEquals(s, s.padEnd(-9, throwing));29 assertEquals(s, s.padEnd(-1, throwing));30 assertEquals(s, s.padEnd(-0, throwing));31 assertEquals(s, s.padEnd(0, throwing));32 assertThrows(_ => s.padEnd(3, throwing), MyError);33 assertThrows(_ => s.padEnd(9, throwing), MyError);34 assertThrows(_ => s.padEnd(2**31-1, throwing), MyError);35 assertThrows(_ => s.padEnd(2**31, throwing), MyError);36 assertThrows(_ => s.padEnd(2**32-1, throwing), MyError);37 assertThrows(_ => s.padEnd(2**32, throwing), MyError);38 assertThrows(_ => s.padEnd(2**53-1, throwing), MyError);39 assertThrows(_ => s.padEnd(2**53, throwing), MyError);40 assertThrows(_ => s.padEnd(Infinity, throwing), MyError);41 for (const empty of empties) {42 assertThrows(_ => s.padStart(Symbol(), empty), TypeError);43 assertEquals(s, s.padStart(NaN, empty));44 assertEquals(s, s.padStart(-Infinity, empty));45 assertEquals(s, s.padStart(-9, empty));46 assertEquals(s, s.padStart(-1, empty));47 assertEquals(s, s.padStart(-0, empty));48 assertEquals(s, s.padStart(0, empty));49 assertEquals(s, s.padStart(3, empty));50 assertEquals(s, s.padStart(9, empty));51 assertEquals(s, s.padStart(2**31-1, empty));52 assertEquals(s, s.padStart(2**31, empty));53 assertEquals(s, s.padStart(2**32-1, empty));54 assertEquals(s, s.padStart(2**32, empty));55 assertEquals(s, s.padStart(2**53-1, empty));56 assertEquals(s, s.padStart(2**53, empty));57 assertEquals(s, s.padStart(Infinity, empty));58 assertThrows(_ => s.padEnd(Symbol(), empty), TypeError);59 assertEquals(s, s.padEnd(NaN, empty));60 assertEquals(s, s.padEnd(-Infinity, empty));61 assertEquals(s, s.padEnd(-9, empty));62 assertEquals(s, s.padEnd(-1, empty));63 assertEquals(s, s.padEnd(-0, empty));64 assertEquals(s, s.padEnd(0, empty));65 assertEquals(s, s.padEnd(3, empty));66 assertEquals(s, s.padEnd(9, empty));67 assertEquals(s, s.padEnd(2**31-1, empty));68 assertEquals(s, s.padEnd(2**31, empty));69 assertEquals(s, s.padEnd(2**32-1, empty));70 assertEquals(s, s.padEnd(2**32, empty));71 assertEquals(s, s.padEnd(2**53-1, empty));72 assertEquals(s, s.padEnd(2**53, empty));73 assertEquals(s, s.padEnd(Infinity, empty));74 }75}76{77 const s = 'hello';78 assertThrows(_ => s.padStart(Symbol(), throwing), TypeError);79 assertEquals(s, s.padStart(NaN, throwing));80 assertEquals(s, s.padStart(-Infinity, throwing));81 assertEquals(s, s.padStart(-9, throwing));82 assertEquals(s, s.padStart(-1, throwing));83 assertEquals(s, s.padStart(-0, throwing));84 assertEquals(s, s.padStart(0, throwing));85 assertEquals(s, s.padStart(3, throwing));86 assertThrows(_ => s.padStart(9, throwing), MyError);87 assertThrows(_ => s.padStart(2**31-1, throwing), MyError);88 assertThrows(_ => s.padStart(2**31, throwing), MyError);89 assertThrows(_ => s.padStart(2**32-1, throwing), MyError);90 assertThrows(_ => s.padStart(2**32, throwing), MyError);91 assertThrows(_ => s.padStart(2**53-1, throwing), MyError);92 assertThrows(_ => s.padStart(2**53, throwing), MyError);93 assertThrows(_ => s.padStart(Infinity, throwing), MyError);94 assertThrows(_ => s.padEnd(Symbol(), throwing), TypeError);95 assertEquals(s, s.padEnd(NaN, throwing));96 assertEquals(s, s.padEnd(-Infinity, throwing));97 assertEquals(s, s.padEnd(-9, throwing));98 assertEquals(s, s.padEnd(-1, throwing));99 assertEquals(s, s.padEnd(-0, throwing));100 assertEquals(s, s.padEnd(0, throwing));101 assertEquals(s, s.padEnd(3, throwing));102 assertThrows(_ => s.padEnd(9, throwing), MyError);103 assertThrows(_ => s.padEnd(2**31-1, throwing), MyError);104 assertThrows(_ => s.padEnd(2**31, throwing), MyError);105 assertThrows(_ => s.padEnd(2**32-1, throwing), MyError);106 assertThrows(_ => s.padEnd(2**32, throwing), MyError);107 assertThrows(_ => s.padEnd(2**53-1, throwing), MyError);108 assertThrows(_ => s.padEnd(2**53, throwing), MyError);109 assertThrows(_ => s.padEnd(Infinity, throwing), MyError);110 for (const empty of empties) {111 assertThrows(_ => s.padStart(Symbol(), empty), TypeError);112 assertEquals(s, s.padStart(NaN, empty));113 assertEquals(s, s.padStart(-Infinity, empty));114 assertEquals(s, s.padStart(-9, empty));115 assertEquals(s, s.padStart(-1, empty));116 assertEquals(s, s.padStart(-0, empty));117 assertEquals(s, s.padStart(0, empty));118 assertEquals(s, s.padStart(3, empty));119 assertEquals(s, s.padStart(9, empty));120 assertEquals(s, s.padStart(2**31-1, empty));121 assertEquals(s, s.padStart(2**31, empty));122 assertEquals(s, s.padStart(2**32-1, empty));123 assertEquals(s, s.padStart(2**32, empty));124 assertEquals(s, s.padStart(2**53-1, empty));125 assertEquals(s, s.padStart(2**53, empty));126 assertEquals(s, s.padStart(Infinity, empty));127 assertThrows(_ => s.padEnd(Symbol(), empty), TypeError);128 assertEquals(s, s.padEnd(NaN, empty));129 assertEquals(s, s.padEnd(-Infinity, empty));130 assertEquals(s, s.padEnd(-9, empty));131 assertEquals(s, s.padEnd(-1, empty));132 assertEquals(s, s.padEnd(-0, empty));133 assertEquals(s, s.padEnd(0, empty));134 assertEquals(s, s.padEnd(3, empty));135 assertEquals(s, s.padEnd(9, empty));136 assertEquals(s, s.padEnd(2**31-1, empty));137 assertEquals(s, s.padEnd(2**31, empty));138 assertEquals(s, s.padEnd(2**32-1, empty));139 assertEquals(s, s.padEnd(2**32, empty));140 assertEquals(s, s.padEnd(2**53-1, empty));141 assertEquals(s, s.padEnd(2**53, empty));142 assertEquals(s, s.padEnd(Infinity, empty));143 }...

Full Screen

Full Screen

stringpad.js

Source:stringpad.js Github

copy

Full Screen

1//-------------------------------------------------------------------------------------------------------2// Copyright (C) Microsoft. All rights reserved.3// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.4//-------------------------------------------------------------------------------------------------------56WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js");78var tests = [9 {10 name: "String.prototype.padStart/padEnd should exist and constructed properly",11 body: function () {12 assert.isTrue(String.prototype.hasOwnProperty('padStart'), "String.prototype should have a padStart method");13 assert.isTrue(String.prototype.hasOwnProperty('padEnd'), "String.prototype should have a padEnd method");14 assert.areEqual(1, String.prototype.padStart.length, "padStart method takes one argument");15 assert.areEqual(1, String.prototype.padEnd.length, "padEnd method takes one argument");16 assert.areEqual("padStart", String.prototype.padStart.name, "padStart.name is 'padStart'");17 assert.areEqual("padEnd", String.prototype.padEnd.name, "padEnd.name is 'padEnd'");18 19 var descriptor = Object.getOwnPropertyDescriptor(String.prototype, 'padStart');20 assert.isTrue(descriptor.writable, "writable(padStart) must be true");21 assert.isFalse(descriptor.enumerable, "enumerable(padStart) must be false");22 assert.isTrue(descriptor.configurable, "configurable(padStart) must be true");23 24 descriptor = Object.getOwnPropertyDescriptor(String.prototype, 'padEnd');25 assert.isTrue(descriptor.writable, "writable(padEnd) must be true");26 assert.isFalse(descriptor.enumerable, "enumerable(padEnd) must be false");27 assert.isTrue(descriptor.configurable, "configurable(padEnd) must be true");28 }29 },30 {31 name: "String.prototype.padStart functionality",32 body: function () {33 assert.areEqual('foo'.padStart(), 'foo', "No arguments to padStart will not affect string");34 assert.areEqual('foo'.padStart(1), 'foo', "No padding added if maxLength (first argument) is less than the length of actual string");35 assert.areEqual('foo'.padStart(-1), 'foo', "No padding added if maxLength (first argument), negative, is less than the length of actual string");36 assert.areEqual('foo'.padStart(3), 'foo', "No padding added if maxLength (first argument) is equal to the length of actual string");37 assert.areEqual('foo'.padStart(4), ' foo', "String with one ' ' (SPACE) as pad is returned");38 assert.areEqual('foo'.padStart(10), ' foo', "String of length 10, with spaces filled as padding, is returned");39 assert.areEqual('foo'.padStart(10, ''), 'foo', "No padding added if the fillString is empty string");40 assert.areEqual('foo'.padStart(10, undefined), ' foo', "'undefined' fillString - string of length 10, with spaces filled as padding, is returned");41 assert.areEqual('foo'.padStart(10, ' '), ' foo', "fillString as one space - string of length 10, with spaces filled as padding, is returned");42 assert.areEqual('foo'.padStart(4, '123'), '1foo', "String of length 4, with only one character from fillString added as a padding, is returned");43 assert.areEqual('foo'.padStart(10, '123'), '1231231foo', "String of length 10, with repeatedly adding characters from fillString to create enough padding, is returned");44 }45 },46 {47 name: "String.prototype.padEnd functionality",48 body: function () {49 assert.areEqual('foo'.padEnd(), 'foo', "No arguments to padEnd will not affect string");50 assert.areEqual('foo'.padEnd(1), 'foo', "No padding added if maxLength (first argument) is less than the length of actual string");51 assert.areEqual('foo'.padEnd(-1), 'foo', "No padding added if maxLength (first argument), negative, is less than the length of actual string");52 assert.areEqual('foo'.padEnd(3), 'foo', "No padding added if maxLength (first argument) is equal to the length of actual string");53 assert.areEqual('foo'.padEnd(4), 'foo ', "String with one ' ' (SPACE) as pad is returned");54 assert.areEqual('foo'.padEnd(10), 'foo ', "String of length 10, with spaces filled as padding, is returned");55 assert.areEqual('foo'.padEnd(10, ''), 'foo', "No padding added if the fillString is empty string");56 assert.areEqual('foo'.padEnd(10, undefined), 'foo ', "'undefined' fillString - string of length 10, with spaces filled as padding, is returned");57 assert.areEqual('foo'.padEnd(10, ' '), 'foo ', "fillString as one space - string of length 10, with spaces filled as padding, is returned");58 assert.areEqual('foo'.padEnd(4, '123'), 'foo1', "String of length 4, with only one character from fillString added as a padding, is returned");59 assert.areEqual('foo'.padEnd(10, '123'), 'foo1231231', "String of length 10, with repeatedly adding characters from fillString to create enough padding, is returned");60 }61 },62 {63 name: "String.prototype.padStart OOM scenario",64 body: function () {65 try {66 'foo'.padStart(2147483647);67 }68 catch(e) {69 assert.areEqual(e.message, "Out of memory", "validating out of memory for maxLength >= int_max"); 70 }71 }72 }73];74 ...

Full Screen

Full Screen

harmony-string-pad-start.js

Source:harmony-string-pad-start.js Github

copy

Full Screen

1// Copyright 2016 the V8 project authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4(function TestMeta() {5 assertEquals(1, String.prototype.padStart.length);6 assertEquals("function", typeof String.prototype.padStart);7 assertEquals(Object.getPrototypeOf(Function),8 Object.getPrototypeOf(String.prototype.padStart));9 assertEquals("padStart", String.prototype.padStart.name);10 var desc = Object.getOwnPropertyDescriptor(String.prototype, "padStart");11 assertFalse(desc.enumerable);12 assertTrue(desc.configurable);13 assertTrue(desc.writable);14 assertEquals(undefined, desc.get);15 assertEquals(undefined, desc.set);16 assertThrows(() => new Function(`${String.prototype.padStart}`), SyntaxError);17})();18(function TestRequireObjectCoercible() {19 var padStart = String.prototype.padStart;20 assertThrows(() => padStart.call(null, 4, "test"), TypeError);21 assertThrows(() => padStart.call(undefined, 4, "test"), TypeError);22 assertEquals(" 123", padStart.call({23 __proto__: null,24 valueOf() { return 123; }25 }, 6, " "));26 var proxy = new Proxy({}, {27 get(t, name) {28 if (name === Symbol.toPrimitive || name === "toString") return;29 if (name === "valueOf") return () => 6.7;30 assertUnreachable();31 }32 });33 assertEquals(" 6.7", padStart.call(proxy, 6, " "));34 proxy = new Proxy({}, {35 get(t, name) {36 if (name === Symbol.toPrimitive || name === "valueOf") return;37 if (name === "toString") return () => 6.7;38 assertUnreachable();39 }40 });41 assertEquals(" 6.7", padStart.call(proxy, 6, " "));42})();43(function TestToLength() {44 assertThrows(() => "123".padStart(Symbol("16")), TypeError);45 assertEquals("123", "123".padStart(-1));46 assertEquals("123", "123".padStart({ toString() { return -1; } }));47 assertEquals("123", "123".padStart(-0));48 assertEquals("123", "123".padStart({ toString() { return -0; } }));49 assertEquals("123", "123".padStart(+0));50 assertEquals("123", "123".padStart({ toString() { return +0; } }));51 assertEquals("123", "123".padStart(NaN));52 assertEquals("123", "123".padStart({ toString() { return NaN; } }));53})();54(function TestFillerToString() {55 assertEquals(" .", ".".padStart(10));56 assertEquals(" .", ".".padStart(10, undefined));57 assertEquals("nullnulln.", ".".padStart(10, null));58 assertEquals("XXXXXXXXX.", ".".padStart(10, { toString() { return "X"; } }));59 assertEquals(60 "111111111.",61 ".".padStart(10, { toString: undefined, valueOf() { return 1; } }));62})();63(function TestFillerEmptyString() {64 assertEquals(".", ".".padStart(10, ""));65 assertEquals(".", ".".padStart(10, { toString() { return ""; } }));66 assertEquals(67 ".", ".".padStart(10, { toString: undefined, valueOf() { return ""; } }));68})();69(function TestFillerRepetition() {70 for (var i = 2000; i > 0; --i) {71 var expected = "xoxo".repeat(i / 4).slice(0, i - 3) + "123";72 var actual = "123".padStart(i, "xoxo");73 assertEquals(expected, actual);74 assertEquals(i > "123".length ? i : 3, actual.length);75 }76})();77(function TestTruncation() {78 assertEquals("ba", "a".padStart(2, "bc"));...

Full Screen

Full Screen

harmony-string-pad-end.js

Source:harmony-string-pad-end.js Github

copy

Full Screen

1// Copyright 2016 the V8 project authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4(function TestMeta() {5 assertEquals(1, String.prototype.padEnd.length);6 assertEquals("function", typeof String.prototype.padEnd);7 assertEquals(Object.getPrototypeOf(Function),8 Object.getPrototypeOf(String.prototype.padEnd));9 assertEquals("padEnd", String.prototype.padEnd.name);10 var desc = Object.getOwnPropertyDescriptor(String.prototype, "padEnd");11 assertFalse(desc.enumerable);12 assertTrue(desc.configurable);13 assertTrue(desc.writable);14 assertEquals(undefined, desc.get);15 assertEquals(undefined, desc.set);16 assertThrows(() => new Function(`${String.prototype.padEnd}`), SyntaxError);17})();18(function TestRequireObjectCoercible() {19 var padEnd = String.prototype.padEnd;20 assertThrows(() => padEnd.call(null, 4, "test"), TypeError);21 assertThrows(() => padEnd.call(undefined, 4, "test"), TypeError);22 assertEquals("123 ", padEnd.call({23 __proto__: null,24 valueOf() { return 123; }25 }, 6, " "));26 var proxy = new Proxy({}, {27 get(t, name) {28 if (name === Symbol.toPrimitive || name === "toString") return;29 if (name === "valueOf") return () => 6.7;30 assertUnreachable();31 }32 });33 assertEquals("6.7 ", padEnd.call(proxy, 6, " "));34 proxy = new Proxy({}, {35 get(t, name) {36 if (name === Symbol.toPrimitive || name === "valueOf") return;37 if (name === "toString") return () => 6.7;38 assertUnreachable();39 }40 });41 assertEquals("6.7 ", padEnd.call(proxy, 6, " "));42})();43(function TestToLength() {44 assertThrows(() => "123".padEnd(Symbol("16")), TypeError);45 assertEquals("123", "123".padEnd(-1));46 assertEquals("123", "123".padEnd({ toString() { return -1; } }));47 assertEquals("123", "123".padEnd(-0));48 assertEquals("123", "123".padEnd({ toString() { return -0; } }));49 assertEquals("123", "123".padEnd(+0));50 assertEquals("123", "123".padEnd({ toString() { return +0; } }));51 assertEquals("123", "123".padEnd(NaN));52 assertEquals("123", "123".padEnd({ toString() { return NaN; } }));53})();54(function TestFillerToString() {55 assertEquals(". ", ".".padEnd(10));56 assertEquals(". ", ".".padEnd(10, undefined));57 assertEquals(".nullnulln", ".".padEnd(10, null));58 assertEquals(".XXXXXXXXX", ".".padEnd(10, { toString() { return "X"; } }));59 assertEquals(60 ".111111111",61 ".".padEnd(10, { toString: undefined, valueOf() { return 1; } }));62})();63(function TestFillerEmptyString() {64 assertEquals(".", ".".padEnd(10, ""));65 assertEquals(".", ".".padEnd(10, { toString() { return ""; } }));66 assertEquals(67 ".", ".".padEnd(10, { toString: undefined, valueOf() { return ""; } }));68})();69(function TestFillerRepetition() {70 for (var i = 2000; i > 0; --i) {71 var expected = "123" + "xoxo".repeat(i / 4).slice(0, i - 3);72 var actual = "123".padEnd(i, "xoxo");73 assertEquals(expected, actual);74 assertEquals(i > "123".length ? i : 3, actual.length);75 }76})();77(function TestTruncation() {78 assertEquals("ab", "a".padEnd(2, "bc"));...

Full Screen

Full Screen

webform.element.signature.js

Source:webform.element.signature.js Github

copy

Full Screen

1/**2 * @file3 * JavaScript behaviors for signature pad integration.4 */5(function ($, Drupal) {6 'use strict';7 // @see https://github.com/szimek/signature_pad#options8 Drupal.webform = Drupal.webform || {};9 Drupal.webform.signaturePad = Drupal.webform.signaturePad || {};10 Drupal.webform.signaturePad.options = Drupal.webform.signaturePad.options || {};11 /**12 * Initialize signature element.13 *14 * @type {Drupal~behavior}15 */16 Drupal.behaviors.webformSignature = {17 attach: function (context) {18 if (!window.SignaturePad) {19 return;20 }21 $(context).find('input.js-webform-signature').once('webform-signature').each(function () {22 var $input = $(this);23 var value = $input.val();24 var $wrapper = $input.parent();25 var $canvas = $wrapper.find('canvas');26 var $button = $wrapper.find(':button, input[type="submit"]');27 var canvas = $canvas[0];28 // Set height.29 $canvas.attr('width', $wrapper.width());30 $canvas.attr('height', $wrapper.width() / 3);31 $(window).resize(function () {32 $canvas.attr('width', $wrapper.width());33 $canvas.attr('height', $wrapper.width() / 3);34 // Resizing clears the canvas so we need to reset the signature pad.35 signaturePad.clear();36 var value = $input.val();37 if (value) {38 signaturePad.fromDataURL(value);39 }40 });41 // Initialize signature canvas.42 var options = $.extend({43 onEnd: function () {44 $input.val(signaturePad.toDataURL());45 }46 }, Drupal.webform.signaturePad.options);47 var signaturePad = new SignaturePad(canvas, options);48 // Set value.49 if (value) {50 signaturePad.fromDataURL(value);51 }52 // Set reset handler.53 $button.on('click', function () {54 signaturePad.clear();55 $input.val();56 this.blur();57 return false;58 });59 // Input onchange clears signature pad if value is empty.60 // @see webform.states.js61 $input.on('change', function () {62 if (!$input.val()) {63 signaturePad.clear();64 }65 });66 // Turn signature pad off/on when the input is disabled/enabled.67 // @see webform.states.js68 $input.on('webform:disabled', function () {69 if ($input.is(':disabled')) {70 signaturePad.off();71 }72 else {73 signaturePad.on();74 }75 });76 });77 }78 };...

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: `example.png` });47 await browser.close();48})();49const { chromium } =

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.click('text="Docs"');7 await page.click('text="API"')

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2const { chromium } = require('playwright');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})();10{11 "dependencies": {12 },13 "scripts": {14 },15}16const path = require('path');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})();25{26 "dependencies": {27 },28 "scripts": {29 },30}31const path = require('path');32const { chromium } = require('playwright');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})();40{

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

1const { pad } = require('playwright/lib/utils/utils');2console.log(pad('hello', 10));3const { utils } = require('playwright');4console.log(utils.pad('hello', 10));5const playwright = require('playwright');6console.log(playwright.utils.pad('hello', 10));7const { utils: { pad } } = require('playwright');8console.log(pad('hello', 10));9const playwright = require('playwright');10const { pad } = playwright.utils;11console.log(pad('hello', 10));12const playwright = require('playwright');13const pad = playwright.utils.pad;14console.log(pad('hello', 10));15const playwright = require('playwright');16const pad = playwright.utils.pad;17console.log(pad('hello', 10));18const playwright = require('playwright');19const pad = playwright.utils.pad;20console.log(pad('hello', 10));21const playwright = require('playwright');22const pad = playwright.utils.pad;23console.log(pad('hello', 10));24const playwright = require('playwright');25const pad = playwright.utils.pad;26console.log(pad('hello', 10));27const playwright = require('playwright');28const pad = playwright.utils.pad;29console.log(pad('hello', 10));30const playwright = require('playwright');31const pad = playwright.utils.pad;32console.log(pad('hello', 10));

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const browser = await chromium.launch();3const context = await browser.newContext();4const page = await context.newPage();5await browser.close();6const { webkit } = require('playwright');7const browser = await webkit.launch();8const context = await browser.newContext();9const page = await context.newPage();10await browser.close();11const { firefox } = require('playwright');12const browser = await firefox.launch();13const context = await browser.newContext();14const page = await context.newPage();15await browser.close();16const { devices } = require('playwright');17const browser = await chromium.launch();18const context = await browser.newContext(devices['iPhone X']);19const page = await context.newPage();20await browser.close();21const { devices } = require('playwright');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Internal } = require('playwright');2const internal = new Internal();3const { Internal } = require('playwright');4const internal = new Internal();5const { Internal } = require('playwright');6const internal = new Internal();7const { Internal } = require('playwright');8const internal = new Internal();

Full Screen

Using AI Code Generation

copy

Full Screen

1const {pad} = require('playwright/internal/stackTrace');2console.log(pad('test', 10, 1, ' '));3console.log(pad('test', 10, 1, ' ', true));4console.log(pad('test', 10, 1, ' ', false));5console.log(pad('test', 10, 1, ' ', true, true));6console.log(pad('test', 10, 1, ' ', false, true));7console.log(pad('test', 10, 1, ' ', true, false));8console.log(pad('test', 10, 1, ' ', false, false));9console.log(pad('test', 10, 1, ' ', true, true, true));10console.log(pad('test', 10, 1, ' ', false, true, true));11console.log(pad('test', 10, 1, ' ', true, false, true));12console.log(pad('test', 10, 1, ' ', false, false, true));13console.log(pad('test', 10, 1, ' ', true, true, false));14console.log(pad('test', 10, 1, ' ', false, true, false));15console.log(pad('test', 10, 1, ' ', true, false, false));16console.log(pad('test', 10, 1, ' ', false, false, false));17console.log(pad('test', 10, 1,

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