summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/inert/inert-and-find.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/inert/inert-and-find.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/inert/inert-and-find.html')
-rw-r--r--testing/web-platform/tests/inert/inert-and-find.html53
1 files changed, 53 insertions, 0 deletions
diff --git a/testing/web-platform/tests/inert/inert-and-find.html b/testing/web-platform/tests/inert/inert-and-find.html
new file mode 100644
index 0000000000..87555b0097
--- /dev/null
+++ b/testing/web-platform/tests/inert/inert-and-find.html
@@ -0,0 +1,53 @@
+<!doctype html>
+<meta charset="utf-8">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<link rel="help" href="https://html.spec.whatwg.org/#inert-subtrees">
+<title>Basic test for inert and find</title>
+<body>
+<script>
+const t = async_test("Basic test for inert and find");
+
+function testFindable(findCount, textToFind, buildDoc, description) {
+ if (typeof findCount == "boolean")
+ findCount = findCount ? 1 : 0;
+ try {
+ const iframe = document.querySelector("iframe")
+ iframe.contentDocument.documentElement.innerHTML =
+ (typeof buildDoc == "string") ? buildDoc : "";
+
+ if (typeof buildDoc == "function")
+ buildDoc(iframe.contentDocument);
+
+ iframe.contentWindow.getSelection().removeAllRanges();
+ for (let i = findCount; i >= 0; --i) {
+ const expectFindable = i != 0;
+ assert_equals(
+ iframe.contentWindow.find(textToFind),
+ expectFindable,
+ "Should be " + (expectFindable ? "" : "not ") + "findable: " + description + ", text: " + textToFind + ", iter: " + (findCount - i + 1)
+ );
+ }
+ } catch (ex) {
+ assert_unreached(ex);
+ }
+}
+
+let runTests = t.step_func_done(function() {
+ testFindable(true, "me", `
+ Find me please
+ `, "basic functionality test");
+
+ testFindable(false, "me", `
+ <div inert>Do not find me please</div>
+ `, "Basic use case");
+});
+
+window.onload = function() {
+ let iframe = document.createElement("iframe");
+ iframe.onload = runTests;
+ iframe.srcdoc = "<!doctype html><html></html>";
+ document.body.appendChild(iframe);
+};
+</script>
+</body>