@@ -1138,4 +1138,35 @@ describe('TextFragmentUtils', function() {
11381138 utils . forTesting . acceptTextNodeIfVisibleInRange ( divNode , range ) ;
11391139 expect ( filterOutput ) . toEqual ( NodeFilter . FILTER_REJECT ) ;
11401140 } ) ;
1141+
1142+ it ( 'Ignores zero-width/height elements with hidden overflow' , function ( ) {
1143+ document . body . innerHTML = __html__ [ 'hidden-overflow.html' ] ;
1144+ {
1145+ const directives = utils . getFragmentDirectives (
1146+ '#:~:text=Target%20text-fragment%201' ,
1147+ ) ;
1148+ const parsedDirectives = utils . parseFragmentDirectives ( directives ) ;
1149+ const processedDirectives =
1150+ utils . processFragmentDirectives ( parsedDirectives ) [ 'text' ] ;
1151+ expect ( processedDirectives [ 0 ] . length ) . toBe ( 1 ) ;
1152+ }
1153+ {
1154+ const directives = utils . getFragmentDirectives (
1155+ '#:~:text=Target%20text-fragment%202' ,
1156+ ) ;
1157+ const parsedDirectives = utils . parseFragmentDirectives ( directives ) ;
1158+ const processedDirectives =
1159+ utils . processFragmentDirectives ( parsedDirectives ) [ 'text' ] ;
1160+ expect ( processedDirectives [ 0 ] . length ) . toBe ( 0 ) ;
1161+ }
1162+ {
1163+ const directives = utils . getFragmentDirectives (
1164+ '#:~:text=Target%20text-fragment%203' ,
1165+ ) ;
1166+ const parsedDirectives = utils . parseFragmentDirectives ( directives ) ;
1167+ const processedDirectives =
1168+ utils . processFragmentDirectives ( parsedDirectives ) [ 'text' ] ;
1169+ expect ( processedDirectives [ 0 ] . length ) . toBe ( 0 ) ;
1170+ }
1171+ } ) ;
11411172} ) ;
0 commit comments