Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: layout/base/tests/mochitest.toml
<!DOCTYPE HTML>
<html>
<!--
-->
<head>
<meta charset="utf-8">
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
var testRunning = false;
async function runTest() {
if (testRunning) {
return;
}
testRunning = true;
var e = document.getElementsByTagName('iframe')[0];
var win = e.contentWindow;
var p = new Promise((r) => { win.addEventListener("hashchange", r, { once: true }); });
win.location.hash = '#anchor';
await p;
win.scrollTo(0, 500);
p = new Promise((r) => { e.addEventListener("load", r, { once: true }); });
win.location.reload();
await p;
is(win.location.hash, "#anchor", "We set the location's hash to 'anchor'");
// Allow a half pixel difference because the scroll position is aligned with
isfuzzy(win.scrollY, 500, 0.5, "Reloading keeps scroll position");
var link = win.document.getElementsByTagName('a')[0];
var anchor = win.document.getElementsByTagName('a')[1];
p = new Promise((r) => {
var observer = new IntersectionObserver((entries) => {
info("IntersectionObserver: entering callback")
if (entries.some((entry) => entry.isIntersecting)) {
info("IntersectionObserver: some entry isIntersecting; disconnecting")
observer.disconnect();
r();
}
});
observer.observe(anchor);
});
win.document.body.offsetHeight;
synthesizeMouseAtCenter(link, {type: "mousedown"}, win);
synthesizeMouseAtCenter(link, {type: "mouseup"}, win);
info("Sending click")
sendMouseEvent({type: "click"}, link, win);
await p;
let actualScroll = win.scrollY;
info("Promise resolved (for IntersectionObserver). win.scrollY is " +
actualScroll);
ok(actualScroll > 3000, "Scrolling after load works.");
SimpleTest.finish();
}
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=851485">Mozilla Bug 851485</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
<iframe src="file_bug842853.html"></iframe>
<script>
</script>
</body>
</html>