summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-display/support/util.js
blob: 08024b52d5fd82e18fc482888164cbe127239329 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function eachDisplayContentsElementIn(document, window, callbackDo, callbackUndo) {
  var elements = [];

  document.body.offsetHeight;

  // NOTE: Doing qsa('*') and getComputedStyle is just for the
  // test's sake, since it's easier to mess it up when
  // getComputedStyle is involved.
  var all = document.querySelectorAll('*');
  for (var i = 0; i < all.length; ++i) {
    if (window.getComputedStyle(all[i]).display === "contents") {
      callbackDo(all[i]);
      elements.push(all[i]);
    }
  }

  document.body.offsetHeight;

  for (var i = 0; i < elements.length; ++i)
    callbackUndo(elements[i]);

  document.body.offsetHeight;
}