Skip to content

Commit

Permalink
Bug 1579450 [wpt PR 18898] - Strip the fragment directive and update …
Browse files Browse the repository at this point in the history
…scroll-to-text WPT, a=testonly

Automatic update from web-platform-tests
Strip the fragment directive and update scroll-to-text WPT

Scroll to text defines a double-hash as the URL fragment directive[1].
The fragment directive should always be stripped from the URL to avoid
breaking pages that use the fragment for state. Our implementation
previously only stripped the fragment directive if we parsed targetText.

Also improved the web platform test to test whether the target scrolls
to the element or text fragment as expected.

Tested updated WPT locally with
run_web_tests.py --additional-driver-flag=
  '--enable-blink-features=TextFragmentIdentifiers'

[1] whatwg/url#445

Bug: 994818
Change-Id: I48109683a5e5ba162f1db72b1c5b174f3b017251
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1772166
Commit-Queue: Nick Burris <nburrischromium.org>
Reviewed-by: David Bokan <bokanchromium.org>
Cr-Commit-Position: refs/heads/master{#694407}

--

wpt-commits: 603a271948a7162bc6efc3c882856e618eabb30e
wpt-pr: 18898

UltraBlame original commit: d6a259fed875176e1f7bc83e32e1eb6cc9ef1fb0
  • Loading branch information
marco-c committed Oct 4, 2019
1 parent 6053efd commit 9b84561
Show file tree
Hide file tree
Showing 2 changed files with 179 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,43 @@
script
>
function
isInView
(
element
)
{
return
(
element
.
offsetTop
>
=
window
.
scrollY
)
&
&
(
element
.
offsetTop
<
=
(
window
.
scrollY
+
window
.
innerHeight
)
)
;
}
function
checkScroll
(
)
Expand All @@ -41,18 +78,78 @@
'
)
;
var
position
=
'
unknown
'
;
if
(
window
.
scrollY
=
=
0
)
position
=
'
top
'
;
else
if
(
isInView
(
document
.
getElementById
(
'
element
'
)
)
)
position
=
'
element
'
;
else
if
(
isInView
(
document
.
getElementById
(
'
text
'
)
)
)
position
=
'
text
'
;
bc
.
postMessage
(
{
didScrollToTarget
scrollPosition
:
window
.
scrollY
>
0
position
}
)
;
Expand Down Expand Up @@ -115,8 +212,11 @@
onload
=
"
checkScroll
window
.
requestAnimationFrame
(
checkScroll
)
"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@
'
#
'
expect_scroll
expect_position
:
false
'
top
'
}
{
fragment
Expand All @@ -126,9 +128,11 @@
=
test
'
expect_scroll
expect_position
:
true
'
text
'
}
{
fragment
Expand All @@ -141,9 +145,11 @@
this
page
'
expect_scroll
expect_position
:
true
'
text
'
}
{
fragment
Expand All @@ -158,9 +164,11 @@
is
test
'
expect_scroll
expect_position
:
true
'
text
'
}
{
fragment
Expand All @@ -177,9 +185,11 @@
-
page
'
expect_scroll
expect_position
:
true
'
text
'
}
{
fragment
Expand All @@ -196,9 +206,11 @@
-
none
'
expect_scroll
expect_position
:
false
'
top
'
}
{
fragment
Expand All @@ -213,9 +225,11 @@
-
page
'
expect_scroll
expect_position
:
true
'
text
'
}
{
fragment
Expand All @@ -235,9 +249,11 @@
%
20page
'
expect_scroll
expect_position
:
true
'
text
'
}
{
fragment
Expand All @@ -254,9 +270,11 @@
test
page
'
expect_scroll
expect_position
:
true
'
text
'
}
{
fragment
Expand All @@ -270,9 +288,11 @@
=
test
'
expect_scroll
expect_position
:
true
'
text
'
}
{
fragment
Expand All @@ -286,9 +306,11 @@
=
nomatch
'
expect_scroll
expect_position
:
false
'
top
'
}
{
fragment
Expand All @@ -302,9 +324,27 @@
=
nomatch
'
expect_scroll
expect_position
:
true
'
element
'
}
{
fragment
:
'
#
element
#
#
directive
'
expect_position
:
'
element
'
}
]
;
Expand Down Expand Up @@ -362,7 +402,7 @@
.
data
.
didScrollToTarget
scrollPosition
)
;
}
Expand Down Expand Up @@ -429,16 +469,16 @@
.
then
(
scroll
scrollPosition
=
>
{
assert_equals
(
scroll
scrollPosition
test_case
.
expect_scroll
expect_position
'
Expected
'
Expand All @@ -447,24 +487,15 @@
.
fragment
+
(
test_case
.
expect_scroll
?
'
to
scroll
.
'
:
'
to
not
scroll
.
'
)
+
test_case
.
expect_position
)
;
}
Expand Down

0 comments on commit 9b84561

Please sign in to comment.