fune/testing/web-platform/tests/scroll-to-text-fragment/scroll-to-text-fragment-api.html
David Bokan dc0dbc4119 Bug 1659608 [wpt PR 25063] - Move location.fragmentDirective to document, a=testonly
Automatic update from web-platform-tests
Move location.fragmentDirective to document

This CL moves the window.location.fragmentDirective object, used for
feature detecting support for text fragments, to
document.fragmentDirective.

This is a web-facing change. Intent-to-ship thread:

https://groups.google.com/a/chromium.org/d/msg/blink-dev/ygBV2vWIX-o/kbYwrJgDAgAJ

Bug: 1057795
Change-Id: I1a7df51a1cde4c39a3595d7d83b118403db5cd5e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2343634
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Reviewed-by: Nick Burris <nburris@chromium.org>
Reviewed-by: Yoav Weiss <yoavweiss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799740}

--

wpt-commits: f8632b0ebf552d519cc1d7ec63511948c7987f63
wpt-pr: 25063
2020-08-27 08:44:25 +00:00

32 lines
1.2 KiB
HTML

<!doctype html>
<title>Fragment directive API</title>
<meta charset=utf-8>
<link rel="help" href="https://wicg.github.io/ScrollToTextFragment/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script>
test(t => {
assert_equals(typeof(document.fragmentDirective), 'object', 'document.fragmentDirective is defined');
}, 'Scroll to text is feature detectable via document.fragmentDirective');
test(t =>{
document.fragmentDirective = 'text=test';
assert_equals(window.scrollY, 0, 'Setting document.fragmentDirective did not have an effect on scroll position');
assert_equals(typeof(document.fragmentDirective), 'object', 'document.fragmentDirective is still an object type');
assert_equals(Object.keys(document.fragmentDirective).length, 0, 'document.fragmentDirective has no properties');
}, 'Setting document.fragmentDirective has no effect');
</script>
<style>
body {
height: 3200px;
}
#text {
position: absolute;
top: 3000px;
}
</style>
<body>
<p id="text">This is a test page</p>
</body>