diff options
Diffstat (limited to 'testing/web-platform/tests/scroll-to-text-fragment')
-rw-r--r-- | testing/web-platform/tests/scroll-to-text-fragment/WEB_FEATURES.yml | 3 | ||||
-rw-r--r-- | testing/web-platform/tests/scroll-to-text-fragment/percent-encoding.html | 33 |
2 files changed, 21 insertions, 15 deletions
diff --git a/testing/web-platform/tests/scroll-to-text-fragment/WEB_FEATURES.yml b/testing/web-platform/tests/scroll-to-text-fragment/WEB_FEATURES.yml new file mode 100644 index 0000000000..0b260aaaec --- /dev/null +++ b/testing/web-platform/tests/scroll-to-text-fragment/WEB_FEATURES.yml @@ -0,0 +1,3 @@ +features: +- name: text-fragments + files: "**" diff --git a/testing/web-platform/tests/scroll-to-text-fragment/percent-encoding.html b/testing/web-platform/tests/scroll-to-text-fragment/percent-encoding.html index 1f1794bdae..be688eabfc 100644 --- a/testing/web-platform/tests/scroll-to-text-fragment/percent-encoding.html +++ b/testing/web-platform/tests/scroll-to-text-fragment/percent-encoding.html @@ -35,17 +35,17 @@ let test_cases = [ }, { fragment: '#:~:text=%', - expect: 'noscroll', + expect: 'singlepercent', description: 'Percent char without hex digits is invalid.' }, { fragment: '#:~:text=%%', - expect: 'noscroll', + expect: 'doublepercent', description: 'Percent char followed by percent char is invalid.' }, { fragment: '#:~:text=%F', - expect: 'noscroll', + expect: 'percentf', description: 'Single digit percent-encoding is invalid.' }, { @@ -65,21 +65,23 @@ let test_cases = [ }, ]; -for (const test_case of test_cases) { - promise_test(t => new Promise(resolve => { - // Clear the fragment and reset the scroll offset to prepare for the next - // test case. - location = `${location.pathname}#`; - scrollTo(0, 0); +function runTests() { + for (const test_case of test_cases) { + promise_test(t => new Promise(resolve => { + // Clear the fragment and reset the scroll offset to prepare for the next + // test case. + location = `${location.pathname}#`; + scrollTo(0, 0); - location = `${location.pathname}${test_case.fragment}`; - requestAnimationFrame( () => requestAnimationFrame(resolve) ); - }).then(() => { - assert_equals(determineResult(), test_case.expect); - }), `Test navigation with fragment: ${test_case.description}.`); + location = `${location.pathname}${test_case.fragment}`; + requestAnimationFrame( () => requestAnimationFrame(resolve) ); + }).then(() => { + assert_equals(determineResult(), test_case.expect); + }), `Test navigation with fragment: ${test_case.description}.`); + } } </script> - +<body onload="runTests()"> <p class="target" id="singlepercent"> % </p> @@ -100,3 +102,4 @@ for (const test_case of test_cases) { Hello world </p> +</body>
\ No newline at end of file |