Skip to content

Commit

Permalink
Convert scroll-position-restored-on-back-at-load-event.html to new style
Browse files Browse the repository at this point in the history
It can fix the leak by convert test to new style.

Bug: 835802
Change-Id: Icb8efd927fc0e8fc8301be6b7c1c0efd9ed51504
Reviewed-on: https://chromium-review.googlesource.com/1028835
Reviewed-by: David Bokan <bokan@chromium.org>
Commit-Queue: Jianpeng Chao <chaopeng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#563421}
  • Loading branch information
chaopeng authored and Commit Bot committed May 31, 2018
1 parent 329c2a2 commit 207e866
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 52 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,39 +1,42 @@
<!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>

0 comments on commit 207e866

Please sign in to comment.