Skip to content

Commit ac51a27

Browse files
committed
Re-import html/editing/the-hidden-attribute WPT
https://bugs.webkit.org/show_bug.cgi?id=294891 rdar://154164234 Reviewed by NOBODY (OOPS!). Upstream commit: web-platform-tests/wpt@bdbb910 * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/beforematch-element-fragment-navigation-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/beforematch-element-fragment-navigation.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/beforematch-scroll-to-text-fragment-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/beforematch-scroll-to-text-fragment.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-ua-stylesheet.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-001-expected.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-001.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-002.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-004-expected.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-004.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-005-expected.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-005-ref.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-005.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-006-ref.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-007-expected.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-007.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-text-fragment-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-text-fragment.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/resources/beforematch-scroll-to-text-fragment-basic.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/resources/beforematch-scroll-to-text-fragment-bubble.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/resources/beforematch-scroll-to-text-fragment-with-anchor.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/resources/container-ref.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/resources/hidden-until-found-text-fragment.html: * LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/resources/spacer-and-container-ref.html: * LayoutTests/tests-options.json:
1 parent 02a8fbd commit ac51a27

26 files changed

+239
-144
lines changed

LayoutTests/TestExpectations

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7945,6 +7945,8 @@ imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-f
79457945
imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-004.html [ ImageOnlyFailure ]
79467946
imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-005.html [ ImageOnlyFailure ]
79477947
imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-007.html [ ImageOnlyFailure ]
7948+
imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/beforematch-scroll-to-text-fragment.html [ Skip ]
7949+
imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-text-fragment.html [ Skip ]
79487950

79497951
# This test hits an assert in debug
79507952
webkit.org/b/290133 [ Debug ] svg/dom/SVGGeometry-isPointInFill-with-null-path.html [ Skip ]

LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/beforematch-element-fragment-navigation-expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ FAIL Verifies that no scrolling occurs when an element selected by the fragment
99
FAIL No scrolling should occur when the beforematch event handler sets the target element's style to display: none. assert_true: beforematch should be called when window.location.hash is set to #displaynone. expected true got false
1010
FAIL Scrolling should still occur when beforematch sets visiblity:hidden on the target element. assert_true: beforematch should be called when window.location.hash is set to #visibilityhidden. expected true got false
1111
PASS Verifies that the beforematch event is not fired on elements without hidden=until-found.
12+
FAIL The hidden attribute should still be set inside the beforematch event handler. assert_true: expected true got false
1213

LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/beforematch-element-fragment-navigation.html

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<meta charset="utf-8">
33
<link rel="author" title="Joey Arhar" href="mailto:[email protected]">
4-
<link rel="help" href="https://github.com/WICG/display-locking">
4+
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#the-hidden-attribute:event-beforematch">
55
<script src="/resources/testharness.js"></script>
66
<script src="/resources/testharnessreport.js"></script>
77

@@ -197,4 +197,21 @@
197197
div.addEventListener('beforematch', t.unreached_func('beforematch should not be fired without hidden=until-found.'));
198198
window.location.hash = '#target';
199199
}, 'Verifies that the beforematch event is not fired on elements without hidden=until-found.');
200+
201+
test(t => {
202+
window.location.hash = '';
203+
const div = document.createElement('div');
204+
div.id = 'target';
205+
div.textContent = 'target';
206+
div.hidden = 'until-found';
207+
document.body.appendChild(div);
208+
t.add_cleanup(() => div.remove());
209+
210+
let hiddenAttributeSet = false;
211+
div.addEventListener('beforematch', () => {
212+
hiddenAttributeSet = div.hasAttribute('hidden');
213+
});
214+
window.location.hash = '#target';
215+
assert_true(hiddenAttributeSet);
216+
}, 'The hidden attribute should still be set inside the beforematch event handler.');
200217
</script>
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

