summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/support/query-testcommon.js
blob: 73246e17e879ecfa711d9d804768a28a9910cc82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
'use strict';

function test_query_selector(parentNode, selector, expected) {
  if (!Array.isArray(expected))
    expected = [ expected ];

  test(function(){
    const elementList = parentNode.querySelectorAll(selector);
    assert_equals(elementList.length, expected.length);

    for (let i = 0; i < elementList.length; ++i) {
      if (typeof expected[i] === 'string')
        assert_equals(elementList[i].id, expected[i]);
      else
        assert_equals(elementList[i], expected[i]);
    }
  }, "Selector '" + selector + '" should find the expected elements');
}