query-testcommon.js (570B)
1 'use strict'; 2 3 function test_query_selector(parentNode, selector, expected) { 4 if (!Array.isArray(expected)) 5 expected = [ expected ]; 6 7 test(function(){ 8 const elementList = parentNode.querySelectorAll(selector); 9 assert_equals(elementList.length, expected.length); 10 11 for (let i = 0; i < elementList.length; ++i) { 12 if (typeof expected[i] === 'string') 13 assert_equals(elementList[i].id, expected[i]); 14 else 15 assert_equals(elementList[i], expected[i]); 16 } 17 }, "Selector '" + selector + '" should find the expected elements'); 18 }