Best JavaScript code snippet using wpt
multi-touch-interactions.js
Source:multi-touch-interactions.js
...14 exist_in_targetlist=true;15 assert_true(exist_in_targetlist, list_name + ".item("+i+") exists in " + targetlist_name);16 }17}18function check_list_subset_of_two_targetlists(list, list_name, targetlist1, targetlist1_name, targetlist2, targetlist2_name) {19 var exist_in_targetlists;20 for(i=0; i<list.length; i++) {21 exist_in_targetlists=false;22 for(j=0; j<targetlist1.length; j++)23 if(list.item(i).identifier==targetlist1.item(j).identifier)24 exist_in_targetlists=true;25 if(!exist_in_targetlists)26 for(j=0; j<targetlist2.length; j++)27 if(list.item(i).identifier==targetlist2.item(j).identifier)28 exist_in_targetlists=true;29 assert_true(exist_in_targetlists, list_name + ".item("+i+") exists in " + targetlist1_name + " or " + targetlist2_name);30 }31}32function is_at_least_one_item_in_targetlist(list, targetlist) {33 for(i=0; i<list.length; i++)34 for(j=0; j<targetlist.length; j++)35 if(list.item(i).identifier==targetlist.item(j).identifier)36 return true;37 return false;38}39function check_no_item_in_targetlist(list, list_name, targetlist, targetlist_name) {40 for(i=0; i<list.length; i++)41 for(j=0; j<targetlist.length; j++) {42 assert_false(list.item(i).identifier==targetlist.item(j).identifier, list_name + ".item("+i+") exists in " + targetlist_name);43 return;44 }45}46function check_targets(list, target) {47 for(i=0; i<list.length; i++)48 assert_true(list.item(i).target==target, "item(" + i + ").target is element receiving event");49}50function check_starting_elements(list) {51 for (i=0; i<list.length; i++) {52 assert_equals(list.item(i).target, starting_elements[list.item(i).identifier], "item(" + i + ").target matches starting element");53 }54}55function run() {56 var target0 = document.getElementById("target0");57 var target1 = document.getElementById("target1");58 var test_touchstart = async_test("touchstart event received");59 var test_touchmove = async_test("touchmove event received");60 var test_touchend = async_test("touchend event received");61 var test_mousedown = async_test("Interaction with mouse events");62 var touchstart_received = 0;63 var touchmove_received = 0;64 var touchend_received = 0;65 var touchstart_identifier;66 // last received touch lists for comparison67 var last_touches;68 var last_targetTouches={};69 var last_changedTouches={};70 on_event(window, "touchstart", function onTouchStart(ev) {71 // process event only if it's targeted at target0 or target172 if(ev.target != target0 && ev.target != target1 )73 return;74 ev.preventDefault();75 if(!touchstart_received) {76 // Check event ordering TA: 1.6.177 test_touchstart.step(function() {78 assert_true(touchmove_received==0, "touchstart precedes touchmove");79 assert_true(touchend_received==0, "touchstart precedes touchend");80 });81 test_touchstart.done();82 test_mousedown.done(); // If we got here, then the mouse event test is not needed.83 }84 touchstart_received++;85 // TA: 1.3.2.2, 1.3.2.486 test(function() {87 assert_true(ev.changedTouches.length >= 1, "changedTouches.length is at least 1");88 assert_true(ev.changedTouches.length <= ev.touches.length, "changedTouches.length is smaller than touches.length");89 check_list_subset_of_targetlist(ev.changedTouches, "changedTouches", ev.touches, "touches");90 }, "touchstart #" + touchstart_received + ": changedTouches is a subset of touches");91 // TA: 1.3.3.2, 1.3.3.392 test(function() {93 assert_true(ev.targetTouches.length >= 1, "targetTouches.length is at least 1");94 assert_true(ev.targetTouches.length <= ev.touches.length, "targetTouches.length is smaller than touches.length");95 check_list_subset_of_targetlist(ev.targetTouches, "targetTouches", ev.touches, "touches");96 }, "touchstart #" + touchstart_received + ": targetTouches is a subset of touches");97 // TA: 1.3.3.998 test(function() {99 check_targets(ev.targetTouches, ev.target);100 }, "touchstart #" + touchstart_received + ": targets of targetTouches are correct");101 // TA: 1.3.4.2102 test(function() {103 assert_true(ev.touches.length >= 1, "touches.length is at least 1");104 }, "touchstart #" + touchstart_received + ": touches.length is valid");105 if(touchstart_received == 1) {106 // TA: 1.3.3.5, 1.3.3.7107 test(function() {108 assert_true(ev.targetTouches.length <= ev.changedTouches.length, "targetTouches.length is smaller than changedTouches.length");109 check_list_subset_of_targetlist(ev.targetTouches, "targetTouches", ev.changedTouches, "changedTouches");110 }, "touchstart #" + touchstart_received + ": targetTouches is a subset of changedTouches");111 // TA: 1.3.4.3112 test(function() {113 assert_true(ev.touches.length==ev.changedTouches.length, "touches and changedTouches have the same length");114 }, "touchstart #" + touchstart_received + ": touches and changedTouches have the same length");115 } else {116 // TA: 1.3.3.6117 test(function() {118 var diff_in_targetTouches = ev.targetTouches.length - (last_targetTouches[ev.target.id] ? last_targetTouches[ev.target.id].length : 0);119 assert_true(diff_in_targetTouches > 0, "targetTouches.length is larger than last received targetTouches.length");120 assert_true(diff_in_targetTouches <= ev.changedTouches.length, "change in targetTouches.length is smaller than changedTouches.length");121 }, "touchstart #" + touchstart_received + ": change in targetTouches.length is valid");122 // TA: 1.3.3.8123 test(function() {124 assert_true(is_at_least_one_item_in_targetlist(ev.targetTouches, ev.changedTouches), "at least one item of targetTouches is in changedTouches");125 }, "touchstart #" + touchstart_received + ": at least one targetTouches item in changedTouches");126 // TA: 1.3.4.4127 test(function() {128 var diff_in_touches = ev.touches.length - last_touches.length;129 assert_true(diff_in_touches > 0, "touches.length is larger than last received touches.length");130 assert_true(diff_in_touches == ev.changedTouches.length, "change in touches.length equals changedTouches.length");131 }, "touchstart #" + touchstart_received + ": change in touches.length is valid");132 // TA: 1.3.4.5133 test(function() {134 check_list_subset_of_two_targetlists(ev.touches, "touches", ev.changedTouches, "changedTouches", last_touches, "last touches");135 }, "touchstart #" + touchstart_received + ": touches is subset of {changedTouches, last received touches}");136 }137 // save starting element of each new touch point138 for (i=0; i<ev.changedTouches.length; i++) {139 starting_elements[ev.changedTouches.item(i).identifier] = ev.changedTouches.item(i).target;140 }141 last_touches = ev.touches;142 last_targetTouches[ev.target.id] = ev.targetTouches;143 last_changedTouches = {}; // changedTouches are only saved for touchend events144 });145 on_event(window, "touchmove", function onTouchMove(ev) {146 // process event only if it's targeted at target0 or target1147 if(ev.target != target0 && ev.target != target1 )148 return;...
Using AI Code Generation
1var wptargetlist = require('./wptargetlist.js');2var fs = require('fs');3var readline = require('readline');4var stream = require('stream');5var instream = fs.createReadStream('test.txt');6var outstream = new stream;7var rl = readline.createInterface(instream, outstream);8var wptl = new wptargetlist();9var list1 = [];10var list2 = [];11rl.on('line', function(line) {12 var c = line.split(",");13 if (c[0] == "1") {14 list1.push(c[1]);15 } else {16 list2.push(c[1]);17 }18});19rl.on('close', function() {20 console.log(wptl.check_list_subset_of_two_targetlists(list1, list2));21});22var wptargetlist = require('./wptargetlist.js');23var fs = require('fs');24var readline = require('readline');25var stream = require('stream');26var instream = fs.createReadStream('test.txt');27var outstream = new stream;28var rl = readline.createInterface(instream, outstream);29var wptl = new wptargetlist();30var list1 = [];31var list2 = [];32rl.on('line', function(line) {33 var c = line.split(",");34 if (c[0] == "1") {35 list1.push(c[1]);36 } else {37 list2.push(c[1]);38 }39});40rl.on('close', function() {41 console.log(wptl.get_intersecting_targets(list1, list2));42});43var wptargetlist = require('./wptargetlist.js');44var fs = require('fs');45var readline = require('readline');46var stream = require('stream');47var instream = fs.createReadStream('test.txt');48var outstream = new stream;49var rl = readline.createInterface(instream, outstream);50var wptl = new wptargetlist();51var list1 = [];52var list2 = [];53rl.on('line', function(line) {
Using AI Code Generation
1var wptargets = require('wptargets');2var fs = require('fs');3var file1 = fs.readFileSync('list1.txt', 'utf8');4var file2 = fs.readFileSync('list2.txt', 'utf8');5var wpt = new wptargets();6var list1 = file1.split('\n');7var list2 = file2.split('\n');8var res = wpt.check_list_subset_of_two_targetlists(list1, list2);9console.log(res);10var wptargets = require('wptargets');11var fs = require('fs');12var wpt = new wptargets();13var res = wpt.get_all_live_subdomains_of_target('example.com');14console.log(res);15var wptargets = require('wptargets');16var fs = require('fs');17var file1 = fs.readFileSync('list1.txt', 'utf8');18var wpt = new wptargets();19var list1 = file1.split('\n');20var res = wpt.get_all_live_subdomains_of_target_from_file(list1);21console.log(res);22var wptargets = require('wptargets');23var fs = require('fs');24var file1 = fs.readFileSync('list1.txt', 'utf8');25var wpt = new wptargets();26var list1 = file1.split('\n');27var res = wpt.get_all_live_subdomains_of_target_from_file(list1, 'results.txt');28console.log(res);
Using AI Code Generation
1var wptargets = require('wptargets');2wp1.check_list_subset_of_two_targetlists(wp2,wp3,function(err,result){3 if(err){4 console.log(err);5 }6 else{7 console.log(result);8 }9});10var wptargets = require('wptargets');11 if(err){12 console.log(err);
Using AI Code Generation
1var wptools = require('wptools');2var fs = require('fs');3var _ = require('underscore');4var async = require('async');5var targetList = JSON.parse(fs.readFileSync('./targetList.json', 'utf8'));6var targetList2 = JSON.parse(fs.readFileSync('./targetList2.json', 'utf8'));7var targetList3 = JSON.parse(fs.readFileSync('./targetList3.json', 'utf8'));8var targetList4 = JSON.parse(fs.readFileSync('./targetList4.json', 'utf8'));9var targetList5 = JSON.parse(fs.readFileSync('./targetList5.json', 'utf8'));10var targetList6 = JSON.parse(fs.readFileSync('./targetList6.json', 'utf8'));11var targetList7 = JSON.parse(fs.readFileSync('./targetList7.json', 'utf8'));12var targetList8 = JSON.parse(fs.readFileSync('./targetList8.json', 'utf8'));13var targetList9 = JSON.parse(fs.readFileSync('./targetList9.json', 'utf8'));14var targetList10 = JSON.parse(fs.readFileSync('./targetList10.json', 'utf8'));15var targetList11 = JSON.parse(fs.readFileSync('./targetList11.json', 'utf8'));16var targetList12 = JSON.parse(fs.readFileSync('./targetList12.json', 'utf8'));17var targetList13 = JSON.parse(fs.readFileSync('./targetList13.json', 'utf8'));18var targetList14 = JSON.parse(fs.readFileSync('./targetList14.json', 'utf8'));19var targetList15 = JSON.parse(fs.readFileSync('./targetList15.json', 'utf8'));20var targetList16 = JSON.parse(fs.readFileSync('./targetList16.json', 'utf8'));21var targetList17 = JSON.parse(fs.readFileSync('./targetList17.json', 'utf8'));22var targetList18 = JSON.parse(fs.readFileSync('./targetList18.json', 'utf8'));23var targetList19 = JSON.parse(fs.readFileSync('./targetList19.json', 'utf8'));24var targetList20 = JSON.parse(fs.readFileSync('./targetList20.json', 'utf8'));25var targetList21 = JSON.parse(fs.readFileSync('./targetList21.json', 'utf8'));26var targetList22 = JSON.parse(fs.readFileSync('./targetList22.json', 'utf8'));27var targetList23 = JSON.parse(fs.readFileSync('./targetList23.json', 'utf8'));28var targetList24 = JSON.parse(fs.readFileSync('./targetList24.json', 'utf
Using AI Code Generation
1include("wptargetlist.js");2var wptargetlist1 = new wptargetlist();3var wptargetlist2 = new wptargetlist();4var wptargetlist3 = new wptargetlist();5var wptargetlist4 = new wptargetlist();6var wptargetlist5 = new wptargetlist();7var wptargetlist6 = new wptargetlist();8var wptargetlist7 = new wptargetlist();9var wptargetlist8 = new wptargetlist();10var wptargetlist9 = new wptargetlist();11var wptargetlist10 = new wptargetlist();12var wptargetlist11 = new wptargetlist();13var wptargetlist12 = new wptargetlist();14var wptargetlist13 = new wptargetlist();15wptargetlist1.add_wptarget("1", "1.0", "1.1", "1.2");16wptargetlist1.add_wptarget("2", "2.0", "2.1", "2.2");17wptargetlist1.add_wptarget("3", "3.0", "3.1", "3.2");
Using AI Code Generation
1var wptargetlist = require('./wptargetlist.js');2var target_list1 = new wptargetlist();3var target_list2 = new wptargetlist();4var target_list3 = new wptargetlist();5var target_list4 = new wptargetlist();6var target_list5 = new wptargetlist();7var target_list6 = new wptargetlist();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!