-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Text Fragments: Separate json test case to let others pass.
The test to check if scrolling is allowed in non-html documents times out for JSON, because it depends on the `onload` event, which Gecko is not firing for JSON (Bug 1905106). Additionally, other test cases in that file can time out on CI as well. With this patch, the JSON test case is separated into its own file and is expected to `TIMEOUT`. The other test cases get a longer timeout so that they pass in all configurations. Differential Revision: https://phabricator.services.mozilla.com/D216565 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1907901 gecko-commit: 72e40f9471c4f8348d84d2e211b97f26c4a84d7b gecko-reviewers: dom-core, sefeng
- Loading branch information
1 parent
e9503de
commit 0291480
Showing
2 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!doctype html> | ||
<title>Allow text fragments in HTML documents only</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 src="/common/utils.js"></script> | ||
<script src="stash.js"></script> | ||
|
||
<script> | ||
// This test originates from non-html-documents.html and was moved into its own | ||
// file because JSON does not emit `onload` in Gecko and this test would timeout | ||
// See https://bugzil.la/1907901 | ||
|
||
function rAF(win) { | ||
return new Promise((resolve) => { | ||
win.requestAnimationFrame(resolve); | ||
}); | ||
} | ||
|
||
function openPopup(url) { | ||
return new Promise((resolve) => { | ||
test_driver.bless('Open a URL with a text fragment directive', () => { | ||
const popup = window.open(url, '_blank', 'width=300,height=300'); | ||
popup.onload = () => resolve(popup); | ||
}); | ||
}); | ||
} | ||
const filename = 'application-json.json' | ||
const expected = 'blocked'; | ||
const mediaType = filename.split('.')[0].replace('-', '/'); | ||
|
||
promise_test(async function (t) { | ||
const popup = await openPopup(`resources/${filename}#:~:text=target`); | ||
|
||
// The WPT server should provide the correct content-type header from the | ||
// file extension. | ||
assert_equals(popup.document.contentType, mediaType); | ||
|
||
// rAF twice in case there is any asynchronicity in scrolling to the target. | ||
await rAF(popup); | ||
await rAF(popup); | ||
|
||
const did_scroll = popup.scrollY > 0; | ||
const expected_scroll = expected == 'allowed'; | ||
assert_equals(did_scroll, expected_scroll, 'scrolled to fragment'); | ||
|
||
popup.close(); | ||
}, `Text directive ${expected} in ${mediaType}`); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters