How to use check_list_subset_of_targetlist method in wpt

Best JavaScript code snippet using wpt

multi-touch-interactions.js

Source:multi-touch-interactions.js Github

copy

Full Screen

...4/* uncomment below statement to show debug messages */5// document.getElementById("debug").innerHTML += x;6}7var starting_elements = {};8function check_list_subset_of_targetlist(list, list_name, targetlist, targetlist_name) {9 var exist_in_targetlist;10 for(i=0; i<list.length; i++) {11 exist_in_targetlist=false;12 for(j=0; j<targetlist.length; j++)13 if(list.item(i).identifier==targetlist.item(j).identifier)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;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;188 last_targetTouches[ev.target.id] = ev.targetTouches;189 last_changedTouches = {}; // changedTouches are only saved for touchend events190 });191 on_event(window, "touchend", function onTouchEnd(ev) {192 // process event only if it's targeted at target0 or target1193 if(ev.target != target0 && ev.target != target1 )194 return;195 test_touchend.step(function() {196 assert_true(touchstart_received>0, "touchend follows touchstart");197 });198 test_touchend.done();199 touchend_received++;200 debug_print("touchend #" + touchend_received + ":<br>");201 debug_print("changedTouches.length=" + ev.changedTouches.length + "<br>");202 debug_print("targetTouches.length=" + ev.targetTouches.length + "<br>");203 debug_print("touches.length=" + ev.touches.length + "<br>");204 for(i=0; i<ev.changedTouches.length; i++)205 debug_print("changedTouches.item(" + i + ").target=" + ev.changedTouches.item(i).target.id + "<br>");206 // TA: 1.5.2.2207 test(function() {208 assert_true(ev.changedTouches.length >= 1, "changedTouches.length is at least 1");209 }, "touchend #" + touchend_received + ": length of changedTouches is valid");210 // TA: 1.5.2.3211 test(function() {212 check_list_subset_of_targetlist(ev.changedTouches, "changedTouches", last_touches, "last received touches");213 }, "touchend #" + touchend_received + ": changedTouches is a subset of last received touches");214 // TA: 1.5.2.4, 1.5.2.5215 test(function() {216 check_no_item_in_targetlist(ev.changedTouches, "changedTouches", ev.touches, "touches");217 check_no_item_in_targetlist(ev.changedTouches, "changedTouches", ev.targetTouches, "targetTouches");218 }, "touchend #" + touchend_received + ": no item in changedTouches are in touches or targetTouches");219 // TA: 1.5.2.6220 test(function() {221 var found=false;222 for (i=0; i<ev.changedTouches.length; i++)223 if (ev.changedTouches.item(i).target == ev.target)224 found=true;225 assert_true(found, "at least one item in changedTouches has matching target");226 }, "touchend #" + touchend_received + ": at least one item in changedTouches targeted at this element");227 // TA: 1.5.3.2, 1.5.3.3228 test(function() {229 assert_true(ev.targetTouches.length >= 0, "targetTouches.length is non-negative");230 assert_true(ev.targetTouches.length <= ev.touches.length, "targetTouches.length is smaller than touches.length");231 check_list_subset_of_targetlist(ev.targetTouches, "targetTouches", ev.touches, "touches");232 }, "touchend #" + touchend_received + ": targetTouches is a subset of touches");233 // TA: 1.5.3.5 (new)234 test(function() {235 check_targets(ev.targetTouches, ev.target);236 }, "touchend #" + touchend_received + ": targets of targetTouches are correct");237 // In some cases, when multiple touch points are released simultaneously238 // the UA would dispatch the "same" touchend event (same changedTouches, same touches, but possibly different targetTouches)239 // to each of the elements that are starting elements of the released touch points.240 // in these situations, the subsequent events are exempt from TA 1.5.3.4 and 1.5.4.2241 var same_event_as_last = false;242 if (last_changedTouches && last_changedTouches.length==ev.changedTouches.length) {243 same_event_as_last = true; // assume true until proven otherwise244 for (i=0; i<last_changedTouches.length; i++) {245 var match = false;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptargetlist = require('./wptargetlist.js');2var targetlist = wptargetlist.get_targetlist();3var check_list_subset_of_targetlist = wptargetlist.check_list_subset_of_targetlist;4var list = ['www.facebook.com', 'www.google.com', 'www.yahoo.com'];5var result = check_list_subset_of_targetlist(list, targetlist);6console.log(result);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt_test_list = require('./wpt_test_list.js');2var list1 = ['abc', 'def', 'ghi', 'jkl'];3var list2 = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr'];4var list3 = ['abc', 'def', 'ghi', 'jkl', 'mno'];5var list4 = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx'];6var list5 = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'];7var list6 = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', '123'];8var list7 = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', '123', '456'];9var list8 = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', '123', '456', '789'];10var list9 = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', '123', '456', '789', '000'];11var list10 = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', '123', '456', '789', '000', '111'];12var list11 = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', '123', '456', '789', '000', '111', '222'];13var list12 = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', '123', '456', '789', '000', '111', '222', '333'];

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2var list = ["a","b","c"];3var target_list = ["a","b","c","d","e","f"];4var result = wpt.check_list_subset_of_targetlist(list, target_list);5if (result == true){6 console.log("The list is a subset of the target list");7}8else{9 console.log("The list is not a subset of the target list");10}

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