2-
FAIL Verifies that the beforematch event is fired on the matching element of a ScrollToTextFragment navigation. assert_equals: Scrolling should happen after beforematch is fired. expected (number) 0 but got (undefined) undefined
3-
FAIL Verifies that beforematch is only fired on elements targeted by a text fragment when there is both a text fragment and an element fragment. assert_true: foo was searched for, so it should get the beforematch event. expected true got false
4-
FAIL Verifies that the beforematch event bubbles with scroll to text fragment. assert_true: The element containing the searched text should have beforematch fired on it. expected true got false
2+
Harness Error (TIMEOUT), message = null
3+
4+
TIMEOUT Verifies that the beforematch event is fired on the matching element of a ScrollToTextFragment navigation. Test timed out
5+
NOTRUN Verifies that beforematch is only fired on elements targeted by a text fragment when there is both a text fragment and an element fragment.
6+
NOTRUN Verifies that the beforematch event bubbles with scroll to text fragment.
57

Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<!DOCTYPE html>
22
<meta charset="utf-8">
3+
<meta name=timeout content=long>
34
<title>beforematch fired on ScrollToTextFragment</title>
45
<link rel="author" title="Joey Arhar" href="mailto:[email protected]">
5-
<link rel="help" href="https://github.com/WICG/display-locking">
6+
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#the-hidden-attribute:event-beforematch">
67
<script src="/resources/testharness.js"></script>
78
<script src="/resources/testharnessreport.js"></script>
89
<script src="/resources/testdriver.js"></script>
@@ -12,57 +13,65 @@
1213
<script src="/scroll-to-text-fragment/stash.js"></script>
1314

1415
<script>
15-
promise_test(t => new Promise((resolve, reject) => {
16-
const key = token();
17-
test_driver.bless('Open a scroll to text fragment URL', () => {
18-
window.open(
19-
`resources/beforematch-scroll-to-text-fragment-basic.html?key=${key}#:~:text=foo`,
20-
'_blank',
21-
'noopener');
16+
async function fetchResultsNoResolver(key) {
17+
return new Promise((resolve, reject) => {
18+
fetchResults(key, resolve, reject);
2219
});
23-
fetchResults(key, resolve, reject);
24-
}).then(results => {
25-
assert_equals(results.pageYOffsetDuringBeforematch, 0,
26-
'Scrolling should happen after beforematch is fired.');
20+
}
21+
22+
promise_test(async () => {
23+
const key = token();
24+
await test_driver.bless('Open a scroll to text fragment URL');
25+
window.open(
26+
`resources/beforematch-scroll-to-text-fragment-basic.html?key=${key}#:~:text=foo`,
27+
'_blank',
28+
'noopener');
29+
const results = await fetchResultsNoResolver(key);
2730
assert_true(results.beforematchFiredOnFoo,
2831
'Foo was searched for, so it should get a beforematch event.');
2932
assert_false(results.beforematchFiredOnBar,
3033
'Bar was not searched for, so it should not get a beforematch event.');
34+
assert_equals(results.pageYOffsetDuringBeforematch, 0,
35+
'Scrolling should happen after beforematch is fired.');
3136
assert_true(results.pageYOffsetAfterRaf > 0,
3237
'The page should be scrolled down to foo.');
33-
}), 'Verifies that the beforematch event is fired on the matching element of a ScrollToTextFragment navigation.');
38+
assert_true(results.beforematchHiddenAttributePresent,
39+
'The hidden attribute should be set inside the beforematch event handler.');
40+
}, 'Verifies that the beforematch event is fired on the matching element of a ScrollToTextFragment navigation.');
3441

35-
promise_test(t => new Promise((resolve, reject) => {
42+
promise_test(async () => {
3643
const key = token();
37-
test_driver.bless('Open a scroll to text fragment URL', () => {
38-
window.open(
39-
`resources/beforematch-scroll-to-text-fragment-with-anchor.html?key=${key}#:~:text=foo`,
40-
'_blank',
41-
'noopener');
42-
});
43-
fetchResults(key, resolve, reject);
44-
}).then(results => {
44+
await test_driver.bless('Open a scroll to text fragment URL');
45+
window.open(
46+
`resources/beforematch-scroll-to-text-fragment-with-anchor.html?key=${key}#bar:~:text=foo`,
47+
'_blank',
48+
'noopener');
49+
const results = await fetchResultsNoResolver(key);
50+
assert_true(results.fooHasHiddenAttribute,
51+
'hidden=until-found revealing should not happen until after the script tag loads.');
4552
assert_true(results.beforematchFiredOnFoo,
4653
'foo was searched for, so it should get the beforematch event.');
4754
assert_false(results.beforematchFiredOnBar,
4855
'bar should not get the beforematch event despite being the target of an element fragment due to the text fragment.');
49-
}), 'Verifies that beforematch is only fired on elements targeted by a text fragment when there is both a text fragment and an element fragment.');
56+
assert_equals(results.pageYOffsetDuringBeforematch, 0,
57+
'Scrolling should happen after beforematch is fired.');
58+
assert_true(results.pageYOffsetAfterRaf > 0,
59+
'The page should be scrolled down to foo.');
60+
}, 'Verifies that beforematch is only fired on elements targeted by a text fragment when there is both a text fragment and an element fragment.');
5061

51-
promise_test(t => new Promise((resolve, reject) => {
62+
promise_test(async () => {
5263
const key = token();
53-
test_driver.bless('Open a scroll to text fragment URL', () => {
54-
window.open(
55-
`resources/beforematch-scroll-to-text-fragment-bubble.html?key=${key}#:~:text=foo`,
56-
'_blank',
57-
'noopener');
58-
});
59-
fetchResults(key, resolve, reject);
60-
}).then(results => {
64+
await test_driver.bless('Open a scroll to text fragment URL');
65+
window.open(
66+
`resources/beforematch-scroll-to-text-fragment-bubble.html?key=${key}#:~:text=foo`,
67+
'_blank',
68+
'noopener');
69+
const results = await fetchResultsNoResolver(key);
6170
assert_true(results.beforematchFiredOnChild,
6271
'The element containing the searched text should have beforematch fired on it.');
6372
assert_true(results.beforematchFiredOnParent,
6473
'The parent element of the element containing the matching text should have the beforematch event fired on it because the event should bubble.');
65-
}), 'Verifies that the beforematch event bubbles with scroll to text fragment.');
74+
}, 'Verifies that the beforematch event bubbles with scroll to text fragment.');
6675

6776
// TODO(jarhar): Write more tests here once we decide on a behavior here: https://github.com/WICG/display-locking/issues/150
6877
</script>

LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-ua-stylesheet.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
`${description} should not affect the div's display property.`);
2929
assert_equals(getComputedStyle(div).contentVisibility, 'hidden',
3030
`${description} should make the div content-visibility:hidden.`);
31+
assert_equals(div.hidden, "until-found",
32+
`${description} should make the div hidden=until-found.`);
3133
}, description);
34+
3235
}
3336

