Commit 77ce1706 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[breadcrumb] Add unittest support for <cr-action-menu>

<cr-action-menu> is Polymer3 and so won't be active during a files app
unittest framework.

Add window.UNIT_TEST guards to prevent the breadcrumb.js unittest from
trying to access undefined (in unittest) <cr-action-menu> api.

Define window.UNIT_TEST and window.IN_TEST for closure compilation. It
seems window.IN_TEST is only closure defined in gallery externs so add
these new closure defines to a files app common externs file.

Bug: 1061388
Change-Id: Id5c11649f32969d5b1b11cbf30236c80edbc69c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2138939Reviewed-by: default avatarAlex Danilo <adanilo@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756983}
parent 9e918ea3
......@@ -30,3 +30,17 @@ Window.prototype.HTMLImports;
* @type {function(function())}
*/
Window.prototype.HTMLImports.whenReady;
/**
* True if in test: set by the background.js page.
*
* @type {boolean}
*/
Window.prototype.IN_TEST;
/**
* Set true in some unit tests.
*
* @type {boolean}
*/
Window.prototype.UNIT_TEST;
......@@ -423,10 +423,10 @@ class BreadCrumb extends HTMLElement {
// Show drop-down below the elider button.
const menu = this.shadowRoot.querySelector('cr-action-menu');
const top = elider.offsetTop + elider.offsetHeight + 4;
menu.showAt(elider, {top: top});
!window.UNIT_TEST && menu.showAt(elider, {top: top});
// Style drop-down and horizontal position.
const dialog = menu.getDialog();
const dialog = !window.UNIT_TEST ? menu.getDialog() : {style: {}};
dialog.style['left'] = position + 'px';
dialog.style['right'] = position + 'px';
dialog.style['overflow'] = 'hidden auto';
......@@ -455,7 +455,7 @@ class BreadCrumb extends HTMLElement {
// Close the drop-down <dialog> if needed.
const menu = this.shadowRoot.querySelector('cr-action-menu');
if (menu.getDialog().hasAttribute('open')) {
if (!window.UNIT_TEST && menu.getDialog().hasAttribute('open')) {
menu.close();
}
}
......
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