Commit 5e1b4cff authored by Joel Hockey's avatar Joel Hockey Committed by Commit Bot

FileManagerDialogBase sets hide state synchronously

Updated FileManagerDialogBase.shown to be set to
false immediately when hide() is called.

Previously, when one dialog spawns a second,
the second fails to show since FileManagerDialogBase
is setting its static 'shown' property to false
async.  The call to show the second dialog is
ignored since the dialog believes it is still
showing the first.

Bug: 1010371
Change-Id: I96d5b9fad72c1c7a87520fdc92604494b5b7a9d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1849474
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Auto-Submit: Joel Hockey <joelhockey@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704490}
parent 94ed56cc
......@@ -191,6 +191,10 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FileListSelectionModelTest) {
RunTestURL("foreground/js/ui/file_list_selection_model_unittest_gen.html");
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, FileManagerDialogBaseTest) {
RunTestURL("foreground/js/ui/file_manager_dialog_base_unittest_gen.html");
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, MultiMenu) {
RunTestURL("foreground/js/ui/multi_menu_unittest_gen.html");
}
......
......@@ -233,6 +233,15 @@ js_library("file_manager_dialog_base") {
"//ui/webui/resources/js/cr:ui",
"//ui/webui/resources/js/cr/ui:dialogs",
]
externs_list = [ "$externs_path/chrome_extensions.js" ]
}
js_unittest("file_manager_dialog_base_unittest") {
deps = [
":file_manager_dialog_base",
"//ui/file_manager/base/js:test_error_reporting",
"//ui/webui/resources/js:webui_resource_test",
]
}
js_library("file_manager_ui") {
......@@ -492,6 +501,7 @@ js_test_gen_html("js_test_gen_html") {
":actions_submenu_unittest",
":directory_tree_unittest",
":file_list_selection_model_unittest",
":file_manager_dialog_base_unittest",
":file_table_list_unittest",
":file_table_unittest",
":file_tap_handler_unittest",
......
......@@ -84,11 +84,11 @@ class FileManagerDialogBase extends cr.ui.dialogs.BaseDialog {
* @param {Function=} opt_onHide Called when the dialog is hidden.
*/
hide(opt_onHide) {
FileManagerDialogBase.shown = false;
super.hide(() => {
if (opt_onHide) {
opt_onHide();
}
FileManagerDialogBase.shown = false;
});
}
}
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
async function testShowDialogAfterHide(done) {
// Polyfill chrome.app.window.current().
/** @suppress {duplicate|checkTypes} */
chrome.app = {window: {current: () => null}};
const container =
assertInstanceof(document.createElement('div'), HTMLElement);
function isShown() {
return !!container.querySelector('.cr-dialog-container.shown');
}
const dialog = new FileManagerDialogBase(container);
// Show the dialog and wait until .shown is set on .cr-dialog-container.
// This happens async.
dialog.showBlankDialog();
await waitUntil(isShown);
// Call hide, and validate .shown is removed (sync).
dialog.hide();
assertFalse(isShown());
// Show the dialog again and ensure that it gets displayed.
// Previously some async processing from hide() would stop
// the dialog showing again at all if it was called too soon.
dialog.showBlankDialog();
await waitUntil(isShown);
done();
}
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