Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: LayoutTests/scrollingcoordinator/non-fast-scrollable-visibility-change.html

Issue 850113003: iframe updates its parent scrollable area set when its visibility change (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: minor spelling corrections Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/scrollingcoordinator/non-fast-scrollable-visibility-change-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/scrollingcoordinator/non-fast-scrollable-visibility-change.html
diff --git a/LayoutTests/scrollingcoordinator/non-fast-scrollable-visibility-change.html b/LayoutTests/scrollingcoordinator/non-fast-scrollable-visibility-change.html
index 9d8e356dd6002554b01438e39b18b9e7382ee1fa..d12c034f7dad840ff3b1396af32e96ae9f7c1f65 100644
--- a/LayoutTests/scrollingcoordinator/non-fast-scrollable-visibility-change.html
+++ b/LayoutTests/scrollingcoordinator/non-fast-scrollable-visibility-change.html
@@ -3,28 +3,51 @@
body {
margin: 0;
}
- .non-fast {
+ .container {
height: 250px;
width: 250px;
+ margin-top: 50px;
display: block;
- background-color: red;
- overflow: scroll;
}
- .non-fast > div {
+ .container > div {
+ height: 200px;
+ width: 200px;
+ overflow: scroll;
+ }
+ .container > div > div {
height: 1000px;
width: 1000px;
- display: block;
background: linear-gradient(to bottom, red, white);
}
+ .container > iframe {
+ height: 222px;
+ width: 222px;
+ display: block;
+ border: none;
+ }
</style>
-<div id="first" class="non-fast">
- This should be covered by the ONLY visible green overlay.
-</div>
-<div id="second" class="non-fast" style="margin-top:50px;">
- This should not be visible.
- <div></div>
-</div>
+<section id='div' style="display:none;">
+ <div class="to-show container">
+ </div>
+ <div class="to-hide container">
+ <div>
+ <div>This should not be visible.</div>
+ </div>
+ </div>
+</section>
+
+<section id="iframe" style="display:none;">
+ <div class="to-show container">
+ </div>
+ <div class="to-hide container">
+ <iframe src="data:text/html;charset=utf-8,<div style='height:1000px; width:1000px; background: linear-gradient(to bottom, red, white);'>">
+ This should not be visible.
+ </iframe>
+ </div>
+</section>
+
+<p>Two squares should be visible and fully covered by green overlays.</p>
<div id="console"></div>
@@ -34,63 +57,105 @@
window.jsTestIsAsync = true;
description('This test ensures that changing visibility of a non-fast ' +
'scrollable area correctly updates list of non-fast scrollable ' +
- 'areas. (See http://crbug.com/434982)');
+ 'areas (See http://crbug.com/434982). Two types of non-fast ' +
+ 'scrollable regions are covered: div, and iframe.');
+
+ onload = next;
+
+ var testCases = [
+ // type, bounding box of element to show, bounding box of element to hide
+ ['div', '[0, 50, 200, 200]', '[0, 350, 200, 200]'],
+ ['iframe', '[0, 50, 222, 222]', '[0, 350, 222, 222]']];
+
+ var index = 0;
+ function next(){
+ if (index < testCases.length) {
+ var type = testCases[index][0];
+ debug('running tests for non-fast scrollable ' + type);
+ runTest.apply(this, testCases[index]);
+ } else {
+ // Next 3 statements have no functional impact just visual
+ showSectionIf(function(){return true;});
+ awaitCompsitingUpdate(function(){
+ runNonFastScrollableRegionTest();
+
+ finishJSTest();
+ });
+ }
- onload = function() {
- awaitCompsitingUpdate(runTest);
- };
+ index++;
+ }
- function runTest() {
- var first = document.getElementById('first'),
- second = document.getElementById('second');
+ // Execute tests for given non-fast scrollable type.
+ function runTest(type, elemToShowExpected, elemToHideExpected) {
+ // Hide all sections that are not relevant to this test to ensure
+ // |window.internals.nonFastScrollableRects| returns only the relevant non-
+ // fast scrollable regions.
+ showSectionIf(function(section){return section.id == type;});
- nonFastScrollableRects = internals.nonFastScrollableRects(document);
- shouldBe('nonFastScrollableRects.length', '1');
- shouldBeEqualToString('rectToString(nonFastScrollableRects[0])',
- '[0, 300, 250, 250]'); // second div
+ awaitCompsitingUpdate(function() {
+ shouldBeEqualToString('document.getElementById("' + type + '").style.display', 'block');
- // Hide container before making it non-fast scrollable to ensure any
- // layout occurs while it is invisible.
- first.style.visibility = 'hidden';
- makeNonFastScrollable(first);
+ var elemToShow = document.querySelector('section#' + type + '> .to-show'),
+ elemToHide = document.querySelector('section#' + type + '> .to-hide');
- // Change visibility (hidden -> visible), which should not cause any layout,
- // and verify that non-fast scrollable areas are correctly updated.
- awaitCompsitingUpdate(function() {
- first.style.visibility = 'visible';
- shouldBe('window.internals.needsLayoutCount()', '0');
+ nonFastScrollableRects = internals.nonFastScrollableRects(document);
+ shouldBe('nonFastScrollableRects.length', '1');
+ shouldBeEqualToString('rectToString(nonFastScrollableRects[0])', elemToHideExpected);
+
+ // Hide container before making it non-fast scrollable to ensure any
+ // layout occurs while it is invisible.
+ elemToShow.style.visibility = 'hidden';
+ appendScrollable(elemToShow, type);
+ // Change visibility (hidden -> visible), which should not cause any layout,
+ // and verify that non-fast scrollable areas are correctly updated.
awaitCompsitingUpdate(function() {
- nonFastScrollableRects = internals.nonFastScrollableRects(document);
- shouldBe('nonFastScrollableRects.length', '2');
- shouldBeEqualToString('rectToString(nonFastScrollableRects[0])',
- '[0, 0, 250, 250]'); // first div
- shouldBeEqualToString('rectToString(nonFastScrollableRects[1])',
- '[0, 300, 250, 250]'); // second div
-
- // Change visibility (visible -> hidden)
- second.style.visibility = 'hidden';
+ elemToShow.style.visibility = 'visible';
shouldBe('window.internals.needsLayoutCount()', '0');
awaitCompsitingUpdate(function() {
- // This has no functional impact just visual
- runNonFastScrollableRegionTest();
-
nonFastScrollableRects = internals.nonFastScrollableRects(document);
- shouldBe('nonFastScrollableRects.length', '1');
- shouldBeEqualToString('rectToString(nonFastScrollableRects[0])',
- '[0, 0, 250, 250]'); // first div
-
- finishJSTest();
+ shouldBe('nonFastScrollableRects.length', '2');
+ shouldBeEqualToString('rectToString(nonFastScrollableRects[0])', elemToShowExpected);
+ shouldBeEqualToString('rectToString(nonFastScrollableRects[1])', elemToHideExpected);
+
+ // Change visibility (visible -> hidden)
+ elemToHide.style.visibility = 'hidden';
+ shouldBe('window.internals.needsLayoutCount()', '0');
+
+ awaitCompsitingUpdate(function() {
+ nonFastScrollableRects = internals.nonFastScrollableRects(document);
+ shouldBe('nonFastScrollableRects.length', '1');
+ shouldBeEqualToString('rectToString(nonFastScrollableRects[0])', elemToShowExpected);
+ next();
+ });
});
});
});
}
- // Makes the container non-fast scrollable area by appending a large element to it.
- function makeNonFastScrollable(container) {
- var inner = document.createElement('div');
- container.appendChild(inner);
+ // Appends to container an scrollable element of the given type.
+ // Note that because this layout test runs with --dump-render-tree flag
+ // the appended scrollable is always non-fast even on HDPI platforms.
+ function appendScrollable(container, type) {
+ var inner;
+ switch (type) {
+ case 'div':
+ inner = '<div><div>This should be covered by a green overlay.</div></div>';
+ break;
+ case 'iframe':
+ inner = '<iframe id="iframe" src="data:text/html;charset=utf-8,<div style=\'height:1000px; width:1000px; background: linear-gradient(to bottom, red, white);\'>This should be covered by a green overlay.</div>"></iframe>';
+ break;
+ }
+ container.innerHTML = inner;
+ }
+
+ // Shows sections that pass condition but hides others
+ function showSectionIf(condition) {
+ var sections = document.querySelectorAll('section');
+ for (var i = 0; i < sections.length; i++)
+ sections[i].style.display = condition(sections[i]) ? 'block' : 'none';
}
// Waits for one RAF call to ensure compositing update has occurred and invokes task.
« no previous file with comments | « no previous file | LayoutTests/scrollingcoordinator/non-fast-scrollable-visibility-change-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698