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

Unified Diff: chrome/test/data/webui/cr_elements/cr_action_menu_test.js

Issue 2966163004: [cr-action-menu] Use clientWidth for rtl flipping. (Closed)
Patch Set: Created 3 years, 5 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 | ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/cr_elements/cr_action_menu_test.js
diff --git a/chrome/test/data/webui/cr_elements/cr_action_menu_test.js b/chrome/test/data/webui/cr_elements/cr_action_menu_test.js
index 62e51011ed259d10ee569e8da711fe095a892fe4..3a8ec6664caba4a4daf5a2d750b9f896a34a8887 100644
--- a/chrome/test/data/webui/cr_elements/cr_action_menu_test.js
+++ b/chrome/test/data/webui/cr_elements/cr_action_menu_test.js
@@ -32,6 +32,8 @@ suite('CrActionMenu', function() {
});
teardown(function() {
+ document.body.style.direction = 'ltr';
+
if (menu.open)
menu.close();
});
@@ -270,7 +272,6 @@ suite('CrActionMenu', function() {
assertEquals(140 - menuWidth, menu.offsetLeft);
assertEquals('250px', menu.style.top);
menu.close();
- document.body.style.direction = 'ltr';
});
test('offscreen scroll positioning', function() {
@@ -292,6 +293,7 @@ suite('CrActionMenu', function() {
position: absolute;
top: ${containerTop}px;
left: ${containerLeft}px;
+ right: ${containerLeft}px;
height: ${containerHeight}px;
width: ${containerWidth}px;
}
@@ -328,9 +330,10 @@ suite('CrActionMenu', function() {
// button.
document.body.scrollLeft = bodyWidth;
document.body.scrollTop = bodyHeight;
+ var container = document.querySelector('#container');
- document.querySelector('#container').scrollLeft = containerLeft;
- document.querySelector('#container').scrollTop = containerTop;
+ container.scrollLeft = containerLeft;
+ container.scrollTop = containerTop;
menu.showAt(dots, {anchorAlignmentX: AnchorAlignment.AFTER_START});
assertEquals(`${containerLeft}px`, menu.style.left);
@@ -353,5 +356,25 @@ suite('CrActionMenu', function() {
var buttonHeight = dots.offsetHeight;
assertEquals(containerLeft - menuWidth + buttonWidth, menu.offsetLeft);
assertEquals(containerTop - menuHeight + buttonHeight, menu.offsetTop);
+ menu.close();
+
+ // showAtPosition takes into account scroll position.
+ document.body.scrollLeft = 500;
dpapad 2017/07/06 22:05:37 The "offscreen scroll positioning" test is becomin
calamity 2017/07/07 03:18:01 Done.
+ document.body.scrollTop = 1000;
+ menu.showAtPosition({top: 50, left: 50});
+ assertEquals(
+ 550, menu.offsetLeft);
+ assertEquals(1050, menu.offsetTop);
+ menu.close();
+
+ // Anchor to an item in RTL.
+ document.body.style.direction = 'rtl';
+ document.body.scrollLeft = 0;
+ document.body.scrollTop = 0;
+ menu.showAt(dots, {anchorAlignmentX: AnchorAlignment.AFTER_START});
+ assertEquals(
+ container.offsetLeft + containerWidth - menuWidth, menu.offsetLeft);
+ assertEquals(containerTop, menu.offsetTop);
+ menu.close();
});
});
« no previous file with comments | « no previous file | ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698