3437
function testNormal(description) {

LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-001-expected.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<meta charset="utf8">
44
<title>CSS Content Visibility: container (reference)</title>
55
<link rel="author" title="Vladimir Levin" href="mailto:[email protected]">
6-
<link rel="help" href="https://github.com/WICG/display-locking">
6+
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#attr-hidden-until-found">
77

88
<style>
99
#container {

LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-001.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf8">
55
<title>content-visibility changes after a delay</title>
66
<link rel="author" title="Vladimir Levin" href="mailto:[email protected]">
7-
<link rel="help" href="https://github.com/WICG/display-locking">
7+
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#attr-hidden-until-found">
88
<link rel="match" href="./resources/container-ref.html">
99
<meta name="assert" content="scrollIntoView has no effect on hidden=until-found">
1010
<script src="/common/reftest-wait.js"></script>

LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-002.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<meta charset="utf8">
33
<title>Content Visibility: tab order navigation ignores hidden=until-found subtrees</title>
44
<link rel="author" title="Vladimir Levin" href="mailto:[email protected]">
5-
<link rel="help" href="https://github.com/WICG/display-locking">
5+
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#attr-hidden-until-found">
66
<meta name="assert" content="tab order navigation ignores hidden=until-found subtrees.">
77

88
<script src="/resources/testharness.js"></script>
@@ -21,7 +21,7 @@
2121

2222
<script>
2323
async_test((t) => {
24-
const tab = "\t";
24+
const tab = "\ue004";
2525
async function step1() {
2626
await test_driver.send_keys(document.body, tab);
2727
t.step(() => {

LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-004-expected.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<meta charset="utf8">
44
<title>CSS Content Visibility: container (reference)</title>
55
<link rel="author" title="Vladimir Levin" href="mailto:[email protected]">
6-
<link rel="help" href="https://github.com/WICG/display-locking">
6+
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#attr-hidden-until-found">
77

88
<style>
99
#container {

LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-004.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<meta charset="utf8">
44
<title>hidden=until-found does not paint</title>
55
<link rel="author" title="Vladimir Levin" href="mailto:[email protected]">
6-
<link rel="help" href="https://github.com/WICG/display-locking">
6+
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#attr-hidden-until-found">
77
<link rel="match" href="./resources/container-ref.html">
88
<meta name="assert" content="content-visibility subtrees are not painted">
99

LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-005-expected.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<meta charset="utf8">
44
<title>Content Visibility: hidden-matchable and size contained (reference)</title>
55
<link rel="author" title="Vladimir Levin" href="mailto:[email protected]">
6-
<link rel="help" href="https://github.com/WICG/display-locking">
6+
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#attr-hidden-until-found">
77

88
<style>
99
div {

LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-005-ref.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<meta charset="utf8">
44
<title>Content Visibility: hidden-matchable and size contained (reference)</title>
55
<link rel="author" title="Vladimir Levin" href="mailto:[email protected]">
6-
<link rel="help" href="https://github.com/WICG/display-locking">
6+
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#attr-hidden-until-found">
77

88
<style>
99
div {

LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-005.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<meta charset="utf8">
44
<title>hidden=until-found and size contained</title>
55
<link rel="author" title="Vladimir Levin" href="mailto:[email protected]">
6-
<link rel="help" href="https://github.com/WICG/display-locking">
6+
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#attr-hidden-until-found">
77
<link rel="match" href="hidden-until-found-005-ref.html">
88
<meta name="assert" content="hidden=until-found puts in size containment">
99

LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-006-ref.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<meta charset="utf8">
44
<title>content-visibility hidden-matchable + scrollIntoView (reference)</title>
55
<link rel="author" title="Vladimir Levin" href="mailto:[email protected]">
6-
<link rel="help" href="https://github.com/WICG/display-locking">
6+
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#attr-hidden-until-found">
77

88
<style>
99
.spacer {

LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-007-expected.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<meta charset="utf8">
44
<title>Content Visibility: spacer and a container (reference)</title>
55
<link rel="author" title="Vladimir Levin" href="mailto:[email protected]">
6-
<link rel="help" href="https://github.com/WICG/display-locking">
6+
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#attr-hidden-until-found">
77

88
<style>
99
.spacer {

LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-007.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf8">
55
<title>hidden=until-found + focus</title>
66
<link rel="author" title="Vladimir Levin" href="mailto:[email protected]">
7-
<link rel="help" href="https://github.com/WICG/display-locking">
7+
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#attr-hidden-until-found">
88
<link rel="match" href="./resources/spacer-and-container-ref.html">
99
<meta name="assert" content="focus does not scroll or focus element under hidden=until-found">
1010
<script src="/common/reftest-wait.js"></script>
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11

2-
FAIL Verifies that the beforematch event is fired on the matching element of a ScrollToTextFragment navigation. assert_false: The matching hidden=until-found element should have its hidden attribute removed so it can be scrolled to. expected false got true
2+
Harness Error (TIMEOUT), message = null
3+
4+
TIMEOUT Verifies that the beforematch event is fired on the matching element of a ScrollToTextFragment navigation. Test timed out
35

LayoutTests/imported/w3c/web-platform-tests/html/editing/the-hidden-attribute/hidden-until-found-text-fragment.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<meta charset="utf-8">
33
<title>beforematch fired on ScrollToTextFragment</title>
44
<link rel="author" title="Joey Arhar" href="mailto:[email protected]">
5-
<link rel="help" href="https://github.com/WICG/display-locking">
5+
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#attr-hidden-until-found">
66
<script src="/resources/testharness.js"></script>
77
<script src="/resources/testharnessreport.js"></script>
88
<script src="/resources/testdriver.js"></script>

0 commit comments

Comments
 (0)