Commit 207e8662 authored by chaopeng's avatar chaopeng Committed by Commit Bot

Convert scroll-position-restored-on-back-at-load-event.html to new style

It can fix the leak by convert test to new style.

Bug: 835802
Change-Id: Icb8efd927fc0e8fc8301be6b7c1c0efd9ed51504
Reviewed-on: https://chromium-review.googlesource.com/1028835Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Commit-Queue: Jianpeng Chao <chaopeng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#563421}
parent 329c2a2f
Test ensures that scrollingElement.scrollTop/Left properties are available by the time DOMContentLoaded event fires.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.scrollingElement.scrollTop is 2000
PASS document.scrollingElement.scrollLeft is 1000
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script>
description('Test ensures that scrollingElement.scrollTop/Left properties are available by the time DOMContentLoaded event fires.');
// Navigation steps:
// 1- page gets first loaded and scrolled.
// 2- loaded page away and then 'back'.
// Test: ensure that by the time DOMContenLoaded fires (after a back navigation), scrollingElement.scrollTop/Left are set.
function init(evt) {
if (window.name == 'second/load') {
shouldBe('document.scrollingElement.scrollTop', '2000');
shouldBe('document.scrollingElement.scrollLeft', '1000');
window.name = "";
if (window.testRunner)
finishJSTest();
} else {
window.scrollTo(1000, 2000);
window.name = "second/load";
}
}
function onLoad() {
setTimeout('window.location = "../../resources/back.html"', 0);
}
window.addEventListener('DOMContentLoaded', init, true);
window.onunload = function() {} // prevent caching
var jsTestIsAsync = true;
</script>
<body onload="onLoad()">
<div id="overflow" style='width: 9999px; height:9999px; float:left;'></div>
<h1 id='console'/>
</body>
</html>
<script src='../../resources/testharness.js'></script>
<script src='../../resources/testharnessreport.js'></script>
<script src='../../resources/gesture-util.js'></script>
<style>
#overflow {
width: 9999px;
height: 9999px;
float: left;
}
</style>
<div id='overflow'></div>
<script>
// Navigation steps:
// 1- page gets first loaded and scrolled.
// 2- loaded page away and then 'back'.
// Test: ensure that by the time DOMContenLoaded fires (after a back navigation), scrollingElement.scrollTop/Left are set.
let t = async_test('Test ensures that scrollingElement.scrollTop/Left properties are available by the time DOMContentLoaded event fires.');
function init() {
t.step(() => {
if (window.name == 'second/load') {
assert_equals(document.scrollingElement.scrollTop, 2000);
assert_equals(document.scrollingElement.scrollLeft, 1000);
window.name = '';
t.done();
} else {
window.scrollTo(1000, 2000);
window.name = 'second/load';
setTimeout(() => { window.location = '../../resources/back.html'; }, 0);
}
});
}
window.addEventListener('DOMContentLoaded', init, true);
</script>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment