summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/nodes/ParentNode-querySelectors-exclusive.html
blob: 5cff9367cf090ad65200cf8e4ff35a3e4eb2059f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<meta charset="utf-8">
<title>querySelector/querySelectorAll should not include their thisArg</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- Regression test for https://github.com/jsdom/jsdom/issues/2296 -->

<script>
"use strict";

setup({ single_test: true });

const button = document.createElement("button");

assert_equals(button.querySelector("*"), null, "querySelector, '*', before modification");
assert_equals(button.querySelector("button"), null, "querySelector, 'button', before modification");
assert_equals(button.querySelector("button, span"), null, "querySelector, 'button, span', before modification");
assert_array_equals(button.querySelectorAll("*"), [], "querySelectorAll, '*', before modification");
assert_array_equals(button.querySelectorAll("button"), [], "querySelectorAll, 'button', before modification");
assert_array_equals(
  button.querySelectorAll("button, span"), [],
  "querySelectorAll, 'button, span', before modification"
);


button.innerHTML = "text";

assert_equals(button.querySelector("*"), null, "querySelector, '*', after modification");
assert_equals(button.querySelector("button"), null, "querySelector, 'button', after modification");
assert_equals(button.querySelector("button, span"), null, "querySelector, 'button, span', after modification");
assert_array_equals(button.querySelectorAll("*"), [], "querySelectorAll, '*', after modification");
assert_array_equals(button.querySelectorAll("button"), [], "querySelectorAll, 'button', after modification");
assert_array_equals(
  button.querySelectorAll("button, span"), [],
  "querySelectorAll, 'button, span', after modification"
);

done();
</script>