How to use is_at_least_one_item_in_targetlist method in wpt

Best JavaScript code snippet using wpt

multi-touch-interactions.js

Source:multi-touch-interactions.js Github

copy

Full Screen

...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;149 ev.preventDefault();150 // TA: 1.6.1151 test_touchmove.step(function() {152 assert_true(touchstart_received>0, "touchmove follows touchstart");153 // assert_false(touchend_received, "touchmove precedes touchend"); // this applies to scenario tests154 });155 test_touchmove.done();156 touchmove_received++;157 // do the detailed checking only for a few times158 if(touchmove_received<6) {159 // TA: 1.4.2.2, 1.4.2.4160 test(function() {161 assert_true(ev.changedTouches.length >= 1, "changedTouches.length is at least 1");162 assert_true(ev.changedTouches.length <= ev.touches.length, "changedTouches.length is smaller than touches.length");163 check_list_subset_of_targetlist(ev.changedTouches, "changedTouches", ev.touches, "touches");164 }, "touchmove #" + touchmove_received + ": changedTouches is a subset of touches");165 // TA: 1.4.3.2, 1.4.3.4166 test(function() {167 assert_true(ev.targetTouches.length >= 1, "targetTouches.length is at least 1");168 assert_true(ev.targetTouches.length <= ev.touches.length, "targetTouches.length is smaller than touches.length");169 check_list_subset_of_targetlist(ev.targetTouches, "targetTouches", ev.touches, "touches");170 }, "touchmove #" + touchmove_received + ": targetTouches is a subset of touches");171 // TA: 1.4.3.6172 test(function() {173 assert_true(is_at_least_one_item_in_targetlist(ev.targetTouches, ev.changedTouches), "at least one item of targetTouches is in changedTouches");174 }, "touchmove #" + touchmove_received + ": at least one targetTouches item in changedTouches");175 // TA: 1.4.3.8176 test(function() {177 check_targets(ev.targetTouches, ev.target);178 }, "touchmove #" + touchmove_received + ": targets of targetTouches are correct");179 // TA: 1.4.4.2180 test(function() {181 assert_true(ev.touches.length==last_touches.length, "length of touches is same as length of last received touches");182 check_list_subset_of_targetlist(ev.touches, "touches", last_touches, "last received touches");183 }, "touchmove #" + touchmove_received + ": touches must be same as last received touches");184 // TA: 1.6.3185 check_starting_elements(ev.changedTouches);186 }187 last_touches = ev.touches;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptargetlist = require('wptargetlist');2var targetlist = new wptargetlist();3if (targetlist.is_at_least_one_item_in_targetlist()) {4 console.log('At least one item in targetlist');5} else {6 console.log('No item in targetlist');7}

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptargetlist = require('wptargetlist');2wptargetlist.is_at_least_one_item_in_targetlist(targetlist, targetlist2, function(err, result){3 if (err) {4 console.log(err);5 } else {6 console.log(result);7 }8});9var wptargetlist = require('wptargetlist');10wptargetlist.is_all_item_in_targetlist(targetlist, targetlist2, function(err, result){11 if (err) {12 console.log(err);13 } else {14 console.log(result);15 }16});17var wptargetlist = require('wptargetlist');18wptargetlist.is_targetlist_contains_targetlist(targetlist, targetlist2, function(err, result){19 if (err) {20 console.log(err);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptargetlist = require('wptargetlist');2var targetlist = {3 "targetlist": {4 {5 },6 {7 }8 }9}10var targetlist2 = {11 "targetlist": {12 {13 },14 {15 },16 {17 }18 }19}20var targetlist3 = {21 "targetlist": {22 {23 },24 {25 },26 {27 }28 }29}30var targetlist4 = {31 "targetlist": {32 {33 },34 {35 },36 {37 }38 }39}40var targetlist5 = {41 "targetlist": {42 {43 },44 {45 },46 {47 }48 }49}50var targetlist6 = {51 "targetlist": {52 {53 },54 {

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt 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